Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
4b55160177 | |||
1faace6bce | |||
995293926f |
31
services/game/client.go
Normal file
31
services/game/client.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package game
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "2020-11-16"
|
||||||
|
)
|
||||||
|
|
||||||
|
var HOST = requests.Host{
|
||||||
|
Default: "game",
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
sdk.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient() (client *Client, err error) {
|
||||||
|
client = new(Client)
|
||||||
|
err = client.Init()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetGameOsInfo 获取游戏系统信息
|
||||||
|
func (c *Client) GetGameOsInfo(req *GetGameOsInfoReq) (resp *GetGameOsInfoResp, err error) {
|
||||||
|
resp = CreateGetGameOsInfoResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
22
services/game/client_test.go
Normal file
22
services/game/client_test.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package game
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetGameOsInfo(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req := CreateGetGameOsInfoReq()
|
||||||
|
|
||||||
|
resp, err := client.GetGameOsInfo(req)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(resp.Code, resp.Msg, resp.Data.OsList, resp.Data.OsRelList2)
|
||||||
|
}
|
49
services/game/game.go
Normal file
49
services/game/game.go
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package game
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetGameOsInfoReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetGameOsInfoResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data Data `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Data struct {
|
||||||
|
OsRelList2 []OsRelList2 `json:"os_rel_list2"`
|
||||||
|
OsList map[string]OsList `json:"os_list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OsRelList2 struct {
|
||||||
|
TwPlatID int `json:"tw_plat_id"`
|
||||||
|
TwOs int `json:"tw_os"`
|
||||||
|
Os int `json:"os"`
|
||||||
|
OsTwo int `json:"os_two"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OsList struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
OsTwo map[string]interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetGameOsInfoReq() *GetGameOsInfoReq {
|
||||||
|
req := &GetGameOsInfoReq{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/api/game/getGameOsInfo")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetGameOsInfoResp() *GetGameOsInfoResp {
|
||||||
|
return &GetGameOsInfoResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
35
services/script/client.go
Normal file
35
services/script/client.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package script
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "2020-11-16"
|
||||||
|
)
|
||||||
|
|
||||||
|
var HOST = requests.Host{
|
||||||
|
Default: "script",
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
sdk.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient() (client *Client, err error) {
|
||||||
|
client = new(Client)
|
||||||
|
err = client.Init()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenGame 同步到游戏中心
|
||||||
|
func (c *Client) OpenGame(req *OpenGameReq) (resp *OpenGameResp, err error) {
|
||||||
|
resp = CreateOpenGameResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
21
services/script/client_test.go
Normal file
21
services/script/client_test.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package script
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOpenGame(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
req := CreateOpenGameReq(7275)
|
||||||
|
|
||||||
|
resp, err := client.OpenGame(req)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(resp.Code, resp.Msg)
|
||||||
|
}
|
41
services/script/script.go
Normal file
41
services/script/script.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package script
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OpenGameReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type OpenGameResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHttpContentBytes 因为http://script.gaore.com/open_game.php?game_id=这个接口返回的不是json,反序列化会报错,所以返回一个固定的json
|
||||||
|
func (baseResponse *OpenGameResp) GetHttpContentBytes() []byte {
|
||||||
|
b, _ := json.Marshal(map[string]interface{}{"code": 200, "msg": "success"})
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOpenGameReq 创建同步到游戏中心请求
|
||||||
|
func CreateOpenGameReq(gameId int) *OpenGameReq {
|
||||||
|
req := &OpenGameReq{
|
||||||
|
&requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "open_game.php?game_id="+fmt.Sprintf("%v", gameId))
|
||||||
|
req.Method = requests.POST
|
||||||
|
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOpenGameResp 创建同步到游戏中心响应
|
||||||
|
func CreateOpenGameResp() *OpenGameResp {
|
||||||
|
return &OpenGameResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
@ -33,3 +33,9 @@ func (c *Client) SyncGameServerList(req *SyncGameServerListReq) (resp *SyncGameS
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) SetUserNewGameAuth(req *SetUserNewGameAuthReq) (resp *SetUserNewGameAuthResp, err error) {
|
||||||
|
resp = CreateSetUserNewGameAuthResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -34,3 +34,21 @@ func TestSyncGameServerList(t *testing.T) {
|
|||||||
|
|
||||||
fmt.Println(resp.Code, resp.Msg, resp.Count)
|
fmt.Println(resp.Code, resp.Msg, resp.Count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClient_SetUserNewGameAuth(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
req := CreateSetUserNewGameAuthReq(map[string]string{
|
||||||
|
"game_sign": "qwldy",
|
||||||
|
"game_id": "7275",
|
||||||
|
})
|
||||||
|
|
||||||
|
resp, err := client.SetUserNewGameAuth(req)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(resp.Code, resp.Msg, resp.Data.Result)
|
||||||
|
}
|
||||||
|
59
services/stat/user.go
Normal file
59
services/stat/user.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package stat
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SetUserNewGameAuthReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetUserNewGameAuthResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data Data `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Data struct {
|
||||||
|
Result string `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = "gr_new_game"
|
||||||
|
|
||||||
|
// CreateSetUserNewGameAuthReq 设置用户新游戏授权
|
||||||
|
func CreateSetUserNewGameAuthReq(data map[string]string) *SetUserNewGameAuthReq {
|
||||||
|
req := &SetUserNewGameAuthReq{
|
||||||
|
&requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
|
||||||
|
ts := time.Now().Unix()
|
||||||
|
hash := md5.New()
|
||||||
|
hash.Write([]byte(fmt.Sprintf("%v%v", ts, key)))
|
||||||
|
hashBytes := hash.Sum(nil)
|
||||||
|
|
||||||
|
token := hex.EncodeToString(hashBytes)
|
||||||
|
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/user/setUserNewGameAuth")
|
||||||
|
req.Method = requests.POST
|
||||||
|
|
||||||
|
req.FormParams = data
|
||||||
|
if req.FormParams == nil {
|
||||||
|
req.FormParams = make(map[string]string)
|
||||||
|
}
|
||||||
|
req.FormParams["sign"] = token
|
||||||
|
req.FormParams["time"] = fmt.Sprintf("%v", ts)
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSetUserNewGameAuthResp 创建设置用户新游戏授权响应
|
||||||
|
func CreateSetUserNewGameAuthResp() *SetUserNewGameAuthResp {
|
||||||
|
return &SetUserNewGameAuthResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user