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{}, + } +}