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 +}