From 995293926fb3375b90891a32896d0a87f0c4ccf7 Mon Sep 17 00:00:00 2001 From: xuyang Date: Thu, 12 Sep 2024 14:27:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E6=B8=B8?= =?UTF-8?q?=E6=88=8F=E7=B3=BB=E7=BB=9F=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/game/client.go | 31 +++++++++++++++++++++++ services/game/client_test.go | 22 ++++++++++++++++ services/game/game.go | 49 ++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 services/game/client.go create mode 100644 services/game/client_test.go create mode 100644 services/game/game.go diff --git a/services/game/client.go b/services/game/client.go new file mode 100644 index 0000000..635d31f --- /dev/null +++ b/services/game/client.go @@ -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 +} diff --git a/services/game/client_test.go b/services/game/client_test.go new file mode 100644 index 0000000..58a6d37 --- /dev/null +++ b/services/game/client_test.go @@ -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) +} diff --git a/services/game/game.go b/services/game/game.go new file mode 100644 index 0000000..51e65dd --- /dev/null +++ b/services/game/game.go @@ -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{}, + } +}