Compare commits
No commits in common. "master" and "v1.1.55" have entirely different histories.
@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "2025-05-28"
|
VERSION = "2025-04-27"
|
||||||
)
|
)
|
||||||
|
|
||||||
var HOST = requests.Host{
|
var HOST = requests.Host{
|
||||||
@ -54,24 +54,3 @@ func (c *Client) GetProtocolByGameId(req *GetProtocolByGameIdRep) (resp *GetProt
|
|||||||
err = c.DoAction(req, resp)
|
err = c.DoAction(req, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGameSimpleList 获取子游戏简单列表
|
|
||||||
func (c *Client) GetGameSimpleList(req *GetGameSimpleListReq) (resp *GetGameSimpleListResp, err error) {
|
|
||||||
resp = CreateGetGameSimpleListResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGameServerV2 获取游戏服务器列表v2
|
|
||||||
func (c *Client) GetGameServerV2(req *GetServerV2Request) (resp *GetServerV2Response, err error) {
|
|
||||||
resp = CreateGetServerV2Response()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGameCompany 获取单个根游戏信息
|
|
||||||
func (c *Client) GetGameCompany(req *GetGameCompanyReq) (resp *GetGameCompanyResp, err error) {
|
|
||||||
resp = CreateGetGameCompanyResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
@ -77,46 +77,3 @@ func TestGetProtocolByGameId(t *testing.T) {
|
|||||||
}
|
}
|
||||||
fmt.Println(info)
|
fmt.Println(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetGameSimpleList(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
req := CreateGetGameSimpleListReq("8071,8062", "")
|
|
||||||
info, err := client.GetGameSimpleList(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println(info)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetGameServerV2(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateGetServerV2Request("n2", "", "")
|
|
||||||
info, err := client.GetGameServerV2(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println(info)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetGameCompany(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
req := CreateGetGameCompanyReq("ascq")
|
|
||||||
gameCompany, err := client.GetGameCompany(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println(gameCompany)
|
|
||||||
fmt.Println(gameCompany.Data.System)
|
|
||||||
}
|
|
||||||
|
@ -162,96 +162,3 @@ func CreateGetGameInfoByIdResp() *GetGameInfoResp {
|
|||||||
BaseResponse: &responses.BaseResponse{},
|
BaseResponse: &responses.BaseResponse{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGameSimpleListReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGameSimpleListResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data map[string]GameSimple `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GameSimple struct {
|
|
||||||
ID int `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
GameSign string `json:"game_sign"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetGameSimpleListReq
|
|
||||||
// gids 子游戏字符串,多个子游戏id用英文逗号分割
|
|
||||||
// game_signs 根游戏标识字符串,多个标识用英文逗号分割
|
|
||||||
func CreateGetGameSimpleListReq(gameIds string, gameSigns string) *GetGameSimpleListReq {
|
|
||||||
req := &GetGameSimpleListReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getSimpleList")
|
|
||||||
tmpParams := make(map[string]string)
|
|
||||||
if gameIds != "" {
|
|
||||||
tmpParams["gids"] = gameIds
|
|
||||||
}
|
|
||||||
if gameSigns != "" {
|
|
||||||
tmpParams["game_signs"] = gameSigns
|
|
||||||
}
|
|
||||||
req.FormParams = tmpParams
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetGameSimpleListResp() *GetGameSimpleListResp {
|
|
||||||
return &GetGameSimpleListResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GameCompany
|
|
||||||
// 获取根游戏记录
|
|
||||||
type GameCompany struct {
|
|
||||||
Id int `json:"id"`
|
|
||||||
GameSign string `json:"game_sign"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
GameName string `json:"game_name"`
|
|
||||||
ContractName string `json:"contract_name"`
|
|
||||||
PayKey string `json:"pay_key"`
|
|
||||||
LoginKey string `json:"login_key"`
|
|
||||||
LoginUrlH5 string `json:"login_url_h5"`
|
|
||||||
LoginUrlIos string `json:"login_url_ios"`
|
|
||||||
LoginUrlAndroid string `json:"login_url_android"`
|
|
||||||
PayUrl string `json:"pay_url"`
|
|
||||||
Ext string `json:"ext"`
|
|
||||||
Status int `json:"status"`
|
|
||||||
Company string `json:"company"`
|
|
||||||
System string `json:"system"`
|
|
||||||
Sync int `json:"sync"`
|
|
||||||
Type int `json:"type"`
|
|
||||||
GameProductId int `json:"game_product_id"`
|
|
||||||
}
|
|
||||||
type GetGameCompanyReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
type GetGameCompanyResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data GameCompany `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetGameCompanyReq(gameSign string) *GetGameCompanyReq {
|
|
||||||
req := &GetGameCompanyReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getGameCompanyBySign")
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"gameSign": gameSign,
|
|
||||||
}
|
|
||||||
req.Method = requests.POST
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
func CreateGetGameCompanyResp() *GetGameCompanyResp {
|
|
||||||
return &GetGameCompanyResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,107 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/md5"
|
|
||||||
"encoding/hex"
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
gameServerKey = "gaoreapi"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetGameServerSign 子游戏区服信息,特有验签
|
|
||||||
func GetGameServerSign(gameId int) (ts int64, sign string) {
|
|
||||||
ts = time.Now().Unix()
|
|
||||||
hash := md5.New()
|
|
||||||
hash.Write([]byte(fmt.Sprintf("%v%v%v", gameId, ts, gameServerKey)))
|
|
||||||
hashBytes := hash.Sum(nil)
|
|
||||||
sign = hex.EncodeToString(hashBytes)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetServerIdRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetServerIdResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data map[string]string `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetServerIdRequest
|
|
||||||
// Deprecated 方法已废弃,不要用
|
|
||||||
func CreateGetServerIdRequest(gameId int) (req *GetServerIdRequest) {
|
|
||||||
req = &GetServerIdRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getServerId")
|
|
||||||
// 获取时间戳、签名
|
|
||||||
ts, sign := GetGameServerSign(gameId)
|
|
||||||
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"appid": fmt.Sprintf("%v", gameId),
|
|
||||||
"time": fmt.Sprintf("%v", ts),
|
|
||||||
"sign": sign,
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetServerIdResponse
|
|
||||||
// Deprecated 方法已废弃,不要用
|
|
||||||
func CreateGetServerIdResponse() (response *GetServerIdResponse) {
|
|
||||||
response = &GetServerIdResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------游戏区服v2列表查询----------
|
|
||||||
|
|
||||||
// GetServerV2Request 请求结构体
|
|
||||||
type GetServerV2Request struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetServerV2Response struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []GameServerV2 `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GameServerV2 struct {
|
|
||||||
ServerId int `json:"server_id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
GameSign string `json:"game_sign"`
|
|
||||||
ServerSign int `json:"server_sign"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetServerV2Request(gameSign string, serverSigns string, types string) (req *GetServerV2Request) {
|
|
||||||
req = &GetServerV2Request{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getServerV2")
|
|
||||||
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"game_sign": gameSign,
|
|
||||||
"server_signs": serverSigns,
|
|
||||||
"types": types,
|
|
||||||
}
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetServerV2Response() (response *GetServerV2Response) {
|
|
||||||
response = &GetServerV2Response{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -16,8 +16,7 @@ type PutOssResponse struct {
|
|||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
Data struct {
|
Data struct {
|
||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
SavePath string `json:"save_path"`
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
package passport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2025-05-28"
|
|
||||||
// 对称加密密钥
|
|
||||||
appKey = "#gr*%com#"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
|
||||||
Default: "passport.gaore.com",
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.Init()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUserList
|
|
||||||
// 获取用户列表
|
|
||||||
func (c *Client) GetUserList(req *GetUserListRequest) (response *GetUserListResponse, err error) {
|
|
||||||
response = CreateGetUserListResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUserRoleList
|
|
||||||
// 获取用户角色列表
|
|
||||||
func (c *Client) GetUserRoleList(req *GetUserRoleListRequest) (response *GetUserRoleListResponse, err error) {
|
|
||||||
response = CreateGetUserRoleListResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package passport
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
// 单元测试
|
|
||||||
|
|
||||||
func TestGetUserList(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
req := CreateGetUserListRequest("ws45265737")
|
|
||||||
resp, err := client.GetUserList(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
t.Logf("resp code:%+v", resp.Code)
|
|
||||||
t.Logf("resp data:%+v", resp.Data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetUserRoleList(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
req := CreateGetUserRoleListRequest(63610626, 2850)
|
|
||||||
resp, err := client.GetUserRoleList(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
t.Logf("resp code:%+v", resp.Code)
|
|
||||||
t.Logf("resp data:%+v", resp.Data)
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
package passport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/md5"
|
|
||||||
"encoding/hex"
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetUserListRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserListResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []UserInfo `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserInfo struct {
|
|
||||||
UserName string `json:"user_name"` // 用户名
|
|
||||||
Uid string `json:"uid"` // uid
|
|
||||||
Telephone string `json:"telephone"` // 手机号
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetUserListRequest 获取玩家用户列表
|
|
||||||
func CreateGetUserListRequest(userName string) (req *GetUserListRequest) {
|
|
||||||
ts, sign := GetSign()
|
|
||||||
|
|
||||||
req = &GetUserListRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/remote_login.php")
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"act": "info",
|
|
||||||
"do": "get_user_list",
|
|
||||||
"user_names": userName,
|
|
||||||
"time": fmt.Sprintf("%v", ts),
|
|
||||||
"sign": sign,
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetUserListResponse() (response *GetUserListResponse) {
|
|
||||||
response = &GetUserListResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserRoleListRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserRoleListResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []UserRoleInfo `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserRoleInfo struct {
|
|
||||||
Uid string `json:"uid"` // uid
|
|
||||||
GameId string `json:"game_id"` // 子游戏id
|
|
||||||
RoleId string `json:"role_id"` // 角色id
|
|
||||||
RoleName string `json:"role_name"` // 角色名
|
|
||||||
RoleServer string `json:"role_server"` // 角色服务器名
|
|
||||||
AddTime string `json:"add_time"` // 创建时间戳
|
|
||||||
UpdateTime string `json:"update_time"` // 更新时间戳
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetSign 封装一个方法,获取当天时间戳和api签名
|
|
||||||
func GetSign() (ts int64, sign string) {
|
|
||||||
ts = time.Now().Unix()
|
|
||||||
hash := md5.New()
|
|
||||||
hash.Write([]byte(fmt.Sprintf("%v%v", ts, appKey)))
|
|
||||||
hashBytes := hash.Sum(nil)
|
|
||||||
sign = hex.EncodeToString(hashBytes)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetUserRoleListRequest 获取玩家角色列表
|
|
||||||
func CreateGetUserRoleListRequest(uid int, gameId int) (req *GetUserRoleListRequest) {
|
|
||||||
ts, sign := GetSign()
|
|
||||||
|
|
||||||
req = &GetUserRoleListRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/remote_login.php")
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"act": "info",
|
|
||||||
"do": "user_role",
|
|
||||||
"method": "get",
|
|
||||||
"uid": fmt.Sprintf("%d", uid),
|
|
||||||
"game_id": fmt.Sprintf("%d", gameId),
|
|
||||||
"time": fmt.Sprintf("%v", ts),
|
|
||||||
"sign": sign,
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetUserRoleListResponse() (response *GetUserRoleListResponse) {
|
|
||||||
response = &GetUserRoleListResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -54,11 +54,3 @@ func (c *Client) MerchantConfigDebug(req *merchantConfigDebugRequest) (response
|
|||||||
err = c.DoAction(req, response)
|
err = c.DoAction(req, response)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrderState
|
|
||||||
// 获取订单状态
|
|
||||||
func (c *Client) GetOrderState(req *GetOrderStateRequest) (response *GetOrderStateResponse, err error) {
|
|
||||||
response = CreateGetOrderStateResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
@ -24,18 +24,3 @@ func TestClient_GetUserInfo(t *testing.T) {
|
|||||||
//fmt.Println(resp.GetHttpContentString())
|
//fmt.Println(resp.GetHttpContentString())
|
||||||
//fmt.Println(resp.GetHttpHeaders())
|
//fmt.Println(resp.GetHttpHeaders())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetOrderState(t *testing.T) {
|
|
||||||
getOrderStateRequest := CreateGetOrderStateRequest("202112060000193551730")
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
getOrderStateResponse, err := client.GetOrderState(getOrderStateRequest)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(getOrderStateResponse.GetHttpContentString())
|
|
||||||
}
|
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
package pay
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetOrderStateRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
OrderId string `position:"Body" field:"orderid" default:"" `
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetOrderStateResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
Orderid string `json:"orderid"` // 订单号
|
|
||||||
Succ string `json:"succ"` // 是否成功
|
|
||||||
Money string `json:"money"` // 支付金额
|
|
||||||
UserName string `json:"user_name"` // 用户名
|
|
||||||
BNum string `json:"b_num"`
|
|
||||||
GameId string `json:"game_id"` // 游戏id
|
|
||||||
PayDate string `json:"pay_date"` // 付费日期
|
|
||||||
SyncDate string `json:"sync_date"` // 回调时间
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetOrderStateRequest(orderId string) (req *GetOrderStateRequest) {
|
|
||||||
req = &GetOrderStateRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
OrderId: orderId,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/user/getOrderState")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetOrderStateResponse() (response *GetOrderStateResponse) {
|
|
||||||
response = &GetOrderStateResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -83,6 +83,17 @@ func (c *Client) SendSms(req *SendSmsRequest) (resp *SendSmsResponse, err error)
|
|||||||
err = errors.New("type is empty")
|
err = errors.New("type is empty")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.Expired == 0 {
|
||||||
|
err = errors.New("expired is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Code == 0 {
|
||||||
|
err = errors.New("code is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
resp = CreateSendSmsResponse()
|
resp = CreateSendSmsResponse()
|
||||||
err = c.DoAction(req, resp)
|
err = c.DoAction(req, resp)
|
||||||
return
|
return
|
||||||
|
@ -94,39 +94,12 @@ func TestClient_SendFeiShuWebHook(t *testing.T) {
|
|||||||
fmt.Println(resp3)
|
fmt.Println(resp3)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_SendSmsCode(t *testing.T) {
|
func TestClient_SendSms(t *testing.T) {
|
||||||
req := CreateSendSmsRequest(SendSmsParam{
|
req := CreateSendSmsRequest(SendSmsParam{
|
||||||
Mobile: "18320021439",
|
Mobile: "18320021439",
|
||||||
Type: SmsTypeBindPhone,
|
Type: SmsTypeBindPhone,
|
||||||
Replaces: []Item{{
|
Code: 123456,
|
||||||
Key: ReplaceKeyCode,
|
Expired: 5,
|
||||||
Value: "6379",
|
|
||||||
}, {
|
|
||||||
Key: ReplaceKeySecond,
|
|
||||||
Value: "120",
|
|
||||||
}},
|
|
||||||
})
|
|
||||||
|
|
||||||
req.Domain = requests.Host{
|
|
||||||
Default: "127.0.0.1:8804",
|
|
||||||
}
|
|
||||||
|
|
||||||
sms, err := client.SendSms(req)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(sms)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestClient_SendSmsUrl(t *testing.T) {
|
|
||||||
req := CreateSendSmsRequest(SendSmsParam{
|
|
||||||
Mobile: "18320021439",
|
|
||||||
Type: TemplateTypeOrderComplete,
|
|
||||||
Replaces: []Item{{
|
|
||||||
Key: ReplaceKeyUrl,
|
|
||||||
Value: "http://www.baidu.com",
|
|
||||||
}},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
req.Domain = requests.Host{
|
req.Domain = requests.Host{
|
||||||
|
@ -32,7 +32,7 @@ func CreateSendEmailRequest(param SendEmailParam) (req *SendEmailRequest) {
|
|||||||
Body: param.Body,
|
Body: param.Body,
|
||||||
FromName: param.FromName,
|
FromName: param.FromName,
|
||||||
}
|
}
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/email/send")
|
req.InitWithApiInfo(HOST, VERSION, "/email/send")
|
||||||
req.Method = requests.POST
|
req.Method = requests.POST
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ func CreateSendFeiShuWebHookRequest(param SendFeiShuWebHookParam) (req *SendFeiS
|
|||||||
Title: param.Title,
|
Title: param.Title,
|
||||||
TitleColor: param.TitleColor,
|
TitleColor: param.TitleColor,
|
||||||
}
|
}
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/feishu/webhook_send")
|
req.InitWithApiInfo(HOST, VERSION, "/feishu/webhook_send")
|
||||||
req.Method = requests.POST
|
req.Method = requests.POST
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -5,24 +5,12 @@ import (
|
|||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ReplaceKey = string
|
|
||||||
|
|
||||||
const (
|
|
||||||
ReplaceKeyCode ReplaceKey = "${code}" // 验证码
|
|
||||||
ReplaceKeySecond ReplaceKey = "${second}" // 秒数
|
|
||||||
ReplaceKeyUrl ReplaceKey = "${url}" // 链接
|
|
||||||
)
|
|
||||||
|
|
||||||
type Item struct {
|
|
||||||
Key ReplaceKey // 要替换的key
|
|
||||||
Value string // 要替换的值
|
|
||||||
}
|
|
||||||
|
|
||||||
type SendSmsRequest struct {
|
type SendSmsRequest struct {
|
||||||
*requests.JsonRequest
|
*requests.JsonRequest
|
||||||
Mobile string `position:"Json" field:"mobile"`
|
Mobile string `position:"Json" field:"mobile"`
|
||||||
Type string `position:"Json" field:"type"`
|
Type string `position:"Json" field:"type"`
|
||||||
Replaces []Item `position:"Json" field:"replaces"`
|
Expired int64 `position:"Json" field:"expired"`
|
||||||
|
Code int64 `position:"Json" field:"code"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SendSmsResponse struct {
|
type SendSmsResponse struct {
|
||||||
@ -32,16 +20,15 @@ type SendSmsResponse struct {
|
|||||||
type SmsType = string
|
type SmsType = string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SmsTypeRegister SmsType = "reg" // 注册
|
SmsTypeRegister SmsType = "reg" // 注册
|
||||||
SmsTypeBindPhone SmsType = "bind_phone" // 绑定手机号
|
SmsTypeBindPhone SmsType = "bind_phone" // 绑定手机号
|
||||||
TemplateTypeOrderComplete SmsType = "kf_order_complete" // 客服工单完成
|
|
||||||
TemplateTypeKFOrderAdditional SmsType = "kf_order_additional" // 客服工单完成
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SendSmsParam struct {
|
type SendSmsParam struct {
|
||||||
Mobile string // 手机号
|
Mobile string // 手机号
|
||||||
Type SmsType // 验证码类型
|
Type SmsType // 验证码类型
|
||||||
Replaces []Item
|
Expired int64 // 过期时间,秒数
|
||||||
|
Code int64 // 验证码
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
||||||
@ -49,9 +36,10 @@ func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
|||||||
JsonRequest: &requests.JsonRequest{},
|
JsonRequest: &requests.JsonRequest{},
|
||||||
Mobile: param.Mobile,
|
Mobile: param.Mobile,
|
||||||
Type: param.Type,
|
Type: param.Type,
|
||||||
Replaces: param.Replaces,
|
Expired: param.Expired,
|
||||||
|
Code: param.Code,
|
||||||
}
|
}
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/sms/send")
|
req.InitWithApiInfo(HOST, VERSION, "/sms/agg/send")
|
||||||
req.Method = requests.POST
|
req.Method = requests.POST
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user