封装 /api/game/getGameRoleInfo 接口
This commit is contained in:
parent
1f0bfefcfc
commit
ef2d84fb2f
@ -170,6 +170,14 @@ func (c *Client) GetGameRoleName(req *GetGameRoleNameReq) (response *GetGameRole
|
||||
return
|
||||
}
|
||||
|
||||
// GetGameRoleInfo
|
||||
// 获取游戏角色信息
|
||||
func (c *Client) GetGameRoleInfo(req *GetGameRoleInfoReq) (response *GetGameRoleInfoResp, err error) {
|
||||
response = CreateGetGameRoleInfoResp()
|
||||
err = c.DoAction(req, response)
|
||||
return
|
||||
}
|
||||
|
||||
// GetAnchorUser
|
||||
// 获取主播信息接口
|
||||
func (c *Client) GetAnchorUser(req *GetAnchorUserReq) (resp *GetAnchorUserResp, err error) {
|
||||
|
||||
@ -529,6 +529,8 @@ func CreateGetLoginBgResp() *GetLoginBgResp {
|
||||
}
|
||||
}
|
||||
|
||||
// GetGameRoleNameReq
|
||||
// 该接口response格式不统一慎用,请求hlhj的数据,返回的数据格式又是另一种
|
||||
type GetGameRoleNameReq struct {
|
||||
*requests.RpcRequest
|
||||
AppId int64 `position:"Body" field:"appid"`
|
||||
@ -595,6 +597,67 @@ func CreateGetGameRoleNameResp() *GetGameRoleNameResp {
|
||||
}
|
||||
}
|
||||
|
||||
// GetGameRoleInfoResp
|
||||
// 统一获取角色信息接口,getGameRoleInfo 接口对response格式做了统一处理
|
||||
type GetGameRoleInfoResp struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
UserInfo []GetGameRoleInfoDataRoleItem `json:"userinfo"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type GetGameRoleInfoDataRoleItem struct {
|
||||
RoleId string `json:"roleId"`
|
||||
Name string `json:"name"`
|
||||
Server int64 `json:"server"`
|
||||
ServerName string `json:"serverName"`
|
||||
Level int64 `json:"level"`
|
||||
VipLevel int64 `json:"vipLevel"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
RoleLevelUpdateTime int64 `json:"roleLevelUpdateTime"`
|
||||
Power int64 `json:"power"`
|
||||
Profession string `json:"profession"`
|
||||
ZhuanshengLv int64 `json:"zhuansheng_lv"`
|
||||
ZhuanshengName string `json:"zhuanshengName"`
|
||||
Gold int64 `json:"gold"`
|
||||
}
|
||||
|
||||
type GetGameRoleInfoReq struct {
|
||||
*requests.RpcRequest
|
||||
AppId int64 `position:"Body" field:"appid"`
|
||||
UserId int64 `position:"Body" field:"uid"`
|
||||
UserName string `position:"Body" field:"user_name"`
|
||||
ServerId int64 `position:"Body" field:"server_id"`
|
||||
Time int64 `position:"Body" field:"time"`
|
||||
Sign string `position:"Body" field:"sign"`
|
||||
Os int64 `position:"Body" field:"os"`
|
||||
}
|
||||
|
||||
func CreateGetGameRoleInfoReq(gameId, sid, uid, os int64, nameName string) *GetGameRoleInfoReq {
|
||||
ts := time.Now().Unix()
|
||||
req := &GetGameRoleInfoReq{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
AppId: gameId,
|
||||
UserName: nameName,
|
||||
ServerId: sid,
|
||||
UserId: uid,
|
||||
Time: ts,
|
||||
Sign: utils.Md5(fmt.Sprintf("%d%d%s", gameId, ts, gameKey)),
|
||||
Os: os,
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getGameRoleInfo")
|
||||
req.Method = requests.POST
|
||||
return req
|
||||
}
|
||||
|
||||
func CreateGetGameRoleInfoResp() *GetGameRoleInfoResp {
|
||||
return &GetGameRoleInfoResp{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
}
|
||||
|
||||
type GetSdkThemeReq struct {
|
||||
*requests.RpcRequest
|
||||
GameId int64 `position:"Query" field:"game_id" default:"-" `
|
||||
|
||||
21
services/game/unit_test.go
Normal file
21
services/game/unit_test.go
Normal file
@ -0,0 +1,21 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestName(t *testing.T) {
|
||||
roleReq := CreateGetGameRoleInfoReq(3706, 1373, 0, 0, "13924600328")
|
||||
roleReq.SetReadTimeout(10 * time.Minute)
|
||||
|
||||
client, _ := NewClient()
|
||||
response, err := client.GetGameRoleInfo(roleReq)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
_ = response
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user