7
0
gaore-common-sdk-go/services/stat/user.go

60 lines
1.3 KiB
Go
Raw Permalink Normal View History

2024-09-19 12:33:23 +08:00
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{},
}
}