Merge branch 'develop/lgj'
This commit is contained in:
commit
73ca794581
68
services/cs/client.go
Normal file
68
services/cs/client.go
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package cs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "2025-06-10"
|
||||||
|
)
|
||||||
|
|
||||||
|
var HOST = requests.Host{
|
||||||
|
Default: "cs",
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
sdk.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient() (client *Client, err error) {
|
||||||
|
client = new(Client)
|
||||||
|
err = client.Init()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (client *Client) GetFaq(req *GetFaqRequest) (resp *GetFaqResponse, err error) {
|
||||||
|
resp = CreateGetFaqResponse()
|
||||||
|
err = client.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (client *Client) GetUserInfo(req *GetUserInfoRequest) (resp *GetUserInfoResponse, err error) {
|
||||||
|
resp = CreateGetUserInfoResponse()
|
||||||
|
err = client.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (client *Client) GetCsUserRoleList(req *GetUserRoleListRequest) (resp *GetUserRoleListResponse, err error) {
|
||||||
|
resp = CreateGetUserRoleListResponse()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (client *Client) Upload(req *UploadRequest) (resp *UploadResponse, err error) {
|
||||||
|
// check file stream
|
||||||
|
if req.FileStream == nil {
|
||||||
|
err = errors.New("stream is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 必须设置content
|
||||||
|
req.SetContent(req.FileStream)
|
||||||
|
resp = CreateUploadResponse()
|
||||||
|
err = client.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
129
services/cs/client_test.go
Normal file
129
services/cs/client_test.go
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
package cs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客服工单服务,单元测试
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 获取faq树状数据
|
||||||
|
func TestGetFaq(t *testing.T) {
|
||||||
|
client, newErr := NewClient()
|
||||||
|
if newErr != nil {
|
||||||
|
panic(newErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
req := CreateGetFaqRequest()
|
||||||
|
faq, err := client.GetFaq(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf(fmt.Sprintf("%#+v", faq))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取玩家基本信息
|
||||||
|
func TestGetUserInfo(t *testing.T) {
|
||||||
|
client, newErr := NewClient()
|
||||||
|
if newErr != nil {
|
||||||
|
panic(newErr)
|
||||||
|
}
|
||||||
|
req := CreateGetUserInfoRequest("ws45265737")
|
||||||
|
info, err := client.GetUserInfo(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取玩家区服列表
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 工单图片上传
|
||||||
|
func TestUpload(t *testing.T) {
|
||||||
|
client, newErr := NewClient()
|
||||||
|
if newErr != nil {
|
||||||
|
panic(newErr)
|
||||||
|
}
|
||||||
|
// 读取文件流
|
||||||
|
file, err := os.ReadFile("test.png")
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req := CreateUploadRequest()
|
||||||
|
req.FileStream = file
|
||||||
|
res, err := client.Upload(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if res.Code != 0 {
|
||||||
|
t.Error("工单图片上传失败")
|
||||||
|
}
|
||||||
|
fmt.Printf(fmt.Sprintf("%v", res))
|
||||||
|
}
|
48
services/cs/faq.go
Normal file
48
services/cs/faq.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package cs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Faq 树状结构
|
||||||
|
type Faq struct {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
ParentId int64 `json:"parent_id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Answer string `json:"answer"`
|
||||||
|
Type int64 `json:"type"`
|
||||||
|
WorkOrderTemplateId int64 `json:"work_order_template_id"`
|
||||||
|
CreatedAt string `json:"created_at"`
|
||||||
|
UpdatedAt string `json:"updated_at"`
|
||||||
|
ProcessFlow string `json:"process_flow"`
|
||||||
|
Children []*Faq `json:"children"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetFaqRequest struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetFaqResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data Faq `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetFaqRequest() (req *GetFaqRequest) {
|
||||||
|
req = &GetFaqRequest{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/v1/faq/list")
|
||||||
|
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetFaqResponse() (response *GetFaqResponse) {
|
||||||
|
response = &GetFaqResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
43
services/cs/order.go
Normal file
43
services/cs/order.go
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package cs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客服工单,相关方法
|
||||||
|
*/
|
||||||
|
|
||||||
|
type UploadRequest struct {
|
||||||
|
*requests.StreamRequest
|
||||||
|
FileStream []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type UploadResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data struct {
|
||||||
|
FileName string `json:"file_name"`
|
||||||
|
FileUrl string `json:"file_url"`
|
||||||
|
FilePath string `json:"file_path"`
|
||||||
|
}
|
||||||
|
TraceId string `json:"trace_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateUploadRequest() (req *UploadRequest) {
|
||||||
|
req = &UploadRequest{
|
||||||
|
StreamRequest: &requests.StreamRequest{},
|
||||||
|
}
|
||||||
|
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/upload_image")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateUploadResponse() (resp *UploadResponse) {
|
||||||
|
return &UploadResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
BIN
services/cs/test.png
Normal file
BIN
services/cs/test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
157
services/cs/user.go
Normal file
157
services/cs/user.go
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
package cs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取玩家(用户)相关信息
|
||||||
|
*/
|
||||||
|
|
||||||
|
// UserInfo 用户信息
|
||||||
|
type UserInfo struct {
|
||||||
|
UserName string `json:"user_name"`
|
||||||
|
Uid int64 `json:"uid"`
|
||||||
|
Telephone string `json:"telephone"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUserInfoRequest struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUserInfoResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data UserInfo `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetUserInfoRequest(userName string) (req *GetUserInfoRequest) {
|
||||||
|
req = &GetUserInfoRequest{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/v1/user/info")
|
||||||
|
|
||||||
|
req.FormParams = map[string]string{
|
||||||
|
"user_name": userName,
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetUserInfoResponse() (response *GetUserInfoResponse) {
|
||||||
|
response = &GetUserInfoResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
Phone string `position:"Json" field:"phone"`
|
||||||
|
}
|
||||||
|
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{},
|
||||||
|
Phone: param.Phone,
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/v1/user/send_sms")
|
||||||
|
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func CreateSendSmsResponse() (response *SendSmsResponse) {
|
||||||
|
response = &SendSmsResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user