7
0

新增同步开服数据接口

This commit is contained in:
许 洋 2024-09-06 17:59:18 +08:00
parent f11735110f
commit 675a48f7d1
3 changed files with 133 additions and 0 deletions

35
services/stat/client.go Normal file
View File

@ -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
}

View File

@ -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)
}

62
services/stat/game.go Normal file
View File

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