Compare commits
No commits in common. "master" and "v1.0.0.1" have entirely different histories.
@ -25,13 +25,7 @@ func signRpcRequest(request requests.AcsRequest, signer Signer) (err error) {
|
|||||||
stringToSign := buildRpcStringToSign(request)
|
stringToSign := buildRpcStringToSign(request)
|
||||||
request.SetStringToSign(stringToSign)
|
request.SetStringToSign(stringToSign)
|
||||||
signature := signer.Sign(stringToSign, "&")
|
signature := signer.Sign(stringToSign, "&")
|
||||||
accessKeyForm, err := signer.GetAccessKeyFrom()
|
request.GetQueryParams()["sign"] = signature
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if accessKeyForm != "" {
|
|
||||||
request.GetQueryParams()["sign"] = signature
|
|
||||||
}
|
|
||||||
debug("GrSdk sign: %s", signature)
|
debug("GrSdk sign: %s", signature)
|
||||||
debug("GrSdk sign string: %s", stringToSign)
|
debug("GrSdk sign string: %s", stringToSign)
|
||||||
debug("GrSdk sign: \r\n")
|
debug("GrSdk sign: \r\n")
|
||||||
@ -44,19 +38,18 @@ func completeRpcSignParams(request requests.AcsRequest, signer Signer) (err erro
|
|||||||
if accessKeyFrom, err = signer.GetAccessKeyFrom(); err != nil {
|
if accessKeyFrom, err = signer.GetAccessKeyFrom(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if accessKeyFrom != "" {
|
|
||||||
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 {
|
queryParams := request.GetQueryParams()
|
||||||
return
|
queryParams["access_time"] = fmt.Sprintf("%d", time.Now().Unix())
|
||||||
}
|
queryParams["access_key"], err = signer.GetAccessKeyId()
|
||||||
request.GetHeaders()["Gr-Sdk-From"] = accessKeyFrom
|
queryParams["access_from"] = accessKeyFrom
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
request.GetHeaders()["Content-type"] = requests.Form
|
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
|
||||||
|
@ -83,15 +83,6 @@ func (client *Client) InitClientConfig() (config *Config) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) InitWithArea(area string, env ...string) error {
|
|
||||||
config := client.InitClientConfig()
|
|
||||||
if len(env) >= 1 {
|
|
||||||
config.Env = env[0]
|
|
||||||
}
|
|
||||||
config.Area = area
|
|
||||||
return client.InitWithOptions(config, new(credentials.BaseCredential))
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
||||||
credential := &credentials.BaseCredential{
|
credential := &credentials.BaseCredential{
|
||||||
@ -288,10 +279,6 @@ func (client *Client) buildRequestWithSigner(request requests.AcsRequest, signer
|
|||||||
request.SetEnv(client.config.Env)
|
request.SetEnv(client.config.Env)
|
||||||
}
|
}
|
||||||
|
|
||||||
if request.GetArea() == "" && client.config.Area != "" {
|
|
||||||
request.SetArea(client.config.Area)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = requests.InitParam(request)
|
err = requests.InitParam(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -15,7 +15,6 @@ type Config struct {
|
|||||||
Scheme string `default:"HTTP"`
|
Scheme string `default:"HTTP"`
|
||||||
Timeout time.Duration `default:"5"`
|
Timeout time.Duration `default:"5"`
|
||||||
Env string `default:""`
|
Env string `default:""`
|
||||||
Area string `default:""`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig() *Config {
|
func NewConfig() *Config {
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
package requests
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/utils"
|
|
||||||
"io"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type JsonRequest struct {
|
|
||||||
*baseRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) init() {
|
|
||||||
request.baseRequest = defaultBaseRequest()
|
|
||||||
request.baseRequest.AddHeaderParam("Content-Type", Json)
|
|
||||||
request.Method = POST
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) BuildUrl() string {
|
|
||||||
|
|
||||||
var hostname string
|
|
||||||
if request.Domain.Func == nil {
|
|
||||||
hostname = request.Domain.Default
|
|
||||||
} else if hostname = request.Domain.Func(request.GetEnv(), request.GetArea()); hostname == "" {
|
|
||||||
hostname = request.Domain.Default
|
|
||||||
}
|
|
||||||
|
|
||||||
url := fmt.Sprintf("%s://%s", strings.ToLower(request.Scheme), hostname)
|
|
||||||
if len(request.Port) > 0 {
|
|
||||||
url = fmt.Sprintf("%s:%s", url, request.Port)
|
|
||||||
}
|
|
||||||
return url + request.BuildQueries()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) GetStyle() string {
|
|
||||||
return STREAM
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) BuildQueries() string {
|
|
||||||
path := strings.TrimLeft(strings.TrimSpace(request.GetActionName()), "/")
|
|
||||||
mod := "&"
|
|
||||||
if !strings.Contains(path, "?") {
|
|
||||||
mod = "?"
|
|
||||||
}
|
|
||||||
request.queries = "/" + path + mod + utils.GetUrlFormedMap(request.QueryParams)
|
|
||||||
return request.queries
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) GetActionName() string {
|
|
||||||
return request.actionName
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) InitWithApiInfo(domain Host, version, urlPath string) {
|
|
||||||
request.init()
|
|
||||||
request.SetDomain(domain)
|
|
||||||
request.version = version
|
|
||||||
request.actionName = urlPath
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) GetBodyReader() io.Reader {
|
|
||||||
if request.JsonParams != nil && len(request.JsonParams) > 0 {
|
|
||||||
body, err := json.Marshal(request.JsonParams)
|
|
||||||
if err == nil {
|
|
||||||
return bytes.NewReader(body)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return strings.NewReader("")
|
|
||||||
}
|
|
@ -12,9 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RPC = "RPC"
|
RPC = "RPC"
|
||||||
ROA = "ROA"
|
ROA = "ROA"
|
||||||
STREAM = "STREAM"
|
|
||||||
|
|
||||||
HTTP = "HTTP"
|
HTTP = "HTTP"
|
||||||
HTTPS = "HTTPS"
|
HTTPS = "HTTPS"
|
||||||
@ -37,11 +36,10 @@ const (
|
|||||||
Raw = "application/octet-stream"
|
Raw = "application/octet-stream"
|
||||||
Form = "application/x-www-form-urlencoded"
|
Form = "application/x-www-form-urlencoded"
|
||||||
|
|
||||||
Header = "Header"
|
Header = "Header"
|
||||||
Query = "Query"
|
Query = "Query"
|
||||||
Body = "Body"
|
Body = "Body"
|
||||||
BodyJson = "Json"
|
Path = "Path"
|
||||||
Path = "Path"
|
|
||||||
|
|
||||||
TEST = "TEST"
|
TEST = "TEST"
|
||||||
PRE = "PRE"
|
PRE = "PRE"
|
||||||
@ -52,7 +50,7 @@ const (
|
|||||||
|
|
||||||
type Host struct {
|
type Host struct {
|
||||||
Default string
|
Default string
|
||||||
Func func(string, string) string
|
Func func(string) string
|
||||||
}
|
}
|
||||||
|
|
||||||
var debug utils.Debug
|
var debug utils.Debug
|
||||||
@ -82,8 +80,6 @@ type AcsRequest interface {
|
|||||||
InitWithApiInfo(domain Host, version, urlPath string)
|
InitWithApiInfo(domain Host, version, urlPath string)
|
||||||
GetEnv() string
|
GetEnv() string
|
||||||
SetEnv(string)
|
SetEnv(string)
|
||||||
GetArea() string
|
|
||||||
SetArea(string)
|
|
||||||
|
|
||||||
BuildUrl() string
|
BuildUrl() string
|
||||||
BuildQueries() string
|
BuildQueries() string
|
||||||
@ -98,7 +94,6 @@ type AcsRequest interface {
|
|||||||
AddHeaderParam(key, value string)
|
AddHeaderParam(key, value string)
|
||||||
addQueryParam(key, value string)
|
addQueryParam(key, value string)
|
||||||
addFormParam(key, value string)
|
addFormParam(key, value string)
|
||||||
addJsonParam(string, interface{})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type baseRequest struct {
|
type baseRequest struct {
|
||||||
@ -122,12 +117,10 @@ type baseRequest struct {
|
|||||||
QueryParams map[string]string
|
QueryParams map[string]string
|
||||||
Headers map[string]string
|
Headers map[string]string
|
||||||
FormParams map[string]string
|
FormParams map[string]string
|
||||||
JsonParams map[string]interface{}
|
|
||||||
Content []byte
|
Content []byte
|
||||||
|
|
||||||
queries string
|
queries string
|
||||||
stringToSign string
|
stringToSign string
|
||||||
area string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *baseRequest) GetEnv() string {
|
func (request *baseRequest) GetEnv() string {
|
||||||
@ -138,14 +131,6 @@ func (request *baseRequest) SetEnv(e string) {
|
|||||||
request.Env = e
|
request.Env = e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *baseRequest) GetArea() string {
|
|
||||||
return request.area
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *baseRequest) SetArea(area string) {
|
|
||||||
request.area = area
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *baseRequest) GetStringToSign() string {
|
func (request *baseRequest) GetStringToSign() string {
|
||||||
return request.stringToSign
|
return request.stringToSign
|
||||||
}
|
}
|
||||||
@ -244,10 +229,6 @@ func (request *baseRequest) addFormParam(key, val string) {
|
|||||||
request.FormParams[key] = val
|
request.FormParams[key] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *baseRequest) addJsonParam(key string, val interface{}) {
|
|
||||||
request.JsonParams[key] = val
|
|
||||||
}
|
|
||||||
|
|
||||||
func defaultBaseRequest() (request *baseRequest) {
|
func defaultBaseRequest() (request *baseRequest) {
|
||||||
request = &baseRequest{
|
request = &baseRequest{
|
||||||
Scheme: HTTP,
|
Scheme: HTTP,
|
||||||
@ -260,7 +241,6 @@ func defaultBaseRequest() (request *baseRequest) {
|
|||||||
"Accept-Encoding": Json,
|
"Accept-Encoding": Json,
|
||||||
},
|
},
|
||||||
FormParams: make(map[string]string),
|
FormParams: make(map[string]string),
|
||||||
JsonParams: make(map[string]interface{}),
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -309,14 +289,14 @@ func flatRepeatedList(reflectValue reflect.Value, request AcsRequest, position s
|
|||||||
value = fieldDefault
|
value = fieldDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
err = addParam(request, fieldPosition, name, value, reflectValue.Field(i).Interface())
|
err = addParam(request, fieldPosition, name, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func addParam(request AcsRequest, position, key, value string, vAny interface{}) (err error) {
|
func addParam(request AcsRequest, position, key, value string) (err error) {
|
||||||
if len(value) > 0 {
|
if len(value) > 0 {
|
||||||
switch position {
|
switch position {
|
||||||
case Header:
|
case Header:
|
||||||
@ -325,8 +305,6 @@ func addParam(request AcsRequest, position, key, value string, vAny interface{})
|
|||||||
request.addQueryParam(key, value)
|
request.addQueryParam(key, value)
|
||||||
case Body:
|
case Body:
|
||||||
request.addFormParam(key, value)
|
request.addFormParam(key, value)
|
||||||
case BodyJson:
|
|
||||||
request.addJsonParam(key, vAny)
|
|
||||||
default:
|
default:
|
||||||
errmsg := fmt.Sprintf("unsupport positions add param `%s`", position)
|
errmsg := fmt.Sprintf("unsupport positions add param `%s`", position)
|
||||||
err = errors.New(errmsg)
|
err = errors.New(errmsg)
|
||||||
|
@ -21,7 +21,7 @@ func (request *RpcRequest) BuildUrl() string {
|
|||||||
var hostname string
|
var hostname string
|
||||||
if request.Domain.Func == nil {
|
if request.Domain.Func == nil {
|
||||||
hostname = request.Domain.Default
|
hostname = request.Domain.Default
|
||||||
} else if hostname = request.Domain.Func(request.GetEnv(), request.GetArea()); hostname == "" {
|
} else if hostname = request.Domain.Func(request.GetEnv()); hostname == "" {
|
||||||
hostname = request.Domain.Default
|
hostname = request.Domain.Default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ const (
|
|||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
var HOST requests.Host = requests.Host{
|
||||||
Default: "c.api.gaore.com",
|
Default: "c.api.gaore.com",
|
||||||
Func: func(s string, area string) string {
|
Func: func(s string) string {
|
||||||
var a = map[string]string{
|
var a = map[string]string{
|
||||||
requests.RELEASE: "c.api.gaore.com",
|
requests.RELEASE: "c.api.gaore.com",
|
||||||
requests.PRE: "c.api.gaore.com",
|
requests.PRE: "c.api.gaore.com",
|
||||||
|
@ -11,7 +11,7 @@ const (
|
|||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
var HOST requests.Host = requests.Host{
|
||||||
Default: "callback.api.gaore.com",
|
Default: "callback.api.gaore.com",
|
||||||
Func: func(s string, area string) string {
|
Func: func(s string) string {
|
||||||
var a = map[string]string{
|
var a = map[string]string{
|
||||||
requests.RELEASE: "callback.api.gaore.com",
|
requests.RELEASE: "callback.api.gaore.com",
|
||||||
requests.PRE: "callback.api.gaore.com",
|
requests.PRE: "callback.api.gaore.com",
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
package ip
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2025-06-24"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST = requests.Host{
|
|
||||||
Default: "ip.gaore.com",
|
|
||||||
Func: func(s string, area string) string {
|
|
||||||
if area != "" {
|
|
||||||
fmt.Println("ip.gaore.com." + area)
|
|
||||||
return "ip.gaore.com." + area
|
|
||||||
}
|
|
||||||
return "ip.gaore.com.hk"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient(area string, env ...string) (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.InitWithArea(area, env...)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) CreateGetIpRequest(req *IpRequest) (resp *IpResponse, err error) {
|
|
||||||
resp = CreateIpResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) CreateGetIpsRequest(req *IpsRequest) (resp *IpsResponse, err error) {
|
|
||||||
resp = CreateIpsResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package ip
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 测试获取单个ip地区信息
|
|
||||||
func TestGetIp(t *testing.T) {
|
|
||||||
client, newErr := NewClient("hk")
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateIpRequest(IpParam{
|
|
||||||
Ip: "114.234.202.136",
|
|
||||||
})
|
|
||||||
res, doErr := client.CreateGetIpRequest(req)
|
|
||||||
if doErr != nil {
|
|
||||||
panic(doErr)
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("查询多个ip失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 测试获取多个ip地区信息
|
|
||||||
func TestGetIps(t *testing.T) {
|
|
||||||
client, newErr := NewClient("hk")
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateIpsRequest(IpsParam{
|
|
||||||
Ips: []string{
|
|
||||||
"2001:ee0:5208:e600:4c51:3189:28a4:b668",
|
|
||||||
"114.234.202.136",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
res, err := client.CreateGetIpsRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("查询多个ip失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
@ -1,100 +0,0 @@
|
|||||||
package ip
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type IpInfo struct {
|
|
||||||
Ip string `json:"ip"`
|
|
||||||
City string `json:"city"`
|
|
||||||
Province string `json:"province"`
|
|
||||||
Country string `json:"country"`
|
|
||||||
Isp string `json:"isp"`
|
|
||||||
Owner string `json:"owner"`
|
|
||||||
Continent string `json:"continent"`
|
|
||||||
Accuracy string `json:"accuracy"`
|
|
||||||
Adcode string `json:"adcode"`
|
|
||||||
Areacode string `json:"areacode"`
|
|
||||||
Asnumber string `json:"asnumber"`
|
|
||||||
Radius string `json:"radius"`
|
|
||||||
Latwgs string `json:"latwgs"`
|
|
||||||
Lngwgs string `json:"lngwgs"`
|
|
||||||
Source string `json:"source"`
|
|
||||||
Timezone string `json:"timezone"`
|
|
||||||
Zipcode string `json:"zipcode"`
|
|
||||||
District string `json:"district"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// IpsParam
|
|
||||||
// 单个ip请求参数
|
|
||||||
type IpParam struct {
|
|
||||||
Ip string `json:"ip"`
|
|
||||||
}
|
|
||||||
type IpRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
Ip string `position:"Json" field:"ip"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// IpResponse
|
|
||||||
// 单个ip返回参数
|
|
||||||
type IpResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data IpInfo `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateIpRequest
|
|
||||||
// 同时支持ipv4、ipv6格式查询
|
|
||||||
func CreateIpRequest(param IpParam) (req *IpRequest) {
|
|
||||||
req = &IpRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
Ip: param.Ip,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/getIp")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateIpResponse() (resp *IpResponse) {
|
|
||||||
resp = &IpResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 多个ip请求参数
|
|
||||||
type IpsParam struct {
|
|
||||||
Ips []string `json:"ips"`
|
|
||||||
}
|
|
||||||
type IpsRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
Ips []string `position:"Json" field:"ips"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// IpsResponse
|
|
||||||
// 多个ip返回参数
|
|
||||||
type IpsResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data map[string]IpInfo `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateIpsRequest
|
|
||||||
// 同时支持ipv4、ipv6格式查询
|
|
||||||
func CreateIpsRequest(param IpsParam) (req *IpsRequest) {
|
|
||||||
req = &IpsRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
Ips: param.Ips,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/getIps")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateIpsResponse() (resp *IpsResponse) {
|
|
||||||
resp = &IpsResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -12,7 +12,7 @@ const (
|
|||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
var HOST requests.Host = requests.Host{
|
||||||
Default: "jedi.api.gaore.com",
|
Default: "jedi.api.gaore.com",
|
||||||
Func: func(s string, area string) string {
|
Func: func(s string) string {
|
||||||
var a = map[string]string{
|
var a = map[string]string{
|
||||||
requests.RELEASE: "jedi.api.gaore.com",
|
requests.RELEASE: "jedi.api.gaore.com",
|
||||||
requests.PRE: "jedi.api.gaore.com",
|
requests.PRE: "jedi.api.gaore.com",
|
||||||
|
@ -14,7 +14,7 @@ const (
|
|||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
var HOST requests.Host = requests.Host{
|
||||||
Default: "mail.gaore.com",
|
Default: "mail.gaore.com",
|
||||||
Func: func(s string, area string) string {
|
Func: func(s string) string {
|
||||||
var a = map[string]string{
|
var a = map[string]string{
|
||||||
requests.RELEASE: "mail.gaore.com",
|
requests.RELEASE: "mail.gaore.com",
|
||||||
requests.PRE: "mail.gaore.com",
|
requests.PRE: "mail.gaore.com",
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
package msdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2023-03-16"
|
|
||||||
KEY = "gaore!@#msdk"
|
|
||||||
)
|
|
||||||
|
|
||||||
var Host = requests.Host{
|
|
||||||
Default: "msdk.api.gaore.com.hk",
|
|
||||||
Func: func(s string, area string) string {
|
|
||||||
if area != "" {
|
|
||||||
fmt.Println("msdk.api.gaore.com." + area)
|
|
||||||
return "msdk.api.gaore.com." + area
|
|
||||||
}
|
|
||||||
return "msdk.api.gaore.com.hk"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
ident string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) UpdateAdjustId(req *UpdateAdjustIdRequest) (resp *UpdateAdjustIdResponse, err error) {
|
|
||||||
resp = CreateUpdateAdjustIdResponse()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient(area string, env ...string) (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.InitWithArea(area, env...)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package msdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestClient_UpdateAdjustId(t *testing.T) {
|
|
||||||
|
|
||||||
req := CreateUpdateAdjustIdRequest()
|
|
||||||
req.AdjustId = "8834ca659b22316354e9e9d6dd6b1904"
|
|
||||||
req.Username = "xn94941370"
|
|
||||||
req.GameSign = "testcw"
|
|
||||||
req.LongId = "ba19fc578664f7c73c424b4c2919f9d1"
|
|
||||||
req.GameId = 10002
|
|
||||||
req.RegTime = 1678949413
|
|
||||||
req.Os = "ios"
|
|
||||||
req.MakeSign()
|
|
||||||
client, _ := NewClient("hk")
|
|
||||||
resp, err := client.UpdateAdjustId(req)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println(resp.Msg)
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package msdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/md5"
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/responses"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type UpdateAdjustIdRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
LongId string `position:"Body" field:"long_id" default:""`
|
|
||||||
GameId int `position:"Body" field:"game_id" default:"0"`
|
|
||||||
Username string `position:"Body" field:"username" default:""`
|
|
||||||
GameSign string `position:"Body" field:"game_sign" default:""`
|
|
||||||
RegTime int64 `position:"Body" field:"reg_time" default:"0"`
|
|
||||||
Os string `position:"Body" field:"os" default:""`
|
|
||||||
AdjustId string `position:"Body" field:"adjust_id" default:""`
|
|
||||||
ts int64 `position:"Body" field:"ts" default:"0"`
|
|
||||||
sign string `position:"Body" field:"sign" default:""`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *UpdateAdjustIdRequest) MakeSign() {
|
|
||||||
u.ts = time.Now().Unix()
|
|
||||||
rawStr := fmt.Sprintf("%d%s%s%d%s", u.GameId, u.LongId, u.Username, u.ts, KEY)
|
|
||||||
sign := md5.Sum([]byte(rawStr))
|
|
||||||
u.sign = fmt.Sprintf("%x", sign)
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpdateAdjustIdResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Ret int `json:"ret"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateUpdateAdjustIdRequest() (req *UpdateAdjustIdRequest) {
|
|
||||||
req = &UpdateAdjustIdRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.ts = time.Now().Unix()
|
|
||||||
req.InitWithApiInfo(Host, VERSION, "/updateAdjustId.php")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateUpdateAdjustIdResponse() (resp *UpdateAdjustIdResponse) {
|
|
||||||
resp = &UpdateAdjustIdResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package passport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2023-04-18"
|
|
||||||
KEY = "#gr*%com#"
|
|
||||||
)
|
|
||||||
|
|
||||||
var Host = requests.Host{
|
|
||||||
Default: "passport.gaore.com.hk",
|
|
||||||
Func: func(s string, area string) string {
|
|
||||||
if area != "" {
|
|
||||||
fmt.Println("passport.gaore.com." + area)
|
|
||||||
return "passport.gaore.com." + area
|
|
||||||
}
|
|
||||||
return "passport.gaore.com.hk"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
ident string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GetRegDeviceByUsers(req *RegDeviceRequest) (resp *RegDeviceResponse, err error) {
|
|
||||||
resp = CreateRegDeviceResponse()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient(area string, env ...string) (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.InitWithArea(area, env...)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package passport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestInfo(t *testing.T) {
|
|
||||||
client, err := NewClient("hk")
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req := CreateRegDeviceRequest("dv35054132", "zf43712598")
|
|
||||||
|
|
||||||
resp, err := client.GetRegDeviceByUsers(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
fmt.Println(resp.Data)
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package passport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/md5"
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/responses"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type RegDeviceRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
do string `position:"Body" field:"do" default:""`
|
|
||||||
act string `position:"Body" field:"act" default:""`
|
|
||||||
time int64 `position:"Body" field:"time" default:"0"`
|
|
||||||
sign string `position:"Body" field:"sign" default:""`
|
|
||||||
users string `position:"Body" field:"username" default:""`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *RegDeviceRequest) getSign() {
|
|
||||||
b.time = time.Now().Unix()
|
|
||||||
rawStr := fmt.Sprintf("%d%s", b.time, KEY)
|
|
||||||
sign := md5.Sum([]byte(rawStr))
|
|
||||||
b.sign = fmt.Sprintf("%x", sign)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *RegDeviceRequest) initRemoteLoginRequest() {
|
|
||||||
b.InitWithApiInfo(Host, VERSION, "/remote_login.php")
|
|
||||||
b.Method = requests.POST
|
|
||||||
}
|
|
||||||
|
|
||||||
type RegDeviceResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []struct {
|
|
||||||
DeviceId string `json:"imei"`
|
|
||||||
Idfa string `json:"imei2"`
|
|
||||||
ChannelDeviceId string `json:"channel_device_id"`
|
|
||||||
Uid int64 `json:"uid"`
|
|
||||||
UserName string `json:"user_name"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateRegDeviceRequest(users ...string) (req *RegDeviceRequest) {
|
|
||||||
req = &RegDeviceRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
|
|
||||||
req.getSign()
|
|
||||||
req.users = strings.Join(users, ",")
|
|
||||||
req.do = "get_reg_device_by_username"
|
|
||||||
req.act = "info"
|
|
||||||
req.initRemoteLoginRequest()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateRegDeviceResponse() (resp *RegDeviceResponse) {
|
|
||||||
return &RegDeviceResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,11 @@
|
|||||||
package sso
|
package sso
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk"
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk"
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -11,11 +14,11 @@ const (
|
|||||||
|
|
||||||
var HOST = requests.Host{
|
var HOST = requests.Host{
|
||||||
Default: "sso",
|
Default: "sso",
|
||||||
Func: func(s string, area string) string {
|
Func: func(s string) string {
|
||||||
host := map[string]string{
|
host := map[string]string{
|
||||||
requests.RELEASE: "sso.gaore.com.hk",
|
requests.RELEASE: "sso.gaore.com.hk",
|
||||||
requests.PRE: "sso.gaore.com.hk",
|
requests.PRE: "sso.gaore.com",
|
||||||
requests.TEST: "sso.gaore.com.hk",
|
requests.TEST: "sso.gaore.com",
|
||||||
}
|
}
|
||||||
if s, ok := host[s]; ok {
|
if s, ok := host[s]; ok {
|
||||||
return s
|
return s
|
||||||
@ -54,6 +57,34 @@ func (c *Client) SearchUser(req *SearchUserRequest) (response *SearchUserRespons
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) GetLoginUrl(redirectUrl string, env ...string) string {
|
||||||
|
uri := fmt.Sprintf("/admin/main/login?ident=%s&redirectUrl=%s", c.ident, url.QueryEscape(redirectUrl))
|
||||||
|
scheme, host := c.getSchemeAndHost(env...)
|
||||||
|
return fmt.Sprintf("%s://%s%s", scheme, host, uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) GetLogout(env ...string) string {
|
||||||
|
uri := fmt.Sprintf("/admin/main/logout?ident=%s&redirectUrl=", c.ident)
|
||||||
|
scheme, host := c.getSchemeAndHost(env...)
|
||||||
|
return fmt.Sprintf("%s://%s%s", scheme, host, uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) getSchemeAndHost(env ...string) (scheme, host string) {
|
||||||
|
rEnv := requests.RELEASE
|
||||||
|
if len(env) >= 1 {
|
||||||
|
rEnv = env[0]
|
||||||
|
}
|
||||||
|
host = HOST.Func(rEnv)
|
||||||
|
|
||||||
|
if rEnv == requests.RELEASE {
|
||||||
|
scheme = requests.HTTPS
|
||||||
|
} else {
|
||||||
|
scheme = requests.HTTP
|
||||||
|
}
|
||||||
|
scheme = strings.ToLower(scheme)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) {
|
func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) {
|
||||||
client = &Client{}
|
client = &Client{}
|
||||||
client.ident = source
|
client.ident = source
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package sso
|
package sso
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLoginUrl(t *testing.T) {
|
func TestLoginUrl(t *testing.T) {
|
||||||
t.Log(GetLoginUrl("stat.gaore.com.hk", "http://stat.gaore.com.hk/web/user/login"))
|
c, _ := NewClientWithAccessKey("stat.gaore.com.hk", "", "stat_gaore_com_hk")
|
||||||
}
|
t.Log(c.GetLoginUrl("http://stat.gaore.com.hk/web/user/login", requests.TEST))
|
||||||
|
|
||||||
func TestClient_CodeAuth(t *testing.T) {
|
|
||||||
}
|
}
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
package sso
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
|
||||||
"net/url"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetLoginUrl(ident string, redirectUrl string, env ...string) string {
|
|
||||||
uri := fmt.Sprintf("/admin/main/login?ident=%s&redirectUrl=%s", ident, url.QueryEscape(redirectUrl))
|
|
||||||
scheme, host := getSchemeAndHost(env...)
|
|
||||||
return fmt.Sprintf("%s://%s%s", scheme, host, uri)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetLogoutUrl(ident string, redirectUrl string, env ...string) string {
|
|
||||||
uri := fmt.Sprintf("/admin/main/loginOut?ident=%s&redirectUrl=%s", ident, url.QueryEscape(redirectUrl))
|
|
||||||
scheme, host := getSchemeAndHost(env...)
|
|
||||||
return fmt.Sprintf("%s://%s%s", scheme, host, uri)
|
|
||||||
}
|
|
||||||
|
|
||||||
func getSchemeAndHost(env ...string) (scheme, host string) {
|
|
||||||
env = append(env, requests.RELEASE)
|
|
||||||
host = HOST.Func(env[0], "")
|
|
||||||
scheme = strings.ToLower(requests.HTTPS)
|
|
||||||
return
|
|
||||||
}
|
|
@ -6,18 +6,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "2023-03-16"
|
VERSION = "2020-09-24"
|
||||||
KEY = "gaore!@#apisdk"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
var HOST requests.Host = requests.Host{
|
||||||
Default: "apisdk.gaore.com.hk",
|
Default: "apisdk.9ooo.cn",
|
||||||
Func: func(s string, area string) string {
|
Func: func(s string) string {
|
||||||
defHost := "apisdk.gaore.com"
|
var a = map[string]string{
|
||||||
if area != "" {
|
requests.RELEASE: "apisdk.9ooo.cn",
|
||||||
return defHost + "." + area
|
requests.PRE: "apisdk.9ooo.cn",
|
||||||
|
requests.TEST: "apisdk.9ooo.cn",
|
||||||
}
|
}
|
||||||
return ""
|
return a[s]
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,15 +42,3 @@ func (c *Client) GetUserInfo(req *GetPwdRequest) (response *GetPwdResponse, err
|
|||||||
err = c.DoAction(req, response)
|
err = c.DoAction(req, response)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UpdateAdjustId(req *UpdateAdjustIdRequest) (resp *UpdateAdjustIdResponse, err error) {
|
|
||||||
resp = CreateUpdateAdjustIdResponse()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient(area string, env ...string) (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.InitWithArea(area, env...)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
@ -23,23 +23,3 @@ func TestClient_GetUserInfo(t *testing.T) {
|
|||||||
fmt.Println(resp.GetHttpContentString())
|
fmt.Println(resp.GetHttpContentString())
|
||||||
fmt.Println(resp.GetHttpHeaders())
|
fmt.Println(resp.GetHttpHeaders())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_UpdateAdjustId(t *testing.T) {
|
|
||||||
req := CreateUpdateAdjustIdRequest()
|
|
||||||
req.AdjustId = "8834ca659b22316354e9e9d6dd6b1904"
|
|
||||||
req.Username = "xn94941370"
|
|
||||||
req.GameId = 10002
|
|
||||||
req.RegTime = 1678949413
|
|
||||||
req.MakeSign()
|
|
||||||
c, err := NewClient("hk", "")
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, err := c.UpdateAdjustId(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(resp)
|
|
||||||
}
|
|
||||||
|
1
services/www/get_token.go
Normal file
1
services/www/get_token.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package www
|
@ -1,52 +0,0 @@
|
|||||||
package www
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/md5"
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/responses"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type UpdateAdjustIdRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
LongId string `position:"Body" field:"long_id" default:""`
|
|
||||||
GameId int `position:"Body" field:"game_id" default:"0"`
|
|
||||||
Username string `position:"Body" field:"username" default:""`
|
|
||||||
GameSign string `position:"Body" field:"game_sign" default:""`
|
|
||||||
RegTime int64 `position:"Body" field:"reg_time" default:"0"`
|
|
||||||
Os string `position:"Body" field:"os" default:""`
|
|
||||||
AdjustId string `position:"Body" field:"adjust_id" default:""`
|
|
||||||
ts int64 `position:"Body" field:"ts" default:"0"`
|
|
||||||
sign string `position:"Body" field:"sign" default:""`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *UpdateAdjustIdRequest) MakeSign() {
|
|
||||||
u.ts = time.Now().Unix()
|
|
||||||
rawStr := fmt.Sprintf("%s%d%d%s", u.Username, u.GameId, u.ts, KEY)
|
|
||||||
sign := md5.Sum([]byte(rawStr))
|
|
||||||
u.sign = fmt.Sprintf("%x", sign)
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpdateAdjustIdResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Ret int `json:"ret"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateUpdateAdjustIdRequest() (req *UpdateAdjustIdRequest) {
|
|
||||||
req = &UpdateAdjustIdRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.ts = time.Now().Unix()
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/user/updateAdjustId.php")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateUpdateAdjustIdResponse() (resp *UpdateAdjustIdResponse) {
|
|
||||||
resp = &UpdateAdjustIdResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user