diff --git a/services/cs/client.go b/services/cs/client.go index ed5af27..6a013ae 100644 --- a/services/cs/client.go +++ b/services/cs/client.go @@ -34,3 +34,9 @@ func (client *Client) GetUserInfo(req *GetUserInfoRequest) (resp *GetUserInfoRes err = client.DoAction(req, resp) return } + +func (client *Client) GetCsUserRoleList(req *GetUserRoleListRequest) (resp *GetUserRoleListResponse, err error) { + resp = CreateGetUserRoleListResponse() + err = client.DoAction(req, resp) + return +} diff --git a/services/cs/client_test.go b/services/cs/client_test.go index d3f2e6e..b51e5bb 100644 --- a/services/cs/client_test.go +++ b/services/cs/client_test.go @@ -41,3 +41,23 @@ func TestGetUserInfo(t *testing.T) { fmt.Printf(fmt.Sprintf("%v", info)) } + +// 获取玩家角色列表 +func TestGetUserRoleList(t *testing.T) { + client, newErr := NewClient() + if newErr != nil { + panic(newErr) + } + req := CreateGetUserRoleListRequest(int64(63610626), int64(2850)) + info, err := client.GetCsUserRoleList(req) + if err != nil { + t.Error(err) + return + } + if info.Code != 0 { + t.Error("获取玩家角色列表失败") + fmt.Printf(fmt.Sprintf("%v", info)) + return + } + fmt.Printf(fmt.Sprintf("%v", info)) +} diff --git a/services/cs/user.go b/services/cs/user.go index 9815d65..9f858e1 100644 --- a/services/cs/user.go +++ b/services/cs/user.go @@ -47,3 +47,40 @@ func CreateGetUserInfoResponse() (response *GetUserInfoResponse) { } return } + +// UserRoleInfo 玩家角色信息 +type UserRoleInfo struct { + Uid int64 `json:"uid"` + RoleName string `json:"role_name"` + RoleId string `json:"role_id"` +} + +type GetUserRoleListRequest struct { + *requests.JsonRequest +} + +type GetUserRoleListResponse struct { + *responses.BaseResponse + Code int `json:"code"` + Msg string `json:"msg"` + Data []UserRoleInfo `json:"data"` +} + +func CreateGetUserRoleListRequest(uId int64, gameId int64) (req *GetUserRoleListRequest) { + req = &GetUserRoleListRequest{ + JsonRequest: &requests.JsonRequest{}, + } + req.InitWithApiInfo(HOST, VERSION, "/v1/user/role_list") + + req.JsonParams["uid"] = uId + req.JsonParams["game_id"] = gameId + + req.Method = requests.POST + return +} +func CreateGetUserRoleListResponse() (response *GetUserRoleListResponse) { + response = &GetUserRoleListResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +}