Compare commits
No commits in common. "master" and "v1.1.79" have entirely different histories.
@ -46,27 +46,6 @@ type Client struct {
|
||||
httpProxy string
|
||||
httpsProxy 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 {
|
||||
@ -239,7 +218,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) {
|
||||
request.AddHeaders(client.GetRefererHeader())
|
||||
|
||||
httpRequest, err := client.buildRequestWithSigner(request, signer)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -56,11 +56,6 @@ type Host struct {
|
||||
Func func(string) string
|
||||
}
|
||||
|
||||
type RefererHeader struct {
|
||||
Referer string
|
||||
TraceId string
|
||||
}
|
||||
|
||||
var debug utils.Debug
|
||||
|
||||
func init() {
|
||||
@ -100,7 +95,6 @@ type AcsRequest interface {
|
||||
GetBodyReader() io.Reader
|
||||
|
||||
AddHeaderParam(key, value string)
|
||||
AddHeaders(headers map[string]string)
|
||||
addQueryParam(key, value string)
|
||||
addFormParam(key, value string)
|
||||
addJsonParam(string, any)
|
||||
@ -232,12 +226,6 @@ func (request *baseRequest) AddHeaderParam(key, val string) {
|
||||
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) {
|
||||
request.QueryParams[key] = val
|
||||
}
|
||||
|
@ -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"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils/random"
|
||||
"hash"
|
||||
rand2 "math/rand"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"sort"
|
||||
@ -36,7 +36,11 @@ func NewUUID() UUID {
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -110,7 +114,3 @@ 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))
|
||||
}
|
||||
|
@ -34,11 +34,6 @@ type OrderRecord struct {
|
||||
OrderParts []*OrderSubmitPart `json:"order_parts"`
|
||||
Id int64 `json:"id"`
|
||||
WorkOrderTemplateFirstLevelId int64 `json:"work_order_template_first_level_id"`
|
||||
WorkOrderTemplateId int64 `json:"work_order_template_id"`
|
||||
WorkOrderTemplateName string `json:"work_order_template_name"`
|
||||
Uid int64 `json:"uid"`
|
||||
OrderStatus string `json:"order_status"`
|
||||
OrderStatusName string `json:"order_status_name"`
|
||||
}
|
||||
|
||||
// PageInfoResp 分页响应
|
||||
|
@ -95,17 +95,3 @@ func (c *Client) GetConfig(req *GetConfigReq) (resp *GetConfigResp, err error) {
|
||||
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
|
||||
}
|
||||
|
@ -149,33 +149,3 @@ func TestGetConfig(t *testing.T) {
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
@ -103,9 +103,6 @@ type GameInfoData struct {
|
||||
FlashPassKey string `json:"flash_pass_key"`
|
||||
GameByname string `json:"game_byname"`
|
||||
GameIconImg string `json:"game_icon_img"`
|
||||
GameImage string `json:"game_image"`
|
||||
GameHomeImage string `json:"game_home_image"`
|
||||
GameHomeShortImage string `json:"game_home_short_image"`
|
||||
GameSign string `json:"game_sign"`
|
||||
GameTsUrl string `json:"game_ts_url"`
|
||||
GameVersion string `json:"game_version"`
|
||||
@ -353,88 +350,3 @@ func CreateGetConfigResp() *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,8 +1,6 @@
|
||||
package msdk
|
||||
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -22,17 +20,11 @@ func TestClient_GetUserAttr(t *testing.T) {
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -63,7 +63,7 @@ func CreateGetIdfaReq() *GetIdfaReq {
|
||||
req := &GetIdfaReq{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/getidfa.php")
|
||||
req.InitWithApiInfo(HOST, VERSION, "/getIdfa.php")
|
||||
req.Method = requests.GET
|
||||
return req
|
||||
}
|
||||
@ -173,7 +173,7 @@ func CreateGetImeiReq() *GetImeiReq {
|
||||
req := &GetImeiReq{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/getimei.php")
|
||||
req.InitWithApiInfo(HOST, VERSION, "/getImei.php")
|
||||
req.Method = requests.GET
|
||||
return req
|
||||
}
|
||||
@ -212,7 +212,7 @@ func CreateSetImeiReq() *SetImeiReq {
|
||||
req := &SetImeiReq{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/setimei.php")
|
||||
req.InitWithApiInfo(HOST, VERSION, "/setImei.php")
|
||||
req.Method = requests.GET
|
||||
return req
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package passport
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -41,17 +40,3 @@ func (c *Client) GetUserRoleList(req *GetUserRoleListRequest) (response *GetUser
|
||||
err = c.DoAction(req, response)
|
||||
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
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
// 单元测试
|
||||
|
||||
@ -33,30 +31,3 @@ func TestGetUserRoleList(t *testing.T) {
|
||||
t.Logf("resp code:%+v", resp.Code)
|
||||
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"`
|
||||
IsDirect int64 `position:"Body" field:"is_direct"`
|
||||
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"`
|
||||
IsDirect int64 `position:"Body" field:"is_direct"`
|
||||
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"`
|
||||
}
|
||||
|
||||
// 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: param.IsDirect,
|
||||
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