From 607dbc87c6d972e906f5672544e1c9cfba578b19 Mon Sep 17 00:00:00 2001 From: liguanjie Date: Tue, 10 Jun 2025 14:46:46 +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=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E7=A0=81=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/cs/client.go | 12 +++++++ services/cs/client_test.go | 42 +++++++++++++++++++++++ services/cs/user.go | 69 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) diff --git a/services/cs/client.go b/services/cs/client.go index 6a013ae..00e01f3 100644 --- a/services/cs/client.go +++ b/services/cs/client.go @@ -40,3 +40,15 @@ func (client *Client) GetCsUserRoleList(req *GetUserRoleListRequest) (resp *GetU err = client.DoAction(req, resp) return } + +func (client *Client) GetUserServerList(req *GetUserServerListRequest) (resp *GetUserServerListResponse, err error) { + resp = CreateGetUserServerListResponse() + err = client.DoAction(req, resp) + return +} + +func (client *Client) SendSmsCode(req *SendSmsRequest) (resp *SendSmsResponse, err error) { + resp = CreateSendSmsResponse() + err = client.DoAction(req, resp) + return +} diff --git a/services/cs/client_test.go b/services/cs/client_test.go index b51e5bb..33323fe 100644 --- a/services/cs/client_test.go +++ b/services/cs/client_test.go @@ -61,3 +61,45 @@ func TestGetUserRoleList(t *testing.T) { } fmt.Printf(fmt.Sprintf("%v", info)) } + +// 获取玩家区服列表 +func TestGetUserServerList(t *testing.T) { + client, newErr := NewClient() + if newErr != nil { + panic(newErr) + } + req := CreateGetUserServerListRequest(int64(63610626), int64(2850)) + info, err := client.GetUserServerList(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)) +} + +// 给玩家发送短信 +func TestSendSms(t *testing.T) { + client, newErr := NewClient() + if newErr != nil { + panic(newErr) + } + req := CreateSendSmsRequest(SendSmsReq{ + Phone: "13725263463", + }) + info, err := client.SendSmsCode(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 9f858e1..d65581b 100644 --- a/services/cs/user.go +++ b/services/cs/user.go @@ -84,3 +84,72 @@ func CreateGetUserRoleListResponse() (response *GetUserRoleListResponse) { } return } + +// UserServerInfo 玩家区服信息 +type UserServerInfo struct { + ServerName string `json:"server_name"` +} +type GetUserServerListRequest struct { + *requests.JsonRequest +} +type GetUserServerListResponse struct { + *responses.BaseResponse + Code int `json:"code"` + Msg string `json:"msg"` + Data []UserServerInfo `json:"data"` +} + +func CreateGetUserServerListRequest(uId int64, gameId int64) (req *GetUserServerListRequest) { + req = &GetUserServerListRequest{ + JsonRequest: &requests.JsonRequest{}, + } + req.InitWithApiInfo(HOST, VERSION, "/v1/user/server_list") + + req.JsonParams["uid"] = uId + req.JsonParams["game_id"] = gameId + + req.Method = requests.POST + return +} +func CreateGetUserServerListResponse() (response *GetUserServerListResponse) { + response = &GetUserServerListResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} + +type SendSmsReq struct { + Phone string `json:"phone"` +} + +// SendSmsResp 发送短信返回 +type SendSmsResp struct { + // 短信发送时间戳,工单模块 有效期5分钟 + SendCodeTime int64 `json:"send_code_time"` +} + +type SendSmsRequest struct { + *requests.JsonRequest +} +type SendSmsResponse struct { + *responses.BaseResponse + Code int `json:"code"` + Msg string `json:"msg"` + Data SendSmsResp `json:"data"` +} + +func CreateSendSmsRequest(param SendSmsReq) (req *SendSmsRequest) { + req = &SendSmsRequest{ + JsonRequest: &requests.JsonRequest{}, + } + req.InitWithApiInfo(HOST, VERSION, "/v1/user/send_sms") + req.JsonParams["phone"] = param.Phone + req.Method = requests.POST + return +} +func CreateSendSmsResponse() (response *SendSmsResponse) { + response = &SendSmsResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +}