Compare commits
No commits in common. "0d1e7b8226f70a823b3712ac2810c482cb5174ed" and "fe038d91f3b817fdf4ba9496ebd6b6be991fdb39" have entirely different histories.
0d1e7b8226
...
fe038d91f3
@ -67,67 +67,3 @@ func CreateGetAnchorUserResp() *GetAnchorUserResp {
|
|||||||
BaseResponse: &responses.BaseResponse{},
|
BaseResponse: &responses.BaseResponse{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetRoleReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
GameId int64 `position:"Body" field:"game_id"`
|
|
||||||
UserId string `position:"Body" field:"user_id"`
|
|
||||||
UserName string `position:"Body" field:"user_name"`
|
|
||||||
RegTime int64 `position:"Body" field:"reg_time"`
|
|
||||||
RoleId string `position:"Body" field:"role_id"`
|
|
||||||
ServerId int64 `position:"Body" field:"server_id"`
|
|
||||||
UseCache int64 `position:"Body" field:"use_cache"`
|
|
||||||
NoVirtual int64 `position:"Body" field:"no_virtual"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RoleItem struct {
|
|
||||||
RoleId string `json:"roleId"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Server int64 `json:"server"`
|
|
||||||
ServerName string `json:"serverName"`
|
|
||||||
Level int64 `json:"level"`
|
|
||||||
VipLevel int64 `json:"vipLevel"`
|
|
||||||
CreateTime int64 `json:"createTime"`
|
|
||||||
RoleLevelUpdateTime int64 `json:"roleLevelUpdateTime"`
|
|
||||||
Power int64 `json:"power"`
|
|
||||||
Profession string `json:"profession"`
|
|
||||||
Gold int64 `json:"gold"`
|
|
||||||
CouponCount any `json:"couponCount"`
|
|
||||||
CouponActCount any `json:"couponActCount"`
|
|
||||||
ZhuanshengLv int64 `json:"zhuansheng_lv"`
|
|
||||||
ZhuanshengName string `json:"zhuanshengName"`
|
|
||||||
Points int64 `json:"points"`
|
|
||||||
MiniCustomsPass any `json:"miniCustomsPass"`
|
|
||||||
CardIds string `json:"cardIds"`
|
|
||||||
DayData any `json:"dayData"`
|
|
||||||
RoleExtData any `json:"roleExtData"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RoleInfo struct {
|
|
||||||
RoleItem
|
|
||||||
FromCache int64 `json:"from_cache"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetRoleResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
RoleInfo RoleInfo `json:"role_info"`
|
|
||||||
RoleListInfo []RoleItem `json:"role_list_info"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetRoleReq(param *GetRoleReq) *GetRoleReq {
|
|
||||||
if param == nil {
|
|
||||||
param = &GetRoleReq{}
|
|
||||||
}
|
|
||||||
param.RpcRequest = &requests.RpcRequest{}
|
|
||||||
param.InitWithApiInfo(HOST, VERSION, "/api/activity/getRole")
|
|
||||||
param.Method = requests.POST
|
|
||||||
return param
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetRoleResp() *GetRoleResp {
|
|
||||||
return &GetRoleResp{BaseResponse: &responses.BaseResponse{}}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -198,10 +198,3 @@ func (c *Client) MakeOrder(req *MakeOrderReq) (response *MakeOrderResp, err erro
|
|||||||
err = c.DoAction(req, response)
|
err = c.DoAction(req, response)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRole 获取游戏角色信息
|
|
||||||
func (c *Client) GetRole(req *GetRoleReq) (response *GetRoleResp, err error) {
|
|
||||||
response = CreateGetRoleResp()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
@ -386,16 +386,16 @@ func TestGetActivityVipUserNewBlacklist(t *testing.T) {
|
|||||||
|
|
||||||
func TestCreateMakeOrderReq(t *testing.T) {
|
func TestCreateMakeOrderReq(t *testing.T) {
|
||||||
req := CreateMakeOrderReq(MakeOrderParam{
|
req := CreateMakeOrderReq(MakeOrderParam{
|
||||||
Username: "rz35990497",
|
Username: "vd22543241",
|
||||||
Gid: 7874,
|
Gid: 123,
|
||||||
Sid: "2918",
|
Sid: "123",
|
||||||
RealSid: "",
|
RealSid: "123",
|
||||||
RoleId: "587102307",
|
RoleId: "123",
|
||||||
RoleName: "繁华之泰坦",
|
RoleName: "13",
|
||||||
Money: 630,
|
Money: 6,
|
||||||
ServerName: "碧水连天",
|
ServerName: "333",
|
||||||
ProductName: "630",
|
ProductName: "666",
|
||||||
DwId: 1008,
|
DwId: 666,
|
||||||
})
|
})
|
||||||
|
|
||||||
client, err := NewClient()
|
client, err := NewClient()
|
||||||
@ -408,26 +408,5 @@ func TestCreateMakeOrderReq(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println(resp.Data)
|
fmt.Println(resp.Msg)
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetRole(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//game_id=9175&server_id=0&user_id=247058227&user_name=yg90938415&no_virtual=1
|
|
||||||
req := CreateGetRoleReq(&GetRoleReq{
|
|
||||||
GameId: 7874,
|
|
||||||
UserId: "221016372",
|
|
||||||
UserName: "rz35990497",
|
|
||||||
NoVirtual: 1,
|
|
||||||
})
|
|
||||||
resp, err := client.GetRole(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Printf("%+v", resp.Data.RoleListInfo[0])
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
package game
|
package game
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
)
|
)
|
||||||
@ -64,16 +62,16 @@ func CreateIsBlockOutIosResp() *IsBlockOutIosResp {
|
|||||||
// MakeOrderReq 预下单请求
|
// MakeOrderReq 预下单请求
|
||||||
type MakeOrderReq struct {
|
type MakeOrderReq struct {
|
||||||
*requests.RpcRequest
|
*requests.RpcRequest
|
||||||
Username string `position:"Body" field:"username"`
|
Username string `position:"Body" field:"username"`
|
||||||
Gid int64 `position:"Body" field:"gid"`
|
Gid int64 `position:"Body" field:"gid"`
|
||||||
Sid string `position:"Body" field:"sid"`
|
Sid string `position:"Body" field:"sid"`
|
||||||
RealSid string `position:"Body" field:"real_sid"`
|
RealSid string `position:"Body" field:"real_sid"`
|
||||||
RoleId string `position:"Body" field:"role_id"`
|
RoleId string `position:"Body" field:"role_id"`
|
||||||
RoleName string `position:"Body" field:"role_name"`
|
RoleName string `position:"Body" field:"role_name"`
|
||||||
Money string `position:"Body" field:"money"`
|
Money float64 `position:"Body" field:"money"`
|
||||||
ServerName string `position:"Body" field:"server_name"`
|
ServerName string `position:"Body" field:"server_name"`
|
||||||
ProductName string `position:"Body" field:"product_name"`
|
ProductName string `position:"Body" field:"product_name"`
|
||||||
DwId int64 `position:"Body" field:"dw_id"`
|
DwId int64 `position:"Body" field:"dw_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MakeOrderRespData struct {
|
type MakeOrderRespData struct {
|
||||||
@ -109,7 +107,7 @@ func CreateMakeOrderReq(param MakeOrderParam) *MakeOrderReq {
|
|||||||
RealSid: param.RealSid,
|
RealSid: param.RealSid,
|
||||||
RoleId: param.RoleId,
|
RoleId: param.RoleId,
|
||||||
RoleName: param.RoleName,
|
RoleName: param.RoleName,
|
||||||
Money: fmt.Sprintf("%v", param.Money),
|
Money: param.Money,
|
||||||
ServerName: param.ServerName,
|
ServerName: param.ServerName,
|
||||||
ProductName: param.ProductName,
|
ProductName: param.ProductName,
|
||||||
DwId: param.DwId,
|
DwId: param.DwId,
|
||||||
|
|||||||
@ -95,10 +95,3 @@ func (c *Client) GetUserRegInfo(req *GetUserRegInfoRequest) (response *GetUserRe
|
|||||||
err = c.DoAction(req, response)
|
err = c.DoAction(req, response)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserId 通过用户名查询 uid
|
|
||||||
func (c *Client) GetUserId(req *GetUserIdRequest) (response *GetUserIdResponse, err error) {
|
|
||||||
response = CreateGetUserIdResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
@ -40,29 +40,6 @@ func TestGetUserRoleList(t *testing.T) {
|
|||||||
t.Logf("resp data:%+v", resp.Data)
|
t.Logf("resp data:%+v", resp.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetUserRoleList2(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
// 不限定角色
|
|
||||||
//req := CreateGetUserRoleListRequest(221016372, 7874, 0, "")
|
|
||||||
// 限定角色
|
|
||||||
req := CreateGetUserRoleListRequest2(GetUserRoleListParam{
|
|
||||||
Uid: 0,
|
|
||||||
Username: "rz35990497",
|
|
||||||
GameId: 7874,
|
|
||||||
RoleId: 0,
|
|
||||||
RoleServer: "",
|
|
||||||
})
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestEditCard(t *testing.T) {
|
func TestEditCard(t *testing.T) {
|
||||||
client, err := NewClient()
|
client, err := NewClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -190,25 +167,3 @@ func TestGetUserRegInfo(t *testing.T) {
|
|||||||
fmt.Printf("%#+v\n", resp)
|
fmt.Printf("%#+v\n", resp)
|
||||||
fmt.Printf("%#+v\n", resp.Data)
|
fmt.Printf("%#+v\n", resp.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 测试通过用户名查询 uid
|
|
||||||
func TestGetUserId(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req := CreateGetUserIdRequest("rz35990497")
|
|
||||||
resp, err := client.GetUserId(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data, err := resp.GetData()
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("解析返回数据失败: %v, raw: %s", err, resp.GetHttpContentString())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Printf("raw: %s\n", resp.GetHttpContentString())
|
|
||||||
fmt.Printf("data: %+v\n", data)
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,46 +0,0 @@
|
|||||||
package passport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetUserIdRequest 通过用户名查询 uid
|
|
||||||
type GetUserIdRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUserIdResponse 返回 {"uid": "user_name", ...} 格式的 map
|
|
||||||
type GetUserIdResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetData 解析返回的 map,key 为 uid,value 为 user_name
|
|
||||||
func (r *GetUserIdResponse) GetData() (map[string]string, error) {
|
|
||||||
result := make(map[string]string)
|
|
||||||
err := json.Unmarshal(r.GetHttpContentBytes(), &result)
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetUserIdRequest 构造请求,user_name 支持逗号分隔多个
|
|
||||||
func CreateGetUserIdRequest(userName string) *GetUserIdRequest {
|
|
||||||
req := &GetUserIdRequest{RpcRequest: &requests.RpcRequest{}}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/get_userid.php")
|
|
||||||
if !strings.Contains(userName, ",") {
|
|
||||||
userName = fmt.Sprintf("%v,%v", userName, userName)
|
|
||||||
}
|
|
||||||
req.QueryParams = map[string]string{
|
|
||||||
"user_name": userName,
|
|
||||||
"type": "1",
|
|
||||||
}
|
|
||||||
req.Method = requests.GET
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetUserIdResponse() *GetUserIdResponse {
|
|
||||||
return &GetUserIdResponse{BaseResponse: &responses.BaseResponse{}}
|
|
||||||
}
|
|
||||||
@ -4,10 +4,9 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetUserListRequest struct {
|
type GetUserListRequest struct {
|
||||||
@ -101,14 +100,6 @@ type UserRoleInfo struct {
|
|||||||
UpdateTime string `json:"update_time"` // 更新时间戳
|
UpdateTime string `json:"update_time"` // 更新时间戳
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUserRoleListParam struct {
|
|
||||||
Uid int
|
|
||||||
Username string
|
|
||||||
GameId int
|
|
||||||
RoleId int
|
|
||||||
RoleServer string
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetSign 封装一个方法,获取当天时间戳和api签名
|
// GetSign 封装一个方法,获取当天时间戳和api签名
|
||||||
func GetSign() (ts int64, sign string) {
|
func GetSign() (ts int64, sign string) {
|
||||||
ts = time.Now().Unix()
|
ts = time.Now().Unix()
|
||||||
@ -119,31 +110,6 @@ func GetSign() (ts int64, sign string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateGetUserRoleListRequest2 获取玩家角色列表
|
|
||||||
func CreateGetUserRoleListRequest2(param GetUserRoleListParam) (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", param.Uid),
|
|
||||||
"game_id": fmt.Sprintf("%d", param.GameId),
|
|
||||||
"role_id": fmt.Sprintf("%d", param.RoleId),
|
|
||||||
"role_server": param.RoleServer,
|
|
||||||
"username": param.Username,
|
|
||||||
"time": fmt.Sprintf("%v", ts),
|
|
||||||
"sign": sign,
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetUserRoleListRequest 获取玩家角色列表
|
// CreateGetUserRoleListRequest 获取玩家角色列表
|
||||||
func CreateGetUserRoleListRequest(uid int, gameId int, roleId int, roleServer string) (req *GetUserRoleListRequest) {
|
func CreateGetUserRoleListRequest(uid int, gameId int, roleId int, roleServer string) (req *GetUserRoleListRequest) {
|
||||||
ts, sign := GetSign()
|
ts, sign := GetSign()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user