Compare commits
No commits in common. "22551147ebf576ce5d85f92d6d19d222a8c6f251" and "13bf104d52843220c0685270dffe725cd50beea8" have entirely different histories.
22551147eb
...
13bf104d52
@ -18,40 +18,38 @@ func signRpcRequest(request requests.AcsRequest, signer Signer) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if signer != nil {
|
if _, isContainsSign := request.GetQueryParams()["sign"]; isContainsSign {
|
||||||
if _, isContainsSign := request.GetQueryParams()["sign"]; isContainsSign {
|
delete(request.GetQueryParams(), "sign")
|
||||||
delete(request.GetQueryParams(), "sign")
|
|
||||||
}
|
|
||||||
stringToSign := buildRpcStringToSign(request)
|
|
||||||
request.SetStringToSign(stringToSign)
|
|
||||||
signature := signer.Sign(stringToSign, "&")
|
|
||||||
request.GetQueryParams()["sign"] = signature
|
|
||||||
debug("GrSdk sign: %s", signature)
|
|
||||||
debug("GrSdk sign string: %s", stringToSign)
|
|
||||||
debug("GrSdk sign: \r\n")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stringToSign := buildRpcStringToSign(request)
|
||||||
|
request.SetStringToSign(stringToSign)
|
||||||
|
signature := signer.Sign(stringToSign, "&")
|
||||||
|
request.GetQueryParams()["sign"] = signature
|
||||||
|
debug("GrSdk sign: %s", signature)
|
||||||
|
debug("GrSdk sign string: %s", stringToSign)
|
||||||
|
debug("GrSdk sign: \r\n")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func completeRpcSignParams(request requests.AcsRequest, signer Signer) (err error) {
|
func completeRpcSignParams(request requests.AcsRequest, signer Signer) (err error) {
|
||||||
if signer != nil {
|
|
||||||
var accessKeyFrom string
|
|
||||||
if accessKeyFrom, err = signer.GetAccessKeyFrom(); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
queryParams := request.GetQueryParams()
|
var accessKeyFrom string
|
||||||
queryParams["access_time"] = fmt.Sprintf("%d", time.Now().Unix())
|
if accessKeyFrom, err = signer.GetAccessKeyFrom(); err != nil {
|
||||||
queryParams["access_key"], err = signer.GetAccessKeyId()
|
return
|
||||||
queryParams["access_from"] = accessKeyFrom
|
|
||||||
request.GetHeaders()["Gr-Sdk-From"] = accessKeyFrom
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
request.GetHeaders()["Content-type"] = requests.Form
|
|
||||||
|
|
||||||
|
queryParams := request.GetQueryParams()
|
||||||
|
queryParams["access_time"] = fmt.Sprintf("%d", time.Now().Unix())
|
||||||
|
queryParams["access_key"], err = signer.GetAccessKeyId()
|
||||||
|
queryParams["access_from"] = accessKeyFrom
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
request.GetHeaders()["Content-type"] = requests.Form
|
||||||
|
request.GetHeaders()["Gr-Sdk-From"] = accessKeyFrom
|
||||||
formString := utils.GetUrlFormedMap(request.GetFormParams())
|
formString := utils.GetUrlFormedMap(request.GetFormParams())
|
||||||
request.SetContent(bytes.NewBufferString(formString).Bytes())
|
request.SetContent(bytes.NewBufferString(formString).Bytes())
|
||||||
return
|
return
|
||||||
|
@ -46,27 +46,6 @@ type Client struct {
|
|||||||
httpProxy string
|
httpProxy string
|
||||||
httpsProxy string
|
httpsProxy string
|
||||||
noProxy string
|
noProxy string
|
||||||
|
|
||||||
header *requests.RefererHeader
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) SetRefererHeader(header *requests.RefererHeader) {
|
|
||||||
c.header = header
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GetRefererHeader() map[string]string {
|
|
||||||
var header *requests.RefererHeader
|
|
||||||
if c.header == nil {
|
|
||||||
header = &requests.RefererHeader{
|
|
||||||
TraceId: utils.MakeTraceId(),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
header = c.header
|
|
||||||
}
|
|
||||||
return map[string]string{
|
|
||||||
"Referer": header.Referer,
|
|
||||||
"Traceparent": header.TraceId,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) GetNoProxy() string {
|
func (client *Client) GetNoProxy() string {
|
||||||
@ -112,15 +91,11 @@ func (client *Client) Init() (err error) {
|
|||||||
|
|
||||||
func (client *Client) InitWithAccessKey(accessKeyId, accessKeySecret, accessKeyFrom string) (err error) {
|
func (client *Client) InitWithAccessKey(accessKeyId, accessKeySecret, accessKeyFrom string) (err error) {
|
||||||
config := client.InitWithConfig()
|
config := client.InitWithConfig()
|
||||||
var credential auth.Credential
|
credential := &credentials.BaseCredential{
|
||||||
if accessKeyId != "" {
|
AccessKeyId: accessKeyId,
|
||||||
credential = &credentials.BaseCredential{
|
AccessKeySecret: accessKeySecret,
|
||||||
AccessKeyId: accessKeyId,
|
AccessKeyFrom: accessKeyFrom,
|
||||||
AccessKeySecret: accessKeySecret,
|
|
||||||
AccessKeyFrom: accessKeyFrom,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return client.InitWithOptions(config, credential)
|
return client.InitWithOptions(config, credential)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,9 +133,8 @@ func (client *Client) InitWithOptions(config *Config, credential auth.Credential
|
|||||||
if config.Timeout > 0 {
|
if config.Timeout > 0 {
|
||||||
client.httpClient.Timeout = config.Timeout
|
client.httpClient.Timeout = config.Timeout
|
||||||
}
|
}
|
||||||
if credential != nil {
|
|
||||||
client.signer, err = auth.NewSignerWithCredential(credential, client.ProcessCommonRequestWithSigner)
|
client.signer, err = auth.NewSignerWithCredential(credential, client.ProcessCommonRequestWithSigner)
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +213,7 @@ func (client *Client) DoAction(request requests.AcsRequest, response responses.A
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) DoActionWithSigner(request requests.AcsRequest, response responses.AcsResponse, signer auth.Signer) (err error) {
|
func (client *Client) DoActionWithSigner(request requests.AcsRequest, response responses.AcsResponse, signer auth.Signer) (err error) {
|
||||||
request.AddHeaders(client.GetRefererHeader())
|
|
||||||
httpRequest, err := client.buildRequestWithSigner(request, signer)
|
httpRequest, err := client.buildRequestWithSigner(request, signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -56,11 +56,6 @@ type Host struct {
|
|||||||
Func func(string) string
|
Func func(string) string
|
||||||
}
|
}
|
||||||
|
|
||||||
type RefererHeader struct {
|
|
||||||
Referer string
|
|
||||||
TraceId string
|
|
||||||
}
|
|
||||||
|
|
||||||
var debug utils.Debug
|
var debug utils.Debug
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -100,7 +95,6 @@ type AcsRequest interface {
|
|||||||
GetBodyReader() io.Reader
|
GetBodyReader() io.Reader
|
||||||
|
|
||||||
AddHeaderParam(key, value string)
|
AddHeaderParam(key, value string)
|
||||||
AddHeaders(headers map[string]string)
|
|
||||||
addQueryParam(key, value string)
|
addQueryParam(key, value string)
|
||||||
addFormParam(key, value string)
|
addFormParam(key, value string)
|
||||||
addJsonParam(string, any)
|
addJsonParam(string, any)
|
||||||
@ -232,12 +226,6 @@ func (request *baseRequest) AddHeaderParam(key, val string) {
|
|||||||
request.Headers[key] = val
|
request.Headers[key] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *baseRequest) AddHeaders(headers map[string]string) {
|
|
||||||
for key, val := range headers {
|
|
||||||
request.Headers[key] = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *baseRequest) addQueryParam(key, val string) {
|
func (request *baseRequest) addQueryParam(key, val string) {
|
||||||
request.QueryParams[key] = val
|
request.QueryParams[key] = val
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, isCommonResponse := response.(*CommonResponse); isCommonResponse {
|
if _, isCommonResponse := response.(CommonResponse); isCommonResponse {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
package random
|
|
||||||
|
|
||||||
import (
|
|
||||||
"math/rand"
|
|
||||||
"time"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Mode int // 随机数模式
|
|
||||||
|
|
||||||
const (
|
|
||||||
Letter Mode = iota
|
|
||||||
Number
|
|
||||||
LetterNumber
|
|
||||||
LetterHex
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
||||||
numbers = "0123456789"
|
|
||||||
lettersHex = "0123456789abcdef"
|
|
||||||
letterIdBit = 6
|
|
||||||
letterIdxMask = 1<<letterIdBit - 1
|
|
||||||
letterIdxMax = 63 / letterIdBit
|
|
||||||
)
|
|
||||||
|
|
||||||
func StrRandom(n int64) string {
|
|
||||||
return Random(n, Letter)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NumRandom(n int64) string {
|
|
||||||
return Random(n, Number)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Random(n int64, mode ...Mode) string {
|
|
||||||
var baseStr string
|
|
||||||
mode = append(mode, LetterNumber)
|
|
||||||
switch mode[0] {
|
|
||||||
case LetterHex:
|
|
||||||
baseStr = lettersHex
|
|
||||||
case Letter:
|
|
||||||
baseStr = letters
|
|
||||||
case Number:
|
|
||||||
baseStr = numbers
|
|
||||||
case LetterNumber:
|
|
||||||
fallthrough
|
|
||||||
default:
|
|
||||||
baseStr = letters + numbers
|
|
||||||
}
|
|
||||||
return random(n, baseStr)
|
|
||||||
}
|
|
||||||
|
|
||||||
func random(n int64, baseStr string) string {
|
|
||||||
|
|
||||||
var src = rand.NewSource(time.Now().UnixNano())
|
|
||||||
b := make([]byte, n)
|
|
||||||
for i, cache, remain := n-1, src.Int63(), letterIdxMax; i >= 0; {
|
|
||||||
if remain == 0 {
|
|
||||||
cache, remain = src.Int63(), letterIdxMax
|
|
||||||
}
|
|
||||||
if idx := int(cache & letterIdxMask); idx < len(baseStr) {
|
|
||||||
b[i] = baseStr[idx]
|
|
||||||
i--
|
|
||||||
}
|
|
||||||
cache >>= letterIdBit
|
|
||||||
remain--
|
|
||||||
}
|
|
||||||
return *(*string)(unsafe.Pointer(&b))
|
|
||||||
}
|
|
@ -5,8 +5,8 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils/random"
|
|
||||||
"hash"
|
"hash"
|
||||||
|
rand2 "math/rand"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
@ -36,7 +36,11 @@ func NewUUID() UUID {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RandStringBytes(n int) string {
|
func RandStringBytes(n int) string {
|
||||||
return random.StrRandom(int64(n))
|
b := make([]byte, n)
|
||||||
|
for i := range b {
|
||||||
|
b[i] = letterBytes[rand2.Intn(len(letterBytes))]
|
||||||
|
}
|
||||||
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFromHash(h hash.Hash, ns UUID, name string) UUID {
|
func newFromHash(h hash.Hash, ns UUID, name string) UUID {
|
||||||
@ -105,12 +109,3 @@ func InitStructWithDefaultTag(bean interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Md5(data string) string {
|
|
||||||
s := md5.Sum([]byte(data))
|
|
||||||
return hex.EncodeToString(s[:])
|
|
||||||
}
|
|
||||||
|
|
||||||
func MakeTraceId() string {
|
|
||||||
return fmt.Sprintf("00-%s-%s-01", random.Random(32, random.LetterHex), random.Random(16, random.LetterHex))
|
|
||||||
}
|
|
||||||
|
@ -23,7 +23,3 @@ func TestInitStructWithDefaultTag(t *testing.T) {
|
|||||||
InitStructWithDefaultTag(testcase)
|
InitStructWithDefaultTag(testcase)
|
||||||
fmt.Printf("%+v", testcase)
|
fmt.Printf("%+v", testcase)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMd5(t *testing.T) {
|
|
||||||
t.Log(Md5("123456"))
|
|
||||||
}
|
|
||||||
|
@ -88,24 +88,3 @@ func (c *Client) GetGameVersion(req *GetGameVersionReq) (resp *GetGameVersionRes
|
|||||||
err = c.DoAction(req, resp)
|
err = c.DoAction(req, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetConfig 获取游戏全局配置
|
|
||||||
func (c *Client) GetConfig(req *GetConfigReq) (resp *GetConfigResp, err error) {
|
|
||||||
resp = CreateGetConfigResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRealAuthBlackList 获取实名黑名单
|
|
||||||
func (c *Client) GetRealAuthBlackList(req *GetRealAuthBlackListReq) (resp *GetRealAuthBlackListResp, err error) {
|
|
||||||
resp = CreateGetRealAuthBlackListResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGameRealAuthInfo 获取实名参数
|
|
||||||
func (c *Client) GetGameRealAuthInfo(req *GetGameRealAuthInfoReq) (resp *GetGameRealAuthInfoResp, err error) {
|
|
||||||
resp = CreateGetGameRealAuthInfoResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
@ -134,48 +134,3 @@ func TestIsBlockOutIos(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(isBlockOutIos)
|
t.Log(isBlockOutIos)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取游戏全局配置
|
|
||||||
func TestGetConfig(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
getConfigReq := CreateGetConfigReq("overlord_act_config")
|
|
||||||
isBlockOutIos, err := client.GetConfig(getConfigReq)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(isBlockOutIos)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取实名黑名单
|
|
||||||
func TestGetRealAuthBlackList(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
getRealAuthBlackListReq := CreateGetRealAuthBlackListReq()
|
|
||||||
isBlockOutIos, err := client.GetRealAuthBlackList(getRealAuthBlackListReq)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(isBlockOutIos)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取游戏实名参数
|
|
||||||
func TestGetGameRealAuthInfo(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
getGameRealAuthInfoReq := CreateGetGameRealAuthInfoReq(7081)
|
|
||||||
isBlockOutIos, err := client.GetGameRealAuthInfo(getGameRealAuthInfoReq)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(isBlockOutIos)
|
|
||||||
}
|
|
||||||
|
@ -315,123 +315,3 @@ func CreateGetGameVersionResp() *GetGameVersionResp {
|
|||||||
BaseResponse: &responses.BaseResponse{},
|
BaseResponse: &responses.BaseResponse{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetConfigReq
|
|
||||||
// 游戏全局配置
|
|
||||||
type GetConfigReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
Key string `position:"Query" field:"key" default:"-" `
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetConfigRespData struct {
|
|
||||||
Id int `json:"id"`
|
|
||||||
Key string `json:"key"`
|
|
||||||
ExtData string `json:"ext_data"`
|
|
||||||
}
|
|
||||||
type GetConfigResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data GetConfigRespData `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetConfigReq(key string) *GetConfigReq {
|
|
||||||
req := &GetConfigReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.Key = key
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getConfig")
|
|
||||||
req.Method = requests.GET
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetConfigResp() *GetConfigResp {
|
|
||||||
return &GetConfigResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRealAuthBlackListReq
|
|
||||||
// 获取实名黑名单
|
|
||||||
type GetRealAuthBlackListReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
Key string `position:"Query" field:"key" default:"-" `
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetRealAuthBlackListRespDataItem struct {
|
|
||||||
Id int `json:"id"`
|
|
||||||
TrueName string `json:"true_name"`
|
|
||||||
IdCard string `json:"id_card"`
|
|
||||||
Remark string `json:"remark"`
|
|
||||||
CreateBy string `json:"create_by"`
|
|
||||||
UpdateBy string `json:"update_by"`
|
|
||||||
CreatedAt string `json:"created_at"`
|
|
||||||
UpdatedAt string `json:"updated_at"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetRealAuthBlackListResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []GetRealAuthBlackListRespDataItem `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetRealAuthBlackListReq() *GetRealAuthBlackListReq {
|
|
||||||
req := &GetRealAuthBlackListReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getRealAuthBlackList")
|
|
||||||
req.Method = requests.GET
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetRealAuthBlackListResp() *GetRealAuthBlackListResp {
|
|
||||||
return &GetRealAuthBlackListResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGameRealAuthInfoReq
|
|
||||||
// 获取实名参数
|
|
||||||
type GetGameRealAuthInfoReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
GameId int64 `position:"Body" field:"game_id" default:"-" `
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGameRealAuthInfoRespData struct {
|
|
||||||
GroupName string `json:"group_name"`
|
|
||||||
GroupDescription int `json:"group_description"`
|
|
||||||
VerifiedTime string `json:"verified_time"`
|
|
||||||
AreaProvince string `json:"area_province"`
|
|
||||||
VersionInfo string `json:"version_info"`
|
|
||||||
IsReal int `json:"is_real"`
|
|
||||||
IsDirect int `json:"is_direct"`
|
|
||||||
AuthChannel string `json:"auth_channel"`
|
|
||||||
StandbyAuthChannel string `json:"standby_auth_channel"`
|
|
||||||
ProtectTime int `json:"protect_time"`
|
|
||||||
GovIoReport int `json:"gov_io_report"`
|
|
||||||
MinorBan int `json:"minor_ban"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGameRealAuthInfoResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data GetGameRealAuthInfoRespData `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetGameRealAuthInfoReq(gameId int64) *GetGameRealAuthInfoReq {
|
|
||||||
req := &GetGameRealAuthInfoReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
GameId: gameId,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/login/getGameRealAuthInfo")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetGameRealAuthInfoResp() *GetGameRealAuthInfoResp {
|
|
||||||
return &GetGameRealAuthInfoResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
package msdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
const VERSION = "2024-06-25"
|
|
||||||
|
|
||||||
var HOST = requests.Host{
|
|
||||||
Default: "msdk.api.gaore.com",
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client, err error) {
|
|
||||||
client = &Client{}
|
|
||||||
err = client.Init()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetIdfa 获取设备归因信息
|
|
||||||
func (c *Client) GetIdfa(req *GetIdfaReq) (resp *GetIdfaResp, err error) {
|
|
||||||
resp = &GetIdfaResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
if req.Imei == "" && req.Idfa != "" {
|
|
||||||
req.Imei = req.Idfa
|
|
||||||
}
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUserAttr 获取用户归因信息
|
|
||||||
func (c *Client) GetUserAttr(req *GetUserAttrReq) (resp *GetUserAttrResp, err error) {
|
|
||||||
resp = &GetUserAttrResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetImei 用户注册归因
|
|
||||||
func (c *Client) GetImei(req *GetImeiReq) (resp *GetImeiResp, err error) {
|
|
||||||
resp = &GetImeiResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) SetImei(req *SetImeiReq) (resp *SetImeiResp, err error) {
|
|
||||||
resp = &SetImeiResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,149 +0,0 @@
|
|||||||
package msdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestClient_GetUserAttr(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req := CreateGetUserAttrReq("ql83649336", "xxhbbxxl")
|
|
||||||
resp, err := client.GetUserAttr(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetIdfa(t *testing.T) {
|
|
||||||
header := &requests.RefererHeader{
|
|
||||||
Referer: "https://www.gaore.com",
|
|
||||||
TraceId: utils.MakeTraceId(),
|
|
||||||
}
|
|
||||||
_ = header
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client.SetRefererHeader(header)
|
|
||||||
req := CreateGetIdfaReq()
|
|
||||||
req.ChannelId = 1
|
|
||||||
req.GameId = 3706
|
|
||||||
req.Ip = "112.23.230.210"
|
|
||||||
req.Imei = "00000000-0000-0000-0000-000000000000"
|
|
||||||
req.LongId = "daff65f07c7cf84862f4217773e3d613"
|
|
||||||
req.SdkVersion = "1.7.2"
|
|
||||||
req.Os = "ios"
|
|
||||||
req.GameOs = 2
|
|
||||||
req.GameSubOs = 0
|
|
||||||
req.Ua = "Mozilla/5.0 (iPad; CPU OS 15_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
|
|
||||||
req.GameSign = "hlhj"
|
|
||||||
req.PkgAgentId = "100"
|
|
||||||
req.PkgSiteId = "1001"
|
|
||||||
req.Network = "Wifi"
|
|
||||||
req.Idfv = "53F2A5F7-B1D4-4716-9775-07727C29BC7A"
|
|
||||||
req.ScreenResolution = "2360*1640"
|
|
||||||
req.System = "15.6.1"
|
|
||||||
req.ProcessorModel = "iPad13,16"
|
|
||||||
req.BaseBand = ""
|
|
||||||
req.Model = "iPad13,16"
|
|
||||||
req.Battery = "74"
|
|
||||||
req.Oaid = ""
|
|
||||||
req.AdInfo = ""
|
|
||||||
req.WxPlatform = ""
|
|
||||||
req.AdDevice = "{\"bootTimeInSec\":\"1745364499\",\"countryCode\":\"CN\",\"language\":\"zh-Hans-CN\",\"deviceName\":\"1b9018182a49e16ba85bb095f224867c\",\"systemVersion\":\"15.6.1\",\"machine\":\"iPad13,16\",\"carrierInfo\":\"unknown\",\"memory\":\"8000356352\",\"disk\":\"255983177728\",\"sysFileTime\":\"1663537105.729985\",\"model\":\"J407AP\",\"timeZone\":\"28800\",\"mntId\":\"A058368B97B0D073829608AAC13FFA64D9BEFD0FE3E14EDB106F2BABD6DF94B1C2BFC7509CBB683EE5B22D91A19FF67A@/dev/disk0s1s1\",\"deviceInitTime\":\"1663537056.906820124\"}"
|
|
||||||
resp, err := client.GetIdfa(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetImei(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req := CreateGetImeiReq()
|
|
||||||
req.Uid = 218047048
|
|
||||||
req.UserName = "ct939725671"
|
|
||||||
req.GameId = 8050
|
|
||||||
req.GameSign = "mrwld"
|
|
||||||
req.RegTime = 1750939725
|
|
||||||
req.Imei = "of5wO5sKWep0OFPt9rWQf6xNJVPg"
|
|
||||||
req.ChannelId = 1
|
|
||||||
req.AgentId = 100
|
|
||||||
req.SiteId = 1001
|
|
||||||
req.Ip = "1864204063"
|
|
||||||
req.Idfa = "of5wO5sKWep0OFPt9rWQf6xNJVPg"
|
|
||||||
req.Logined = 1
|
|
||||||
req.MatchType = 1
|
|
||||||
req.GameAwemeId = ""
|
|
||||||
req.ComeBackUser = 0
|
|
||||||
req.FanCode = ""
|
|
||||||
req.Network = ""
|
|
||||||
req.Idfv = ""
|
|
||||||
req.ScreenResolution = ""
|
|
||||||
req.System = ""
|
|
||||||
req.Electric = ""
|
|
||||||
req.ProcessorModel = ""
|
|
||||||
req.BaseBand = ""
|
|
||||||
req.Model = ""
|
|
||||||
req.Battery = ""
|
|
||||||
req.Oaid = ""
|
|
||||||
req.AdInfo = ""
|
|
||||||
req.AdDevice = ""
|
|
||||||
req.Ua = "WebSdk GaoreGame/1.3.1"
|
|
||||||
req.WxPlatform = ""
|
|
||||||
resp, err := client.GetImei(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
t.Log(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSetImei(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req := CreateSetImeiReq()
|
|
||||||
// 基础字段赋值
|
|
||||||
req.UserName = "15179405888"
|
|
||||||
req.GameId = 6062
|
|
||||||
req.GameSign = "hlhj"
|
|
||||||
req.ChannelId = 1 // mtype
|
|
||||||
req.MatchType = 2
|
|
||||||
req.Imei = "96d9acdd57535c92-null"
|
|
||||||
req.Idfa = "96d9acdd57535c92-null"
|
|
||||||
req.Network = "4G"
|
|
||||||
req.Idfv = ""
|
|
||||||
req.ScreenResolution = "2132x1080"
|
|
||||||
req.System = "11"
|
|
||||||
req.ProcessorModel = ""
|
|
||||||
req.BaseBand = ""
|
|
||||||
req.Model = "PCDM10"
|
|
||||||
req.Battery = "45"
|
|
||||||
req.Oaid = "B9258E43A5084B43B72D94580C830898343a97328d6fd210b9e23859b1d5e83d_gaore_"
|
|
||||||
req.AdInfo = ""
|
|
||||||
req.AdDevice = ""
|
|
||||||
req.Ua = "Mozilla/5.0 (Linux; Android 11; PCDM10 Build/RP1A.200720.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile Safari/537.36; SHGR GaoreGame/2.3.5"
|
|
||||||
req.WxPlatform = ""
|
|
||||||
|
|
||||||
resp, err := client.SetImei(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(resp)
|
|
||||||
}
|
|
@ -1,218 +0,0 @@
|
|||||||
package msdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"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/utils"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
const msdkKey = "msdk@gaore.com#!!"
|
|
||||||
|
|
||||||
type GetIdfaReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
ChannelId int `position:"Query" field:"mtype"`
|
|
||||||
GameId int `position:"Query" field:"game_id"`
|
|
||||||
GameSign string `position:"Query" field:"game_sign"`
|
|
||||||
Ip string `position:"Query" field:"ip"`
|
|
||||||
Imei string `position:"Query" field:"imei"`
|
|
||||||
Idfa string `position:"Query" field:"idfa"`
|
|
||||||
Idfv string `position:"Query" field:"idfv"`
|
|
||||||
LongId string `position:"Query" field:"long_id"`
|
|
||||||
SdkVersion string `position:"Query" field:"version"`
|
|
||||||
Os string `position:"Query" field:"os"`
|
|
||||||
GameOs int `position:"Query" field:"game_os"`
|
|
||||||
GameSubOs int `position:"Query" field:"game_sub_os"`
|
|
||||||
UserName string `position:"Query" field:"user_name"`
|
|
||||||
Ua string `position:"Query" field:"ua"`
|
|
||||||
LiveCode string `position:"Query" field:"live_code"`
|
|
||||||
AdDevice string `position:"Query" field:"ad_device"`
|
|
||||||
PkgAgentId string `position:"Query" field:"pkg_agent_id"`
|
|
||||||
PkgSiteId string `position:"Query" field:"pkg_site_id"`
|
|
||||||
Network string `position:"Query" field:"network"`
|
|
||||||
ScreenResolution string `position:"Query" field:"screen_resolution"`
|
|
||||||
System string `position:"Query" field:"system"`
|
|
||||||
Electric string `position:"Query" field:"electric"`
|
|
||||||
ProcessorModel string `position:"Query" field:"processor_model"`
|
|
||||||
BaseBand string `position:"Query" field:"baseband"`
|
|
||||||
Model string `position:"Query" field:"model"`
|
|
||||||
Battery string `position:"Query" field:"battery"`
|
|
||||||
Oaid string `position:"Query" field:"oaid"`
|
|
||||||
AdInfo string `position:"Query" field:"adinfo"`
|
|
||||||
WxPlatform string `position:"Query" field:"wx_platform"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetIdfaResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
GameId int `json:"game_id"`
|
|
||||||
AgentId int `json:"agent_id"`
|
|
||||||
SiteId int `json:"site_id"`
|
|
||||||
GameAwemeId string `json:"game_aweme_id"`
|
|
||||||
LongId string `json:"long_id"`
|
|
||||||
DeviceId string `json:"device_id"`
|
|
||||||
Exists bool `json:"exists"`
|
|
||||||
FromAd bool `json:"from_ad"`
|
|
||||||
MatchType int `json:"match_type"`
|
|
||||||
ClickId string `json:"click_id,omitempty"` // 非必要字段,使用 omitempty 忽略空值
|
|
||||||
MatchTrace string `json:"match_trace,omitempty"` // 非必要字段
|
|
||||||
RegTime int64 `json:"reg_time"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetIdfaReq() *GetIdfaReq {
|
|
||||||
req := &GetIdfaReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/getidfa.php")
|
|
||||||
req.Method = requests.GET
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserAttrReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
UserName string `position:"Query" field:"user_name"`
|
|
||||||
GameSign string `position:"Query" field:"game_sign"`
|
|
||||||
Ts int64 `position:"Query" field:"ts"`
|
|
||||||
Sign string `position:"Query" field:"sign"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserAttrResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
Uid int `json:"uid"`
|
|
||||||
UserName string `json:"user_name"`
|
|
||||||
RegTime int `json:"reg_time"` // 假设注册时间是时间戳
|
|
||||||
GameID int `json:"game_id"`
|
|
||||||
RegIP string `json:"reg_ip"`
|
|
||||||
AgentId int `json:"agent_id"`
|
|
||||||
SiteId int `json:"site_id"`
|
|
||||||
Imei string `json:"imei"`
|
|
||||||
Oaid string `json:"oaid"`
|
|
||||||
LongId string `json:"long_id"`
|
|
||||||
PromotionId string `json:"promotion_id"`
|
|
||||||
Mid3 string `json:"mid3"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetUserAttrReq(userName, gameSign string) *GetUserAttrReq {
|
|
||||||
req := &GetUserAttrReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.UserName = userName
|
|
||||||
req.GameSign = gameSign
|
|
||||||
req.Ts = time.Now().Unix()
|
|
||||||
req.Sign = utils.Md5(fmt.Sprintf("%d%s", req.Ts, msdkKey))
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/getUserAttr.php")
|
|
||||||
req.Method = requests.GET
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetImeiReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
Uid int `position:"Query" field:"uid"`
|
|
||||||
UserName string `position:"Query" field:"user_name"`
|
|
||||||
GameId int `position:"Query" field:"game_id"`
|
|
||||||
GameSign string `position:"Query" field:"game_sign"`
|
|
||||||
RegTime int64 `position:"Query" field:"reg_time"`
|
|
||||||
Imei string `position:"Query" field:"imei"`
|
|
||||||
ChannelId int `position:"Query" field:"mtype"`
|
|
||||||
AgentId int `position:"Query" field:"agent_id"`
|
|
||||||
SiteId int `position:"Query" field:"site_id"`
|
|
||||||
Ip string `position:"Query" field:"ip"`
|
|
||||||
UserIp string `position:"Query" field:"user_ip"`
|
|
||||||
Idfa string `position:"Query" field:"idfa"`
|
|
||||||
Logined int `position:"Query" field:"logined"`
|
|
||||||
MatchType int `position:"Query" field:"match_type"`
|
|
||||||
GameAwemeId string `position:"Query" field:"game_aweme_id"`
|
|
||||||
ComeBackUser int `position:"Query" field:"come_back_user"` //回流用户标识 1=>回流用户
|
|
||||||
LpReg int `position:"Query" field:"lp_reg"` // 落地页注册用户标识
|
|
||||||
FanCode string `position:"Query" field:"fan_code"` // 粉丝码
|
|
||||||
Network string `position:"Query" field:"network"`
|
|
||||||
Idfv string `position:"Query" field:"idfv"`
|
|
||||||
ScreenResolution string `position:"Query" field:"screen_resolution"`
|
|
||||||
System string `position:"Query" field:"system"`
|
|
||||||
Electric string `position:"Query" field:"electric"`
|
|
||||||
ProcessorModel string `position:"Query" field:"processor_model"`
|
|
||||||
BaseBand string `position:"Query" field:"baseband"`
|
|
||||||
Model string `position:"Query" field:"model"`
|
|
||||||
Battery string `position:"Query" field:"battery"`
|
|
||||||
Oaid string `position:"Query" field:"oaid"`
|
|
||||||
AdInfo string `position:"Query" field:"adinfo"`
|
|
||||||
AdDevice string `position:"Query" field:"ad_device"`
|
|
||||||
Ua string `position:"Query" field:"ua"`
|
|
||||||
WxPlatform string `position:"Query" field:"wx_platform"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetImeiResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Uid string `json:"uid"`
|
|
||||||
UserName string `json:"user_name"`
|
|
||||||
Openid string `json:"openid"`
|
|
||||||
ChannelId string `json:"mtype"`
|
|
||||||
Logined int `json:"logined"`
|
|
||||||
GameId string `json:"game_id"`
|
|
||||||
GameSign string `json:"game_sign"`
|
|
||||||
MatchType int `json:"match_type"`
|
|
||||||
RegTime int64 `json:"reg_time"` // 原始时间戳字符串
|
|
||||||
Imei string `json:"imei"`
|
|
||||||
Oaid string `json:"oaid"`
|
|
||||||
Idfa string `json:"idfa"`
|
|
||||||
Ip int64 `json:"ip"`
|
|
||||||
UserIp string `json:"user_ip"`
|
|
||||||
Ua string `json:"ua"`
|
|
||||||
Media string `json:"media"`
|
|
||||||
AgentId int `json:"agent_id"`
|
|
||||||
SiteId int `json:"site_id"`
|
|
||||||
AdInfo string `json:"adinfo"`
|
|
||||||
GameAwemeId string `json:"game_aweme_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetImeiReq() *GetImeiReq {
|
|
||||||
req := &GetImeiReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/getimei.php")
|
|
||||||
req.Method = requests.GET
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetImeiReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
UserName string `position:"Query" field:"user_name"`
|
|
||||||
GameId int `position:"Query" field:"game_id"`
|
|
||||||
Imei string `position:"Query" field:"imei"`
|
|
||||||
Idfa string `position:"Query" field:"idfa"`
|
|
||||||
GameSign string `position:"Query" field:"game_sign"`
|
|
||||||
ChannelId int `position:"Query" field:"mtype"`
|
|
||||||
MatchType int `position:"Query" field:"match_type"`
|
|
||||||
Network string `position:"Query" field:"network"`
|
|
||||||
Idfv string `position:"Query" field:"idfv"`
|
|
||||||
ScreenResolution string `position:"Query" field:"screen_resolution"`
|
|
||||||
System string `position:"Query" field:"system"` // 可能为系统版本号字符串
|
|
||||||
ProcessorModel string `position:"Query" field:"processor_model"`
|
|
||||||
BaseBand string `position:"Query" field:"baseband"`
|
|
||||||
Model string `position:"Query" field:"model"`
|
|
||||||
Battery string `position:"Query" field:"battery"`
|
|
||||||
Oaid string `position:"Query" field:"oaid"`
|
|
||||||
AdInfo string `position:"Query" field:"adinfo"`
|
|
||||||
AdDevice string `position:"Query" field:"ad_device"`
|
|
||||||
Ua string `position:"Query" field:"ua"`
|
|
||||||
WxPlatform string `position:"Query" field:"wx_platform"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetImeiResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateSetImeiReq() *SetImeiReq {
|
|
||||||
req := &SetImeiReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/setimei.php")
|
|
||||||
req.Method = requests.GET
|
|
||||||
return req
|
|
||||||
}
|
|
@ -3,7 +3,6 @@ package passport
|
|||||||
import (
|
import (
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -41,17 +40,3 @@ func (c *Client) GetUserRoleList(req *GetUserRoleListRequest) (response *GetUser
|
|||||||
err = c.DoAction(req, response)
|
err = c.DoAction(req, response)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditCard
|
|
||||||
// 新增或修改实名信息
|
|
||||||
func (c *Client) EditCard(req EditCardRequestParam) (response string, err error) {
|
|
||||||
editCardRequest := CreateEditCardRequest(req)
|
|
||||||
createEditCardResponse := CreateEditCardResponse()
|
|
||||||
err = c.DoAction(editCardRequest, createEditCardResponse)
|
|
||||||
if err != nil && strings.Contains(err.Error(), "json Unmarshal:") {
|
|
||||||
return createEditCardResponse.GetHttpContentString(), nil
|
|
||||||
} else if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return createEditCardResponse.GetHttpContentString(), nil
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package passport
|
package passport
|
||||||
|
|
||||||
import (
|
import "testing"
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 单元测试
|
// 单元测试
|
||||||
|
|
||||||
@ -33,30 +31,3 @@ func TestGetUserRoleList(t *testing.T) {
|
|||||||
t.Logf("resp code:%+v", resp.Code)
|
t.Logf("resp code:%+v", resp.Code)
|
||||||
t.Logf("resp data:%+v", resp.Data)
|
t.Logf("resp data:%+v", resp.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEditCard(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
editCardRequest := EditCardRequestParam{
|
|
||||||
Uid: 32455414,
|
|
||||||
GameId: 5010,
|
|
||||||
Imei: "11111111",
|
|
||||||
IsReal: 0,
|
|
||||||
DirectStatus: 1,
|
|
||||||
AuthChannel: "gjfcm_wzcq",
|
|
||||||
DirectExtData: "测试测试测试",
|
|
||||||
Pi: "",
|
|
||||||
Ip: "",
|
|
||||||
Ipv6: "",
|
|
||||||
UserName: "asfasfd",
|
|
||||||
RealName: "这艘啊",
|
|
||||||
IdCard: "33032419950123532X",
|
|
||||||
Mandatory: "3123123123",
|
|
||||||
}
|
|
||||||
editCardResponse, err := client.EditCard(editCardRequest)
|
|
||||||
t.Logf("%v", editCardResponse)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -1,97 +0,0 @@
|
|||||||
package passport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"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/utils"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
const weeDongKey = "aVCxX2B3yswpxCMjaaSUHFXAzLYyuGhW"
|
|
||||||
|
|
||||||
func weeDongGetSign(ts int64) string {
|
|
||||||
return utils.Md5(utils.Md5(fmt.Sprintf("%d", ts)+weeDongKey) + weeDongKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
type EditCardRequestParam struct {
|
|
||||||
Uid int64 `position:"Body" field:"uid"`
|
|
||||||
GameId int64 `position:"Body" field:"game_id"`
|
|
||||||
Imei string `position:"Body" field:"imei"`
|
|
||||||
IsReal int64 `position:"Body" field:"is_real"`
|
|
||||||
DirectStatus int64 `position:"Body" field:"direct_status"`
|
|
||||||
AuthChannel string `position:"Body" field:"auth_channel"`
|
|
||||||
DirectExtData string `position:"Body" field:"direct_ext_data"`
|
|
||||||
Pi string `position:"Body" field:"pi"`
|
|
||||||
Ip string `position:"Body" field:"ip"`
|
|
||||||
Ipv6 string `position:"Body" field:"ipv6"`
|
|
||||||
UserName string `position:"Body" field:"user_name"`
|
|
||||||
RealName string `position:"Body" field:"truename"`
|
|
||||||
IdCard string `position:"Body" field:"idcard"`
|
|
||||||
Mandatory string `position:"Body" field:"mandatory"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type EditCardResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
type EditCardRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
Uid int64 `position:"Body" field:"uid"`
|
|
||||||
GameId int64 `position:"Body" field:"game_id"`
|
|
||||||
Imei string `position:"Body" field:"imei"`
|
|
||||||
IsReal int64 `position:"Body" field:"is_real"`
|
|
||||||
DirectStatus int64 `position:"Body" field:"direct_status"`
|
|
||||||
AuthChannel string `position:"Body" field:"auth_channel"`
|
|
||||||
DirectExtData string `position:"Body" field:"direct_ext_data"`
|
|
||||||
Pi string `position:"Body" field:"pi"`
|
|
||||||
Ip string `position:"Body" field:"ip"`
|
|
||||||
Ipv6 string `position:"Body" field:"ipv6"`
|
|
||||||
UserName string `position:"Body" field:"user_name"`
|
|
||||||
RealName string `position:"Body" field:"truename"`
|
|
||||||
IdCard string `position:"Body" field:"idcard"`
|
|
||||||
Mandatory string `position:"Body" field:"mandatory"`
|
|
||||||
Action string `position:"Body" field:"action"`
|
|
||||||
Flag string `position:"Body" field:"flag"`
|
|
||||||
Time string `position:"Body" field:"time"`
|
|
||||||
IsDirect int64 `position:"Body" field:"is_direct"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateEditCardRequest 记录实名结果接口
|
|
||||||
func CreateEditCardRequest(param EditCardRequestParam) (req *EditCardRequest) {
|
|
||||||
ts := time.Now().Unix()
|
|
||||||
sign := weeDongGetSign(ts)
|
|
||||||
|
|
||||||
req = &EditCardRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
Action: "edit_card",
|
|
||||||
Flag: sign,
|
|
||||||
Time: fmt.Sprintf("%v", ts),
|
|
||||||
IsDirect: 0,
|
|
||||||
//
|
|
||||||
Uid: param.Uid,
|
|
||||||
GameId: param.GameId,
|
|
||||||
Imei: param.Imei,
|
|
||||||
IsReal: param.IsReal,
|
|
||||||
DirectStatus: param.DirectStatus,
|
|
||||||
AuthChannel: param.AuthChannel,
|
|
||||||
DirectExtData: param.DirectExtData,
|
|
||||||
Pi: param.Pi,
|
|
||||||
Ip: param.Ip,
|
|
||||||
Ipv6: param.Ipv6,
|
|
||||||
UserName: param.UserName,
|
|
||||||
RealName: param.RealName,
|
|
||||||
IdCard: param.IdCard,
|
|
||||||
Mandatory: param.Mandatory,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/weedong.php")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateEditCardResponse() (response *EditCardResponse) {
|
|
||||||
response = &EditCardResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user