新增补充adjustId方法

Bu işleme şunda yer alıyor:
余 欣怀 2023-03-16 20:15:17 +08:00
ebeveyn 9710c9ddd7
işleme f0fe02d420
18 değiştirilmiş dosya ile 261 ekleme ve 26 silme

Dosyayı Görüntüle

@ -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

Dosyayı Görüntüle

@ -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

Dosyayı Görüntüle

@ -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 {

Dosyayı Görüntüle

@ -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
}

Dosyayı Görüntüle

@ -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
}

Dosyayı Görüntüle

@ -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",

Dosyayı Görüntüle

@ -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",

Dosyayı Görüntüle

@ -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",

Dosyayı Görüntüle

@ -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 dosya
Dosyayı Görüntüle

@ -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
}

Dosyayı Görüntüle

@ -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)
}

Dosyayı Görüntüle

@ -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
}

Dosyayı Görüntüle

@ -14,7 +14,7 @@ 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",
@ -74,7 +74,7 @@ func (c Client) getSchemeAndHost(env ...string) (scheme, host string) {
if len(env) >= 1 {
rEnv = env[0]
}
host = HOST.Func(rEnv)
host = HOST.Func(rEnv, "")
if rEnv == requests.RELEASE {
scheme = requests.HTTPS

Dosyayı Görüntüle

@ -9,3 +9,6 @@ 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))
}
func TestClient_CodeAuth(t *testing.T) {
}

Dosyayı Görüntüle

@ -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
}

Dosyayı Görüntüle

@ -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)
}

Dosyayı Görüntüle

@ -1 +0,0 @@
package www

Dosyayı Görüntüle

@ -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
}