diff --git a/services/game/client.go b/services/game/client.go index 698a8df..e7a7f38 100644 --- a/services/game/client.go +++ b/services/game/client.go @@ -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) { diff --git a/services/game/game.go b/services/game/game.go index ba1c88d..2e7af17 100644 --- a/services/game/game.go +++ b/services/game/game.go @@ -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:"-" ` diff --git a/services/game/unit_test.go b/services/game/unit_test.go new file mode 100644 index 0000000..5e9a314 --- /dev/null +++ b/services/game/unit_test.go @@ -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 + +}