From 675a48f7d1fbf9e40e602a1dce5e608c14d6cf1a Mon Sep 17 00:00:00 2001 From: xuyang Date: Fri, 6 Sep 2024 17:59:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=90=8C=E6=AD=A5=E5=BC=80?= =?UTF-8?q?=E6=9C=8D=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/stat/client.go | 35 ++++++++++++++++++++ services/stat/client_test.go | 36 +++++++++++++++++++++ services/stat/game.go | 62 ++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 services/stat/client.go create mode 100644 services/stat/client_test.go create mode 100644 services/stat/game.go diff --git a/services/stat/client.go b/services/stat/client.go new file mode 100644 index 0000000..04a8ccc --- /dev/null +++ b/services/stat/client.go @@ -0,0 +1,35 @@ +package stat + +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: "stat", +} + +type Client struct { + sdk.Client +} + +func NewClient() (client *Client, err error) { + client = new(Client) + err = client.Init() + return +} + +// SyncGameServerList 同步开服数据 +func (c *Client) SyncGameServerList(req *SyncGameServerListReq) (resp *SyncGameServerListResp, err error) { + resp = CreateSyncGameServerListResp() + err = c.DoAction(req, resp) + if err != nil { + return + } + + return +} diff --git a/services/stat/client_test.go b/services/stat/client_test.go new file mode 100644 index 0000000..bcf648d --- /dev/null +++ b/services/stat/client_test.go @@ -0,0 +1,36 @@ +package stat + +import ( + "fmt" + "testing" +) + +func TestSyncGameServerList(t *testing.T) { + client, err := NewClient() + if err != nil { + panic(err) + } + req := CreateSyncGameServerListReq("insertOrUpdate", []map[string]interface{}{ + { + "id": 123564, + "channel_id": 12456, + "version_id": 1, + "game_id": 1, + "server_id": 1, + "game_sign": "test", + "name": "test", + "open_date": "2099-03-01", + "open_time": "12:00:00", + "remark": "", + "status": 1, + "if_tj": 1, + }, + }) + + resp, err := client.SyncGameServerList(req) + if err != nil { + panic(err) + } + + fmt.Println(resp.Code, resp.Msg, resp.Count) +} diff --git a/services/stat/game.go b/services/stat/game.go new file mode 100644 index 0000000..219f663 --- /dev/null +++ b/services/stat/game.go @@ -0,0 +1,62 @@ +package stat + +import ( + "encoding/json" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" +) + +type SyncGameServerListReq struct { + *requests.RpcRequest +} + +type SyncGameServerListResp struct { + *responses.BaseResponse + Code int `json:"code"` + Msg string `json:"msg"` + Count int `json:"count"` +} + +// CreateSyncGameServerListReq 创建同步开服数据请求 +// opt: 更新 insertOrUpdate, 删除 del +// +// data: []map[string]interface{}{ +// { +// "id": data.ID, +// "channel_id": data.ChannelID, +// "version_id": data.VersionID, +// "game_id": data.GameID, +// "server_id": data.ServerID, +// "game_sign": data.GameSign, +// "name": data.Name, +// "open_date": data.OpenDate.Format(constants.DateFormat), +// "open_time": data.OpenTime, +// "remark": data.Remark, +// "status": data.Status, +// "if_tj": data.IfTj, +// }, +// } +func CreateSyncGameServerListReq(opt string, data []map[string]interface{}) *SyncGameServerListReq { + req := &SyncGameServerListReq{ + &requests.RpcRequest{}, + } + + req.InitWithApiInfo(HOST, VERSION, "/game/syncGameServerList") + req.Method = requests.POST + + marshal, _ := json.Marshal(data) + + req.FormParams = map[string]string{ + "opt": opt, + "data": string(marshal), + } + + return req +} + +// CreateSyncGameServerListResp 创建同步开服数据响应 +func CreateSyncGameServerListResp() *SyncGameServerListResp { + return &SyncGameServerListResp{ + BaseResponse: &responses.BaseResponse{}, + } +}