From d3f303e20cafbd61c8953276c3f2ea5064133bea Mon Sep 17 00:00:00 2001 From: liguanjie Date: Tue, 10 Jun 2025 14:19:18 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90cs=E6=9C=8D=E5=8A=A1=E3=80=91=201?= =?UTF-8?q?=E3=80=81=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/cs/client.go | 6 ++++++ services/cs/client_test.go | 20 ++++++++++++++++++++ services/cs/user.go | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) 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 +}