Compare commits
No commits in common. "master" and "v1.1.33" have entirely different histories.
@ -1,35 +0,0 @@
|
||||
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
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
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{},
|
||||
}
|
||||
}
|
@ -33,9 +33,3 @@ func (c *Client) SyncGameServerList(req *SyncGameServerListReq) (resp *SyncGameS
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) SetUserNewGameAuth(req *SetUserNewGameAuthReq) (resp *SetUserNewGameAuthResp, err error) {
|
||||
resp = CreateSetUserNewGameAuthResp()
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
@ -34,21 +34,3 @@ func TestSyncGameServerList(t *testing.T) {
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
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{},
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user