Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
10283347b6 | |||
67b30db9b4 | |||
daadddc8a2 | |||
9a2e21d646 | |||
710f74a50c | |||
f0fe02d420 |
@ -25,7 +25,13 @@ func signRpcRequest(request requests.AcsRequest, signer Signer) (err error) {
|
||||
stringToSign := buildRpcStringToSign(request)
|
||||
request.SetStringToSign(stringToSign)
|
||||
signature := signer.Sign(stringToSign, "&")
|
||||
request.GetQueryParams()["sign"] = signature
|
||||
accessKeyForm, err := signer.GetAccessKeyFrom()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if accessKeyForm != "" {
|
||||
request.GetQueryParams()["sign"] = signature
|
||||
}
|
||||
debug("GrSdk sign: %s", signature)
|
||||
debug("GrSdk sign string: %s", stringToSign)
|
||||
debug("GrSdk sign: \r\n")
|
||||
@ -38,18 +44,19 @@ func completeRpcSignParams(request requests.AcsRequest, signer Signer) (err erro
|
||||
if accessKeyFrom, err = signer.GetAccessKeyFrom(); err != nil {
|
||||
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
|
||||
|
||||
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
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
request.GetHeaders()["Gr-Sdk-From"] = accessKeyFrom
|
||||
}
|
||||
|
||||
request.GetHeaders()["Content-type"] = requests.Form
|
||||
request.GetHeaders()["Gr-Sdk-From"] = accessKeyFrom
|
||||
formString := utils.GetUrlFormedMap(request.GetFormParams())
|
||||
request.SetContent(bytes.NewBufferString(formString).Bytes())
|
||||
return
|
||||
|
@ -83,6 +83,15 @@ 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) {
|
||||
config := client.InitWithConfig()
|
||||
credential := &credentials.BaseCredential{
|
||||
@ -279,6 +288,10 @@ func (client *Client) buildRequestWithSigner(request requests.AcsRequest, signer
|
||||
request.SetEnv(client.config.Env)
|
||||
}
|
||||
|
||||
if request.GetArea() == "" && client.config.Area != "" {
|
||||
request.SetArea(client.config.Area)
|
||||
}
|
||||
|
||||
err = requests.InitParam(request)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -15,6 +15,7 @@ type Config struct {
|
||||
Scheme string `default:"HTTP"`
|
||||
Timeout time.Duration `default:"5"`
|
||||
Env string `default:""`
|
||||
Area string `default:""`
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
|
@ -50,7 +50,7 @@ const (
|
||||
|
||||
type Host struct {
|
||||
Default string
|
||||
Func func(string) string
|
||||
Func func(string, string) string
|
||||
}
|
||||
|
||||
var debug utils.Debug
|
||||
@ -80,6 +80,8 @@ type AcsRequest interface {
|
||||
InitWithApiInfo(domain Host, version, urlPath string)
|
||||
GetEnv() string
|
||||
SetEnv(string)
|
||||
GetArea() string
|
||||
SetArea(string)
|
||||
|
||||
BuildUrl() string
|
||||
BuildQueries() string
|
||||
@ -121,6 +123,7 @@ type baseRequest struct {
|
||||
|
||||
queries string
|
||||
stringToSign string
|
||||
area string
|
||||
}
|
||||
|
||||
func (request *baseRequest) GetEnv() string {
|
||||
@ -131,6 +134,14 @@ func (request *baseRequest) SetEnv(e string) {
|
||||
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 {
|
||||
return request.stringToSign
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ func (request *RpcRequest) BuildUrl() string {
|
||||
var hostname string
|
||||
if request.Domain.Func == nil {
|
||||
hostname = request.Domain.Default
|
||||
} else if hostname = request.Domain.Func(request.GetEnv()); hostname == "" {
|
||||
} else if hostname = request.Domain.Func(request.GetEnv(), request.GetArea()); hostname == "" {
|
||||
hostname = request.Domain.Default
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ const (
|
||||
|
||||
var HOST requests.Host = requests.Host{
|
||||
Default: "c.api.gaore.com",
|
||||
Func: func(s string) string {
|
||||
Func: func(s string, area string) string {
|
||||
var a = map[string]string{
|
||||
requests.RELEASE: "c.api.gaore.com",
|
||||
requests.PRE: "c.api.gaore.com",
|
||||
|
@ -11,7 +11,7 @@ const (
|
||||
|
||||
var HOST requests.Host = requests.Host{
|
||||
Default: "callback.api.gaore.com",
|
||||
Func: func(s string) string {
|
||||
Func: func(s string, area string) string {
|
||||
var a = map[string]string{
|
||||
requests.RELEASE: "callback.api.gaore.com",
|
||||
requests.PRE: "callback.api.gaore.com",
|
||||
|
@ -12,7 +12,7 @@ const (
|
||||
|
||||
var HOST requests.Host = requests.Host{
|
||||
Default: "jedi.api.gaore.com",
|
||||
Func: func(s string) string {
|
||||
Func: func(s string, area string) string {
|
||||
var a = map[string]string{
|
||||
requests.RELEASE: "jedi.api.gaore.com",
|
||||
requests.PRE: "jedi.api.gaore.com",
|
||||
|
@ -14,7 +14,7 @@ const (
|
||||
|
||||
var HOST requests.Host = requests.Host{
|
||||
Default: "mail.gaore.com",
|
||||
Func: func(s string) string {
|
||||
Func: func(s string, area string) string {
|
||||
var a = map[string]string{
|
||||
requests.RELEASE: "mail.gaore.com",
|
||||
requests.PRE: "mail.gaore.com",
|
||||
|
40
services/msdk/client.go
Normal file
40
services/msdk/client.go
Normal file
@ -0,0 +1,40 @@
|
||||
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
|
||||
}
|
25
services/msdk/client_test.go
Normal file
25
services/msdk/client_test.go
Normal file
@ -0,0 +1,25 @@
|
||||
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)
|
||||
}
|
52
services/msdk/update_adjustid.go
Normal file
52
services/msdk/update_adjustid.go
Normal file
@ -0,0 +1,52 @@
|
||||
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
|
||||
}
|
40
services/passport/client.go
Normal file
40
services/passport/client.go
Normal file
@ -0,0 +1,40 @@
|
||||
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
|
||||
}
|
21
services/passport/client_test.go
Normal file
21
services/passport/client_test.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
63
services/passport/info.go
Normal file
63
services/passport/info.go
Normal file
@ -0,0 +1,63 @@
|
||||
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,11 +1,8 @@
|
||||
package sso
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk"
|
||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -14,11 +11,11 @@ const (
|
||||
|
||||
var HOST = requests.Host{
|
||||
Default: "sso",
|
||||
Func: func(s string) string {
|
||||
Func: func(s string, area string) string {
|
||||
host := map[string]string{
|
||||
requests.RELEASE: "sso.gaore.com.hk",
|
||||
requests.PRE: "sso.gaore.com",
|
||||
requests.TEST: "sso.gaore.com",
|
||||
requests.PRE: "sso.gaore.com.hk",
|
||||
requests.TEST: "sso.gaore.com.hk",
|
||||
}
|
||||
if s, ok := host[s]; ok {
|
||||
return s
|
||||
@ -57,34 +54,6 @@ func (c *Client) SearchUser(req *SearchUserRequest) (response *SearchUserRespons
|
||||
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) {
|
||||
client = &Client{}
|
||||
client.ident = source
|
||||
|
@ -1,11 +1,12 @@
|
||||
package sso
|
||||
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoginUrl(t *testing.T) {
|
||||
c, _ := NewClientWithAccessKey("stat.gaore.com.hk", "", "stat_gaore_com_hk")
|
||||
t.Log(c.GetLoginUrl("http://stat.gaore.com.hk/web/user/login", requests.TEST))
|
||||
t.Log(GetLoginUrl("stat.gaore.com.hk", "http://stat.gaore.com.hk/web/user/login"))
|
||||
}
|
||||
|
||||
func TestClient_CodeAuth(t *testing.T) {
|
||||
}
|
||||
|
27
services/sso/url.go
Normal file
27
services/sso/url.go
Normal file
@ -0,0 +1,27 @@
|
||||
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 (
|
||||
VERSION = "2020-09-24"
|
||||
VERSION = "2023-03-16"
|
||||
KEY = "gaore!@#apisdk"
|
||||
)
|
||||
|
||||
var HOST requests.Host = requests.Host{
|
||||
Default: "apisdk.9ooo.cn",
|
||||
Func: func(s string) string {
|
||||
var a = map[string]string{
|
||||
requests.RELEASE: "apisdk.9ooo.cn",
|
||||
requests.PRE: "apisdk.9ooo.cn",
|
||||
requests.TEST: "apisdk.9ooo.cn",
|
||||
Default: "apisdk.gaore.com.hk",
|
||||
Func: func(s string, area string) string {
|
||||
defHost := "apisdk.gaore.com"
|
||||
if area != "" {
|
||||
return defHost + "." + area
|
||||
}
|
||||
return a[s]
|
||||
return ""
|
||||
},
|
||||
}
|
||||
|
||||
@ -42,3 +42,15 @@ func (c *Client) GetUserInfo(req *GetPwdRequest) (response *GetPwdResponse, err
|
||||
err = c.DoAction(req, response)
|
||||
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,3 +23,23 @@ func TestClient_GetUserInfo(t *testing.T) {
|
||||
fmt.Println(resp.GetHttpContentString())
|
||||
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 +0,0 @@
|
||||
package www
|
52
services/www/update_adjustid.go
Normal file
52
services/www/update_adjustid.go
Normal file
@ -0,0 +1,52 @@
|
||||
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