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{}, + } +} diff --git a/services/mkt/client.go b/services/mkt/client.go index 53023b7..9c03d71 100644 --- a/services/mkt/client.go +++ b/services/mkt/client.go @@ -29,3 +29,15 @@ func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err = client.InitWithAccessKey(accesskey, secrect, source) return } + +func NewClient() (client *Client, err error) { + client = new(Client) + err = client.Init() + return +} + +func (c *Client) SubjectList(req *SubjectListRequest) (response *SubjectListResponse, err error) { + response = CreateSubjectListResponse() + err = c.DoAction(req, response) + return +} diff --git a/services/mkt/client_test.go b/services/mkt/client_test.go new file mode 100644 index 0000000..721a581 --- /dev/null +++ b/services/mkt/client_test.go @@ -0,0 +1,22 @@ +package mkt + +import ( + "fmt" + "testing" +) + +func TestSubjectList(t *testing.T) { + client, err := NewClient() + if err != nil { + panic(err) + } + + req := CreateSubjectListRequest(0) + req.Port = "9090" + list, err := client.SubjectList(req) + if err != nil { + panic(err) + } + + fmt.Println(list.Status, list.Code, list.Msg, list.Data) +} diff --git a/services/mkt/subject.go b/services/mkt/subject.go new file mode 100644 index 0000000..8177248 --- /dev/null +++ b/services/mkt/subject.go @@ -0,0 +1,68 @@ +package mkt + +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" +) + +const appKey = "fc1f841#@de!!08" + +type SubjectListRequest struct { + *requests.RpcRequest +} + +type SubjectListResponse struct { + *responses.BaseResponse + Status bool `json:"status"` + Code int `json:"code"` + Msg string `json:"msg"` + Data struct { + List map[int]Data `json:"list"` + } `json:"data"` +} + +type Data struct { + Abbr string `json:"abbr"` + AbbrSign string `json:"abbr_sign"` + Id int `json:"id"` + Name string `json:"name"` + State int `json:"state"` + System string `json:"system"` + Type int `json:"type"` +} + +// CreateSubjectListRequest 公司列表请求 +func CreateSubjectListRequest(state int) (req *SubjectListRequest) { + ts := time.Now().Unix() + hash := md5.New() + hash.Write([]byte(fmt.Sprintf("%v%v", ts, appKey))) + hashBytes := hash.Sum(nil) + + token := hex.EncodeToString(hashBytes) + + req = &SubjectListRequest{ + RpcRequest: &requests.RpcRequest{}, + } + + req.InitWithApiInfo(HOST, VERSION, fmt.Sprintf("/api/subject/list")) + + req.FormParams = map[string]string{ + "token": token, + "ts": fmt.Sprintf("%v", ts), + "state": fmt.Sprintf("%v", state), + } + req.Method = requests.POST + return +} + +// CreateSubjectListResponse 公司列表请求响应 +func CreateSubjectListResponse() (response *SubjectListResponse) { + response = &SubjectListResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/services/pay/client.go b/services/pay/client.go index 97c58ea..3338267 100644 --- a/services/pay/client.go +++ b/services/pay/client.go @@ -49,8 +49,8 @@ func (c *Client) ComplaintUpload(req *ComplaintUploadRequest) (response *Complai return } -func (c *Client) ComplaintNotifyUrl(req *ComplaintNotifyUrlRequest) (response *ComplaintNotifyUrlResponse, err error) { - response = CreateComplaintNotifyUrlResponse() +func (c *Client) MerchantConfigDebug(req *merchantConfigDebugRequest) (response *merchantConfigDebugResponse, err error) { + response = CreateMerchantConfigDebugResponse() err = c.DoAction(req, response) return } diff --git a/services/pay/complaint_notify_url.go b/services/pay/complaint_notify_url.go deleted file mode 100644 index 571fdb9..0000000 --- a/services/pay/complaint_notify_url.go +++ /dev/null @@ -1,35 +0,0 @@ -package pay - -import ( - "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" - "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" -) - -type ComplaintNotifyUrlRequest struct { - *requests.RpcRequest - MchId string `position:"Body" field:"mch_id" default:"" ` - NotifyUrl string `position:"Body" field:"notify_url" default:"" ` - Type int `position:"Body" field:"type" default:""` -} - -type ComplaintNotifyUrlResponse struct { - *responses.BaseResponse - Code int `json:"code"` - Msg string `json:"msg"` -} - -func CreateComplaintNotifyUrlRequest() (req *ComplaintNotifyUrlRequest) { - req = &ComplaintNotifyUrlRequest{ - RpcRequest: &requests.RpcRequest{}, - } - req.InitWithApiInfo(HOST, VERSION, "/api/complaint/createWxNotifyUrl") - req.Method = requests.POST - return -} - -func CreateComplaintNotifyUrlResponse() (response *ComplaintNotifyUrlResponse) { - response = &ComplaintNotifyUrlResponse{ - BaseResponse: &responses.BaseResponse{}, - } - return -} diff --git a/services/pay/merchant_config_debug.go b/services/pay/merchant_config_debug.go new file mode 100644 index 0000000..c574707 --- /dev/null +++ b/services/pay/merchant_config_debug.go @@ -0,0 +1,33 @@ +package pay + +import ( + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" +) + +type merchantConfigDebugRequest struct { + *requests.RpcRequest + MchId string `position:"Body" field:"mch_id" default:"" ` +} + +type merchantConfigDebugResponse struct { + *responses.BaseResponse + Code int `json:"code"` + Msg string `json:"msg"` +} + +func CreateMerchantConfigDebugRequest() (req *merchantConfigDebugRequest) { + req = &merchantConfigDebugRequest{ + RpcRequest: &requests.RpcRequest{}, + } + req.InitWithApiInfo(HOST, VERSION, "/api/complaint/configDebug") + req.Method = requests.POST + return +} + +func CreateMerchantConfigDebugResponse() (response *merchantConfigDebugResponse) { + response = &merchantConfigDebugResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/services/script/client.go b/services/script/client.go new file mode 100644 index 0000000..69096a0 --- /dev/null +++ b/services/script/client.go @@ -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 +} diff --git a/services/script/client_test.go b/services/script/client_test.go new file mode 100644 index 0000000..3834fe1 --- /dev/null +++ b/services/script/client_test.go @@ -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) +} diff --git a/services/script/script.go b/services/script/script.go new file mode 100644 index 0000000..30287f7 --- /dev/null +++ b/services/script/script.go @@ -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{}, + } +} diff --git a/services/stat/client.go b/services/stat/client.go new file mode 100644 index 0000000..c55fce2 --- /dev/null +++ b/services/stat/client.go @@ -0,0 +1,41 @@ +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 +} + +func (c *Client) SetUserNewGameAuth(req *SetUserNewGameAuthReq) (resp *SetUserNewGameAuthResp, err error) { + resp = CreateSetUserNewGameAuthResp() + err = c.DoAction(req, resp) + return +} diff --git a/services/stat/client_test.go b/services/stat/client_test.go new file mode 100644 index 0000000..c83e4cb --- /dev/null +++ b/services/stat/client_test.go @@ -0,0 +1,54 @@ +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) +} + +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) +} 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{}, + } +} diff --git a/services/stat/user.go b/services/stat/user.go new file mode 100644 index 0000000..2a531af --- /dev/null +++ b/services/stat/user.go @@ -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{}, + } +}