Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
5a8de98af3 | |||
6c3dfae18b | |||
b29010cac6 | |||
792d13fa32 | |||
ce30ff4ef9 | |||
78d60083f7 | |||
bee78a0b12 | |||
c582fbf8ed | |||
|
14551a66b4 | ||
d8528ecbe8 | |||
b7bf3c7585 | |||
|
eae413bc00 | ||
631959c0ec | |||
4a8d29f57f | |||
4f63f8f302 | |||
956e294a2f | |||
30afd2cbe1 | |||
517d422993 | |||
721b735a0e | |||
e89f227e54 | |||
1902a769f8 | |||
857f7b9f90 | |||
5d941b865b | |||
e26c54c474 | |||
|
a7a0099cb8 | ||
|
e3cfca5bfa |
10
go.mod
Normal file
10
go.mod
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module golib.gaore.com/GaoreGo/gaore-common-sdk-go
|
||||||
|
|
||||||
|
go 1.19
|
||||||
|
|
||||||
|
require github.com/json-iterator/go v1.1.12
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
)
|
15
go.sum
Normal file
15
go.sum
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/json-iterator/go/extra"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/auth"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/auth"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/auth/credentials"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/auth/credentials"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
@ -18,6 +19,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -359,3 +361,10 @@ func (client *Client) getNoProxy(scheme string) []string {
|
|||||||
func hookDo(fn func(req *http.Request) (*http.Response, error)) func(req *http.Request) (*http.Response, error) {
|
func hookDo(fn func(req *http.Request) (*http.Response, error)) func(req *http.Request) (*http.Response, error) {
|
||||||
return fn
|
return fn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
once := sync.Once{}
|
||||||
|
once.Do(func() {
|
||||||
|
extra.RegisterFuzzyDecoders()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -15,6 +15,7 @@ type JsonRequest struct {
|
|||||||
|
|
||||||
func (request *JsonRequest) init() {
|
func (request *JsonRequest) init() {
|
||||||
request.baseRequest = defaultBaseRequest()
|
request.baseRequest = defaultBaseRequest()
|
||||||
|
request.baseRequest.AddHeaderParam("Content-Type", Json)
|
||||||
request.Method = POST
|
request.Method = POST
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,12 +36,16 @@ func (request *JsonRequest) BuildUrl() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (request *JsonRequest) GetStyle() string {
|
func (request *JsonRequest) GetStyle() string {
|
||||||
return RPC
|
return STREAM
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *JsonRequest) BuildQueries() string {
|
func (request *JsonRequest) BuildQueries() string {
|
||||||
path := strings.TrimLeft(strings.TrimSpace(request.GetActionName()), "/")
|
path := strings.TrimLeft(strings.TrimSpace(request.GetActionName()), "/")
|
||||||
request.queries = "/" + path + "?" + utils.GetUrlFormedMap(request.QueryParams)
|
mod := "&"
|
||||||
|
if !strings.Contains(path, "?") {
|
||||||
|
mod = "?"
|
||||||
|
}
|
||||||
|
request.queries = "/" + path + mod + utils.GetUrlFormedMap(request.QueryParams)
|
||||||
return request.queries
|
return request.queries
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,8 +61,8 @@ func (request *JsonRequest) InitWithApiInfo(domain Host, version, urlPath string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (request *JsonRequest) GetBodyReader() io.Reader {
|
func (request *JsonRequest) GetBodyReader() io.Reader {
|
||||||
if request.FormParams != nil && len(request.FormParams) > 0 {
|
if request.JsonParams != nil && len(request.JsonParams) > 0 {
|
||||||
body, err := json.Marshal(request.FormParams)
|
body, err := json.Marshal(request.JsonParams)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return bytes.NewReader(body)
|
return bytes.NewReader(body)
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,12 @@ const (
|
|||||||
Xml = "application/xml"
|
Xml = "application/xml"
|
||||||
Raw = "application/octet-stream"
|
Raw = "application/octet-stream"
|
||||||
Form = "application/x-www-form-urlencoded"
|
Form = "application/x-www-form-urlencoded"
|
||||||
|
FormData = "multipart/form-data"
|
||||||
|
|
||||||
Header = "Header"
|
Header = "Header"
|
||||||
Query = "Query"
|
Query = "Query"
|
||||||
Body = "Body"
|
Body = "Body"
|
||||||
|
BodyJson = "Json"
|
||||||
Path = "Path"
|
Path = "Path"
|
||||||
|
|
||||||
TEST = "TEST"
|
TEST = "TEST"
|
||||||
@ -95,6 +97,7 @@ 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, any)
|
||||||
}
|
}
|
||||||
|
|
||||||
type baseRequest struct {
|
type baseRequest struct {
|
||||||
@ -118,6 +121,7 @@ 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]any
|
||||||
Content []byte
|
Content []byte
|
||||||
|
|
||||||
queries string
|
queries string
|
||||||
@ -230,6 +234,10 @@ func (request *baseRequest) addFormParam(key, val string) {
|
|||||||
request.FormParams[key] = val
|
request.FormParams[key] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (request *baseRequest) addJsonParam(key string, val any) {
|
||||||
|
request.JsonParams[key] = val
|
||||||
|
}
|
||||||
|
|
||||||
func defaultBaseRequest() (request *baseRequest) {
|
func defaultBaseRequest() (request *baseRequest) {
|
||||||
request = &baseRequest{
|
request = &baseRequest{
|
||||||
Scheme: HTTP,
|
Scheme: HTTP,
|
||||||
@ -242,6 +250,7 @@ func defaultBaseRequest() (request *baseRequest) {
|
|||||||
"Accept-Encoding": Json,
|
"Accept-Encoding": Json,
|
||||||
},
|
},
|
||||||
FormParams: make(map[string]string),
|
FormParams: make(map[string]string),
|
||||||
|
JsonParams: make(map[string]any),
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -290,14 +299,14 @@ func flatRepeatedList(reflectValue reflect.Value, request AcsRequest, position s
|
|||||||
value = fieldDefault
|
value = fieldDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
err = addParam(request, fieldPosition, name, value)
|
err = addParam(request, fieldPosition, name, value, reflectValue.Field(i).Interface())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func addParam(request AcsRequest, position, key, value string) (err error) {
|
func addParam(request AcsRequest, position, key, value string, vAny any) (err error) {
|
||||||
if len(value) > 0 {
|
if len(value) > 0 {
|
||||||
switch position {
|
switch position {
|
||||||
case Header:
|
case Header:
|
||||||
@ -306,6 +315,8 @@ func addParam(request AcsRequest, position, key, value string) (err error) {
|
|||||||
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)
|
||||||
|
@ -13,6 +13,7 @@ type RpcRequest struct {
|
|||||||
|
|
||||||
func (request *RpcRequest) init() {
|
func (request *RpcRequest) init() {
|
||||||
request.baseRequest = defaultBaseRequest()
|
request.baseRequest = defaultBaseRequest()
|
||||||
|
request.baseRequest.AddHeaderParam("Content-Type", Form)
|
||||||
request.Method = POST
|
request.Method = POST
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ type StreamRequest struct {
|
|||||||
|
|
||||||
func (s *StreamRequest) init() {
|
func (s *StreamRequest) init() {
|
||||||
s.baseRequest = defaultBaseRequest()
|
s.baseRequest = defaultBaseRequest()
|
||||||
s.baseRequest.AddHeaderParam("Content-Type", "application/form-data")
|
s.baseRequest.AddHeaderParam("Content-Type", FormData)
|
||||||
s.Method = POST
|
s.Method = POST
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package responses
|
package responses
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/json-iterator/go"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -97,7 +97,10 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
|
|||||||
if contentType, ok := response.GetHttpHeaders()["Content-Type"]; ok {
|
if contentType, ok := response.GetHttpHeaders()["Content-Type"]; ok {
|
||||||
for _, v := range contentType {
|
for _, v := range contentType {
|
||||||
if strings.Contains(v, requests.Json) {
|
if strings.Contains(v, requests.Json) {
|
||||||
json.Unmarshal(response.GetHttpContentBytes(), response)
|
err = jsoniter.Unmarshal(response.GetHttpContentBytes(), response)
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("json Unmarshal:" + err.Error())
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,7 +111,7 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if format != "xml" {
|
if format != "xml" {
|
||||||
err = json.Unmarshal(response.GetHttpContentBytes(), response)
|
err = jsoniter.Unmarshal(response.GetHttpContentBytes(), response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("json Unmarshal:" + err.Error())
|
return errors.New("json Unmarshal:" + err.Error())
|
||||||
}
|
}
|
||||||
|
42
services/capk/client.go
Normal file
42
services/capk/client.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package capk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "2024-10-30"
|
||||||
|
)
|
||||||
|
|
||||||
|
var HOST requests.Host = requests.Host{
|
||||||
|
Default: "capk.gaore.com",
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
sdk.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient() (client *Client, err error) {
|
||||||
|
client = new(Client)
|
||||||
|
err = client.Init()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) TaskCreate(req *TaskCreateRequest) (resp *TaskCreateResponse, err error) {
|
||||||
|
resp = CreateTaskCreateResponse()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) ConfigModify(req *ConfigModifyRequest) (resp *ConfigModifyResponse, err error) {
|
||||||
|
resp = CreateConfigModifyResponse()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) ConfigGet(req *ConfigGetRequest) (resp *ConfigGetResponse, err error) {
|
||||||
|
resp = CreateConfigGetResponse()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
39
services/capk/client_test.go
Normal file
39
services/capk/client_test.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package capk
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestTask_Create(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req := CreateTaskCreateRequest()
|
||||||
|
req.GameId = 7788
|
||||||
|
req.GameVersion = "1.0.1"
|
||||||
|
req.Config = "{\"data\":{\"sdkPath\":\"\",\"localPath\":\"\",\"plugins\":{\"addictioncheck\":\"\",\"msaid\":\"\",\"bugly\":\"\",\"gdt\":\"\",\"gdt_channel\":\"\"},\"decompileApk\":\"\"},\"game\":{\"appID\":\"7477\",\"appName\":\"xyxmz_xlhh_ylh\",\"appKey\":\"yWpx3hWQHFhSnTCj#7477#6KuRKuaAjLJ5sYRy\",\"appDescNew\":\"西游仙魔传\",\"orientation\":\"landscape\",\"cpuSupport\":\"armeabi-v7a|arm64-v8a\",\"minSdkVersion\":\"21\",\"targetSdkVersion\":\"31\",\"outputApkName\":\"{appName}_{appID}_{versionCode}_{versionName}_{time}.apk\",\"gameCategory\":\"25|771-2.0.4.3\",\"icon\":\"\",\"logoPath\":\"\",\"loadingPath\":\"\",\"certificatePath\":\"\"},\"channel\":{\"id\":\"1\",\"name\":\"gaore\",\"sdk\":\"gaore\",\"desc\":\"GRSDK\",\"suffix\":\"com.bjhr.xyxmz\",\"splash\":\"0\",\"splash_copy_to_unity\":\"0\",\"sdkParams\":{\"SCREEN_ORIENTATION\":\"0\",\"GAORE_CHANNELID\":\"1\",\"GAORE_VERSION_TAG\":\"1\",\"GAORE_LOGO_SHOW\":\"1\",\"GAORE_CHANNEL_KEY\":\"GRSDK\",\"GAORE_GAME_VERSION\":\"1.0.0\",\"GAORE_APPLICATION_PROXY_NAME\":\"com.gr.sdk.GaoreApplication,com.gr.sdk.MSAApplication,com.gr.sdk.addictioncheck.application.GaoreApplication,com.gr.sdk.BuglyProxyApplication,com.gr.sdk.GDTProxyApplication,com.gr.sdk.GDTChannelProxyApplication\",\"GAORE_WX_APP_ID\":\"\",\"GAORE_FLOAT_POSITION\":\"0|30\",\"GAORE_ROUND_ICON\":\"0\",\"GAORE_ROUND_ICON_PATH\":\"\",\"GAORE_ROUND_ICON_FOREGROUND_PATH\":\"\",\"GAORE_ROUND_ICON_BACKGROUND_PATH\":\"\",\"GR_AGEWARN\":\"true\",\"GR_REDPACKET\":\"1\",\"GR_REDPACKET_GUIDE\":\"1\",\"GAORE_INIT_SDK_TYPE\":\"2\",\"appkey_avscan\":\"\",\"seckey_avscan\":\"\",\"GDT_USER_ACTION_SET_ID\":\"1203968086\",\"GDT_APP_SECRET_KEY\":\"8ad271167be3dcf120468770a4ee9b21\",\"GISM_APPID\":\"\",\"GISM_APPNAME\":\"\",\"QL_APPID\":\"\",\"KUAISHOU_APPID\":\"\",\"KUAISHOU_APPNAME\":\"\",\"TOUTIAO_AID\":\"\",\"addPermissionActivity\":\"1\",\"VIVO_SRC_ID\":\"\"},\"sdkVersion\":{\"versionName\":\"2.6.1\"},\"plugins\":{\"addictioncheck\":\"\",\"msaid\":\"\",\"bugly\":\"\",\"gdt\":\"\",\"gdt_channel\":\"\"}}}"
|
||||||
|
req.Env = 0 // 灰度为 1 正式为0
|
||||||
|
resp, err := client.TaskCreate(req)
|
||||||
|
t.Logf("%v", resp.Data.TaskId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfig_Modify(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
req := CreateConfigModifyRequest()
|
||||||
|
req.Content = []byte(`<?xml version='1.0' encoding='UTF-8'?><xml><apks><!-- name:母包文件名 --><!-- screen:屏幕方向 0竖屏 1横屏 --><!-- targetSdk:targetSdkVersion支持30以上 0否 1是 --><apk><param name="id" value="1" /><param name="name" value="heji" /><param name="desc" value="合击" /><param name="screen" value="1" /><param name="targetSdk" value="0" /></apk><apk><param name="id" value="2" /><param name="name" value="lanyue" /><param name="desc" value="蓝月" /><param name="screen" value="1" /><param name="targetSdk" value="0" /></apk></apks></xmls>`)
|
||||||
|
resp, err := client.ConfigModify(req)
|
||||||
|
t.Log(resp.Code, resp.Msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfig_Get(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
req := CreateConfigGetRequest()
|
||||||
|
resp, err := client.ConfigGet(req)
|
||||||
|
t.Log(resp.Code, resp.Data)
|
||||||
|
}
|
34
services/capk/config_get.go
Normal file
34
services/capk/config_get.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package capk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ConfigGetRequest struct {
|
||||||
|
*requests.JsonRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigGetResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateConfigGetRequest() *ConfigGetRequest {
|
||||||
|
req := &ConfigGetRequest{
|
||||||
|
JsonRequest: &requests.JsonRequest{},
|
||||||
|
}
|
||||||
|
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/pack/config/get")
|
||||||
|
req.Method = requests.GET
|
||||||
|
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateConfigGetResponse() *ConfigGetResponse {
|
||||||
|
return &ConfigGetResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
33
services/capk/config_modify.go
Normal file
33
services/capk/config_modify.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package capk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ConfigModifyRequest struct {
|
||||||
|
*requests.StreamRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigModifyResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateConfigModifyRequest() (req *ConfigModifyRequest) {
|
||||||
|
req = &ConfigModifyRequest{
|
||||||
|
StreamRequest: &requests.StreamRequest{},
|
||||||
|
}
|
||||||
|
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/pack/config/set")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateConfigModifyResponse() (resp *ConfigModifyResponse) {
|
||||||
|
return &ConfigModifyResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
38
services/capk/task_create.go
Normal file
38
services/capk/task_create.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package capk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TaskCreateRequest struct {
|
||||||
|
*requests.JsonRequest
|
||||||
|
GameId int `position:"Json" field:"game_id"`
|
||||||
|
GameVersion string `position:"Json" field:"game_version"`
|
||||||
|
Config string `position:"Json" field:"config"`
|
||||||
|
Env int `position:"Json" field:"env"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TaskCreateResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data struct {
|
||||||
|
TaskId string `json:"task_id"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateTaskCreateRequest() (req *TaskCreateRequest) {
|
||||||
|
req = &TaskCreateRequest{
|
||||||
|
JsonRequest: &requests.JsonRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/pack/task/create")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateTaskCreateResponse() (resp *TaskCreateResponse) {
|
||||||
|
resp = &TaskCreateResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
31
services/center-api/client.go
Normal file
31
services/center-api/client.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package center_api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "2020-11-16"
|
||||||
|
)
|
||||||
|
|
||||||
|
var HOST = requests.Host{
|
||||||
|
Default: "center-api",
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
sdk.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient() (client *Client, err error) {
|
||||||
|
client = new(Client)
|
||||||
|
err = client.Init()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// PackagingTaskCallback 打包任务回调
|
||||||
|
func (c *Client) PackagingTaskCallback(req *PackagingTaskCallbackReq) (resp *PackagingTaskCallbackResp, err error) {
|
||||||
|
resp = CreatePackagingTaskCallbackResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
28
services/center-api/client_test.go
Normal file
28
services/center-api/client_test.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package center_api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPackagingTaskCallback(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req := CreatePackagingTaskCallbackReq(Data{
|
||||||
|
TaskId: "asdada120",
|
||||||
|
Status: 1,
|
||||||
|
Msg: "test",
|
||||||
|
Url: "http://www.baidu.com",
|
||||||
|
Md5: "adadsadasdasda",
|
||||||
|
})
|
||||||
|
|
||||||
|
resp, err := client.PackagingTaskCallback(req)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(resp.StatusCode, resp.StatusMsg)
|
||||||
|
}
|
64
services/center-api/packaging.go
Normal file
64
services/center-api/packaging.go
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package center_api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PackagingTaskCallbackReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
TaskId string `position:"Body" field:"task_id"`
|
||||||
|
Status int `position:"Body" field:"status"`
|
||||||
|
Msg string `position:"Body" field:"msg"`
|
||||||
|
Url string `position:"Body" field:"url"`
|
||||||
|
Md5 string `position:"Body" field:"md5"`
|
||||||
|
Sign string `position:"Body" field:"sign"`
|
||||||
|
Ts int64 `position:"Body" field:"ts"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PackagingTaskCallbackResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
StatusMsg string `json:"status_msg"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Data struct {
|
||||||
|
TaskId string `json:"task_id"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Url string `json:"url"`
|
||||||
|
Md5 string `json:"md5"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePackagingTaskCallbackReq(data Data) *PackagingTaskCallbackReq {
|
||||||
|
req := &PackagingTaskCallbackReq{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
|
||||||
|
req.TaskId = data.TaskId
|
||||||
|
req.Status = data.Status
|
||||||
|
req.Msg = data.Msg
|
||||||
|
req.Url = data.Url
|
||||||
|
req.Md5 = data.Md5
|
||||||
|
req.Ts = 1730357662
|
||||||
|
|
||||||
|
// sign=md5(ts+task_id+sign_key) 32位
|
||||||
|
// 生成 MD5 哈希
|
||||||
|
hash := md5.Sum([]byte(fmt.Sprintf("%d%s%s", req.Ts, req.TaskId, "xBPVBJ132asdUeJC3XjD7AnFWD2sbGH6pJC4654y89")))
|
||||||
|
|
||||||
|
// 将哈希结果转换为十六进制字符串
|
||||||
|
hashString := hex.EncodeToString(hash[:])
|
||||||
|
req.Sign = hashString
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/v1/packaging/task/callback")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePackagingTaskCallbackResp() *PackagingTaskCallbackResp {
|
||||||
|
return &PackagingTaskCallbackResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
43
services/game/channel.go
Normal file
43
services/game/channel.go
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package game
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ChannelInfoReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
ChannelId int64 `position:"Body" field:"channelId"`
|
||||||
|
ChannelKey string `position:"Body" field:"channelKey"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChannelInfoResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data map[int64]struct {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
PlatKey string `json:"plat_key"`
|
||||||
|
PlatName string `json:"plat_name"`
|
||||||
|
PlatCompany string `json:"plat_company"`
|
||||||
|
PlatUrl string `json:"plat_url"`
|
||||||
|
Company string `json:"company"`
|
||||||
|
PlatCategoryId int64 `json:"plat_category_id"`
|
||||||
|
CategoryName string `json:"category_name"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateChannelInfoReq() *ChannelInfoReq {
|
||||||
|
req := &ChannelInfoReq{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/api/channel/getChannelInfo")
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateChannelInfoResp() *ChannelInfoResp {
|
||||||
|
resp := &ChannelInfoResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return resp
|
||||||
|
}
|
@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "2020-11-16"
|
VERSION = "2025-04-27"
|
||||||
)
|
)
|
||||||
|
|
||||||
var HOST = requests.Host{
|
var HOST = requests.Host{
|
||||||
@ -29,3 +29,28 @@ func (c *Client) GetGameOsInfo(req *GetGameOsInfoReq) (resp *GetGameOsInfoResp,
|
|||||||
err = c.DoAction(req, resp)
|
err = c.DoAction(req, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetGameInfo 获取游戏信息
|
||||||
|
func (c *Client) GetGameInfo(req *GetGameInfoReq) (resp *GetGameInfoResp, err error) {
|
||||||
|
resp = CreateGetGameInfoByIdResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) GetChannelInfo(req *ChannelInfoReq) (resp *ChannelInfoResp, err error) {
|
||||||
|
resp = CreateChannelInfoResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) GetLoginInfoById(req *GetLoginInfoByIdReq) (resp *GetLoginInfoByIdResp, err error) {
|
||||||
|
resp = CreateGetLoginInfoByIdResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) GetProtocolByGameId(req *GetProtocolByGameIdRep) (resp *GetProtocolByGameIdResp, err error) {
|
||||||
|
resp = CreateGetProtocolByGameIdResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -20,3 +20,60 @@ func TestGetGameOsInfo(t *testing.T) {
|
|||||||
|
|
||||||
fmt.Println(resp.Code, resp.Msg, resp.Data.OsList, resp.Data.OsRelList2)
|
fmt.Println(resp.Code, resp.Msg, resp.Data.OsList, resp.Data.OsRelList2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetGameInfo(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
resp, err := client.GetGameInfo(CreateGetGameInfoByIdReq(8362, 1))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Println(resp.Code, resp.Msg, resp.Data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestChannelInfo(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
req := CreateChannelInfoReq()
|
||||||
|
req.ChannelKey = "GRSDK"
|
||||||
|
resp, err := client.GetChannelInfo(req)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Println(resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoginInfoById(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
req := CreateGetLoginInfoByIdReq(7349, "1.0.0")
|
||||||
|
info, err := client.GetLoginInfoById(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Println(info)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetProtocolByGameId(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
req := CreateGetProtocolByGameIdRep()
|
||||||
|
req.GameId = 8088
|
||||||
|
req.GameVersion = "1.1.0"
|
||||||
|
req.Type = 1
|
||||||
|
info, err := client.GetProtocolByGameId(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Println(info)
|
||||||
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package game
|
package game
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"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/responses"
|
||||||
)
|
)
|
||||||
@ -47,3 +48,117 @@ func CreateGetGameOsInfoResp() *GetGameOsInfoResp {
|
|||||||
BaseResponse: &responses.BaseResponse{},
|
BaseResponse: &responses.BaseResponse{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetGameInfoReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetGameInfoResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data GameInfoData `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetGameInfoReqData struct {
|
||||||
|
GameId int
|
||||||
|
NoCache int
|
||||||
|
}
|
||||||
|
|
||||||
|
type GameInfoData struct {
|
||||||
|
AcceptRelatedGame int `json:"accept_related_game"`
|
||||||
|
ActCodeState int `json:"act_code_state"`
|
||||||
|
AgentSign string `json:"agent_sign"`
|
||||||
|
AppId string `json:"app_id"`
|
||||||
|
AppName string `json:"app_name"`
|
||||||
|
Autologin int `json:"autologin"`
|
||||||
|
BName string `json:"b_name"`
|
||||||
|
BackResult int `json:"back_result"`
|
||||||
|
BusinessPurpose int `json:"business_purpose"`
|
||||||
|
ChannelShow int `json:"channel_show"`
|
||||||
|
ClientType int `json:"client_type"`
|
||||||
|
Company string `json:"company"`
|
||||||
|
CreatedAt string `json:"created_at"`
|
||||||
|
CreatedRealname string `json:"created_realname"`
|
||||||
|
CreatedUsername string `json:"created_username"`
|
||||||
|
DisableBack int `json:"disable_back"`
|
||||||
|
DisablePay int `json:"disable_pay"`
|
||||||
|
DisableRegister int `json:"disable_register"`
|
||||||
|
DisableRelatedBack int `json:"disable_related_back"`
|
||||||
|
DisableUnrelatedLogin int `json:"disable_unrelated_login"`
|
||||||
|
Discount int `json:"discount"`
|
||||||
|
Divide int `json:"divide"`
|
||||||
|
DownloadDomain string `json:"download_domain"`
|
||||||
|
DownloadId int `json:"download_id"`
|
||||||
|
ExchangeRate int `json:"exchange_rate"`
|
||||||
|
ExtData string `json:"ext_data"`
|
||||||
|
Fcmathod int `json:"fcmathod"`
|
||||||
|
FirstLetter string `json:"first_letter"`
|
||||||
|
FlashAuthId string `json:"flash_auth_id"`
|
||||||
|
FlashAuthKey string `json:"flash_auth_key"`
|
||||||
|
FlashAuthLogo string `json:"flash_auth_logo"`
|
||||||
|
FlashAuthName string `json:"flash_auth_name"`
|
||||||
|
FlashAuthStatus int `json:"flash_auth_status"`
|
||||||
|
GameByname string `json:"game_byname"`
|
||||||
|
GameIconImg string `json:"game_icon_img"`
|
||||||
|
GameSign string `json:"game_sign"`
|
||||||
|
GameTsUrl string `json:"game_ts_url"`
|
||||||
|
GameVersion string `json:"game_version"`
|
||||||
|
GameZsUrl string `json:"game_zs_url"`
|
||||||
|
GetRoleUrl string `json:"get_role_url"`
|
||||||
|
HideRedButton int `json:"hide_red_button"`
|
||||||
|
Icon string `json:"icon"`
|
||||||
|
Icp string `json:"icp"`
|
||||||
|
IcpUrl string `json:"icp_url"`
|
||||||
|
Id int `json:"id"`
|
||||||
|
IsAugment int `json:"is_augment"`
|
||||||
|
IsOpen int `json:"is_open"`
|
||||||
|
IsSync int `json:"is_sync"`
|
||||||
|
MarketName string `json:"market_name"`
|
||||||
|
MediaAbbr string `json:"media_abbr"`
|
||||||
|
MobileLoginState int `json:"mobile_login_state"`
|
||||||
|
MobileRegState int `json:"mobile_reg_state"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
ObjectiveId int `json:"objective_id"`
|
||||||
|
OpenGame int `json:"open_game"`
|
||||||
|
Os int `json:"os"`
|
||||||
|
OsTwo int `json:"os_two"`
|
||||||
|
Owner int `json:"owner"`
|
||||||
|
PackageNameId int `json:"package_name_id"`
|
||||||
|
PayUrl string `json:"pay_url"`
|
||||||
|
PlatId int `json:"plat_id"`
|
||||||
|
Platform int `json:"platform"`
|
||||||
|
ProtocolPreState int `json:"protocol_pre_state"`
|
||||||
|
Rank int `json:"rank"`
|
||||||
|
RegisterProtocolState int `json:"register_protocol_state"`
|
||||||
|
RelateGame string `json:"relate_game"`
|
||||||
|
ReleaseState int `json:"release_state"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
RequestDomain string `json:"request_domain"`
|
||||||
|
ResultCode string `json:"result_code"`
|
||||||
|
ScreenType int `json:"screen_type"`
|
||||||
|
ServerGroupId int `json:"server_group_id"`
|
||||||
|
ServerSign int `json:"server_sign"`
|
||||||
|
SimId int `json:"sim_id"`
|
||||||
|
SpareRequestDomain string `json:"spare_request_domain"`
|
||||||
|
TwOs int `json:"tw_os"`
|
||||||
|
TwPlatId int `json:"tw_plat_id"`
|
||||||
|
UpdatedAt string `json:"updated_at"`
|
||||||
|
UpdatedRealname string `json:"updated_realname"`
|
||||||
|
UpdatedUsername string `json:"updated_username"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetGameInfoByIdReq(gameId, noCache int) *GetGameInfoReq {
|
||||||
|
req := &GetGameInfoReq{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, fmt.Sprintf("/api/game/getGameById/%d?no_cache=%d", gameId, noCache))
|
||||||
|
req.Method = requests.GET
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetGameInfoByIdResp() *GetGameInfoResp {
|
||||||
|
return &GetGameInfoResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
73
services/game/login.go
Normal file
73
services/game/login.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package game
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetLoginInfoByIdReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
GameId int `position:"Body" field:"game_id"`
|
||||||
|
GameVersion string `position:"Body" field:"game_version"`
|
||||||
|
Uid int `position:"Body" field:"uid"`
|
||||||
|
UserName string `position:"Body" field:"uname"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PayInfo struct {
|
||||||
|
HiddenAlipay int `json:"hide_alipay"`
|
||||||
|
HiddenWx int `json:"hide_wx"`
|
||||||
|
HiddenUnionPay int `json:"hide_union_pay"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GameVersionInfo struct {
|
||||||
|
AppName string `json:"app_name"`
|
||||||
|
AppID string `json:"app_id"`
|
||||||
|
LoginURL string `json:"login_url"`
|
||||||
|
PayURL string `json:"pay_url"`
|
||||||
|
GameURL string `json:"game_url"`
|
||||||
|
PayCallbackURL string `json:"pay_callback_url"`
|
||||||
|
IsH5Logout int `json:"is_h5_logout"`
|
||||||
|
HideWindow int `json:"hidewindow"`
|
||||||
|
GameVersion string `json:"version"`
|
||||||
|
GameSign string `json:"game_sign"`
|
||||||
|
GameSignName string `json:"game_sign_name"`
|
||||||
|
GameSignID int `json:"game_sign_id"`
|
||||||
|
IsYsdk int `json:"is_ysdk"`
|
||||||
|
Company string `json:"company"`
|
||||||
|
CompanyKf string `json:"company_kf"`
|
||||||
|
CompanyProto string `json:"company_proto"`
|
||||||
|
CompanySms string `json:"company_sms"`
|
||||||
|
KfStatus int `json:"kf_status"`
|
||||||
|
PopupTime int `json:"popup_time"`
|
||||||
|
GameId int `json:"game_id"`
|
||||||
|
ScreenType int `json:"screen_type"`
|
||||||
|
GameSwitch int `json:"game_switch"` // 根据上下文,0 或 1 的整数表示布尔值
|
||||||
|
ExtData map[string]any `json:"ext_data"`
|
||||||
|
OsName string `json:"os_name"`
|
||||||
|
PayInfo PayInfo `json:"pay_info"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetLoginInfoByIdResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data GameVersionInfo `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetLoginInfoByIdReq(gameId int, gameVersion string) *GetLoginInfoByIdReq {
|
||||||
|
req := &GetLoginInfoByIdReq{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.GameId = gameId
|
||||||
|
req.GameVersion = gameVersion
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/api/login/getInfoById")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetLoginInfoByIdResp() *GetLoginInfoByIdResp {
|
||||||
|
resp := &GetLoginInfoByIdResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return resp
|
||||||
|
}
|
37
services/game/news.go
Normal file
37
services/game/news.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package game
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetProtocolByGameIdRep struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
GameId int `position:"Query" field:"game_id"`
|
||||||
|
GameVersion string `position:"Query" field:"game_version"`
|
||||||
|
Type int `position:"Query" field:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetProtocolByGameIdResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data struct {
|
||||||
|
Content string `json:"content"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetProtocolByGameIdRep() *GetProtocolByGameIdRep {
|
||||||
|
req := &GetProtocolByGameIdRep{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/api/news/getProtocolByGameId")
|
||||||
|
req.Method = requests.GET
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetProtocolByGameIdResp() *GetProtocolByGameIdResp {
|
||||||
|
return &GetProtocolByGameIdResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package mkt
|
package mkt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -18,5 +19,11 @@ func TestSubjectList(t *testing.T) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
marshal, err := json.Marshal(list.Data)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(string(marshal))
|
||||||
fmt.Println(list.Status, list.Code, list.Msg, list.Data)
|
fmt.Println(list.Status, list.Code, list.Msg, list.Data)
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ type Data struct {
|
|||||||
State int `json:"state"`
|
State int `json:"state"`
|
||||||
System string `json:"system"`
|
System string `json:"system"`
|
||||||
Type int `json:"type"`
|
Type int `json:"type"`
|
||||||
|
Uscc string `json:"uscc"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSubjectListRequest 公司列表请求
|
// CreateSubjectListRequest 公司列表请求
|
||||||
|
@ -3,11 +3,12 @@ package oss
|
|||||||
import (
|
import (
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"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/responses"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetApkVersionRequest struct {
|
type GetApkVersionRequest struct {
|
||||||
*requests.JsonRequest
|
*requests.JsonRequest
|
||||||
Filepath string `position:"Body" field:"filepath"`
|
Filepath string `position:"Json" field:"filepath"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetApkVersionResponse struct {
|
type GetApkVersionResponse struct {
|
||||||
@ -17,6 +18,8 @@ type GetApkVersionResponse struct {
|
|||||||
Data struct {
|
Data struct {
|
||||||
VersionCode string `json:"versionCode"`
|
VersionCode string `json:"versionCode"`
|
||||||
VersionName string `json:"versionName"`
|
VersionName string `json:"versionName"`
|
||||||
|
MinSdkVersion string `json:"minSdkVersion"`
|
||||||
|
TargetSdkVersion string `json:"targetSdkVersion"`
|
||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,6 +29,7 @@ func CreateGetApkVersionRequest() (req *GetApkVersionRequest) {
|
|||||||
}
|
}
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/apk/version")
|
req.InitWithApiInfo(HOST, VERSION, "/api/apk/version")
|
||||||
req.Method = requests.POST
|
req.Method = requests.POST
|
||||||
|
req.SetReadTimeout(30 * time.Second)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,10 +43,16 @@ func TestUpload_Del(t *testing.T) {
|
|||||||
|
|
||||||
func TestCreateInitMultipartUpload(t *testing.T) {
|
func TestCreateInitMultipartUpload(t *testing.T) {
|
||||||
req := CreateInitMultipartUploadRequest()
|
req := CreateInitMultipartUploadRequest()
|
||||||
req.Filepath = "test.jpg"
|
|
||||||
|
extInfo := map[string]any{"game_byname": "tech_test_tencent"}
|
||||||
|
bExtInfo, _ := json.Marshal(extInfo)
|
||||||
|
|
||||||
|
req.UploadType = "package"
|
||||||
req.TargetType = "oss"
|
req.TargetType = "oss"
|
||||||
req.TargetName = "image"
|
req.TargetName = "image"
|
||||||
req.FileHash = "51c68615b8d21f9b72b02f48c400cb87"
|
req.FileHash = "51c68615b8d21f9b72b02f48c400cb87"
|
||||||
|
req.Filepath = "q5-01.zip"
|
||||||
|
req.ExtInfo = string(bExtInfo)
|
||||||
client, err := NewClient()
|
client, err := NewClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
@ -66,7 +72,7 @@ func TestCreateInitMultipartUpload(t *testing.T) {
|
|||||||
|
|
||||||
func TestClient_GetApkVersion(t *testing.T) {
|
func TestClient_GetApkVersion(t *testing.T) {
|
||||||
req := CreateGetApkVersionRequest()
|
req := CreateGetApkVersionRequest()
|
||||||
req.Filepath = "36c55c4c3a2f4c79e3917b989d580496.zip"
|
req.Filepath = "uploads/files/package/1f57ac9693f0593fc9073f366b1c1936.zip"
|
||||||
client, err := NewClient()
|
client, err := NewClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
@ -15,10 +15,12 @@ const (
|
|||||||
|
|
||||||
type InitMultipartUploadRequest struct {
|
type InitMultipartUploadRequest struct {
|
||||||
*requests.JsonRequest
|
*requests.JsonRequest
|
||||||
Filepath string `position:"Body" field:"filepath"`
|
UploadType string `position:"Json" field:"upload_type"`
|
||||||
TargetType string `position:"Body" field:"target_type"`
|
TargetType string `position:"Json" field:"target_type"`
|
||||||
TargetName string `position:"Body" field:"target_name"`
|
TargetName string `position:"Json" field:"target_name"`
|
||||||
FileHash string `position:"Body" field:"file_hash"`
|
FileHash string `position:"Json" field:"file_hash"`
|
||||||
|
Filepath string `position:"Json" field:"filepath"`
|
||||||
|
ExtInfo string `position:"Json" field:"ext_info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type InitMultipartUploadResponse struct {
|
type InitMultipartUploadResponse struct {
|
||||||
@ -50,7 +52,7 @@ func CreateInitMultipartUploadRequest() (req *InitMultipartUploadRequest) {
|
|||||||
JsonRequest: &requests.JsonRequest{},
|
JsonRequest: &requests.JsonRequest{},
|
||||||
}
|
}
|
||||||
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/upload/multipart/init?ts="+ts+"&sign="+sign)
|
req.InitWithApiInfo(HOST, VERSION, "/api/upload/multipart/init?_ts="+ts+"&_sign="+sign)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
type DelOssRequest struct {
|
type DelOssRequest struct {
|
||||||
*requests.JsonRequest
|
*requests.JsonRequest
|
||||||
BucketName string `position:"Body" field:"bucket_name" default:"image"`
|
BucketName string `position:"Json" field:"bucket_name" default:"image"`
|
||||||
MediaUrl string `position:"Body" field:"url" default:"-"`
|
MediaUrl string `position:"Json" field:"url" default:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DelOssResponse struct {
|
type DelOssResponse struct {
|
||||||
|
@ -10,11 +10,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
var HOST requests.Host = requests.Host{
|
||||||
Default: "pay.gaore.com",
|
Default: "pay.api.gaore.com",
|
||||||
Func: func(s string) string {
|
Func: func(s string) string {
|
||||||
var a = map[string]string{
|
var a = map[string]string{
|
||||||
requests.RELEASE: "pay.gaore.com",
|
requests.RELEASE: "pay.api.gaore.com",
|
||||||
requests.PRE: "pay.gaore.com",
|
requests.PRE: "pay.api.gaore.com",
|
||||||
requests.TEST: "pay.gaore.com",
|
requests.TEST: "pay.gaore.com",
|
||||||
}
|
}
|
||||||
return a[s]
|
return a[s]
|
||||||
@ -49,8 +49,8 @@ func (c *Client) ComplaintUpload(req *ComplaintUploadRequest) (response *Complai
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ComplaintNotifyUrl(req *ComplaintNotifyUrlRequest) (response *ComplaintNotifyUrlResponse, err error) {
|
func (c *Client) MerchantConfigDebug(req *merchantConfigDebugRequest) (response *merchantConfigDebugResponse, err error) {
|
||||||
response = CreateComplaintNotifyUrlResponse()
|
response = CreateMerchantConfigDebugResponse()
|
||||||
err = c.DoAction(req, response)
|
err = c.DoAction(req, response)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
package pay
|
package pay
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestClient_GetUserInfo(t *testing.T) {
|
func TestClient_GetUserInfo(t *testing.T) {
|
||||||
|
|
||||||
c, err := NewClient()
|
//c, err := NewClient()
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
t.Error(err)
|
// t.Error(err)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
req := CreateComplaintNotifyUrlRequest()
|
//req := CreateComplaintNotifyUrlRequest()
|
||||||
|
//
|
||||||
req.MchId = "3503"
|
//req.MchId = "3503"
|
||||||
req.NotifyUrl = "https://pay.uu89.com/api/complaint/wxNotify/3503"
|
//req.NotifyUrl = "https://pay.uu89.com/api/complaint/wxNotify/3503"
|
||||||
req.Type = 1
|
//req.Type = 1
|
||||||
|
//
|
||||||
resp, err := c.ComplaintNotifyUrl(req)
|
//resp, err := c.ComplaintNotifyUrl(req)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
log.Fatalln(err)
|
// log.Fatalln(err)
|
||||||
}
|
//}
|
||||||
fmt.Println(resp.GetHttpContentString())
|
//fmt.Println(resp.GetHttpContentString())
|
||||||
fmt.Println(resp.GetHttpHeaders())
|
//fmt.Println(resp.GetHttpHeaders())
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ type ComplaintCompleteRequest struct {
|
|||||||
*requests.RpcRequest
|
*requests.RpcRequest
|
||||||
MchId string `position:"Body" field:"mch_id" default:"" `
|
MchId string `position:"Body" field:"mch_id" default:"" `
|
||||||
ComplaintId string `position:"Body" field:"complaint_id" default:"" `
|
ComplaintId string `position:"Body" field:"complaint_id" default:"" `
|
||||||
|
ExtData string `position:"Body" field:"ext_data" default:"" `
|
||||||
}
|
}
|
||||||
|
|
||||||
type ComplaintCompleteResponse struct {
|
type ComplaintCompleteResponse struct {
|
||||||
|
@ -16,8 +16,8 @@ type merchantConfigDebugResponse struct {
|
|||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateMerchantConfigDebugRequest() (req *ComplaintNotifyUrlRequest) {
|
func CreateMerchantConfigDebugRequest() (req *merchantConfigDebugRequest) {
|
||||||
req = &ComplaintNotifyUrlRequest{
|
req = &merchantConfigDebugRequest{
|
||||||
RpcRequest: &requests.RpcRequest{},
|
RpcRequest: &requests.RpcRequest{},
|
||||||
}
|
}
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/complaint/configDebug")
|
req.InitWithApiInfo(HOST, VERSION, "/api/complaint/configDebug")
|
||||||
@ -25,8 +25,8 @@ func CreateMerchantConfigDebugRequest() (req *ComplaintNotifyUrlRequest) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateMerchantConfigDebugResponse() (response *ComplaintNotifyUrlResponse) {
|
func CreateMerchantConfigDebugResponse() (response *merchantConfigDebugResponse) {
|
||||||
response = &ComplaintNotifyUrlResponse{
|
response = &merchantConfigDebugResponse{
|
||||||
BaseResponse: &responses.BaseResponse{},
|
BaseResponse: &responses.BaseResponse{},
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -2,13 +2,13 @@ package script
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"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/responses"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OpenGameReq struct {
|
type OpenGameReq struct {
|
||||||
*requests.RpcRequest
|
*requests.RpcRequest
|
||||||
|
GameID int `position:"Query" field:"game_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpenGameResp struct {
|
type OpenGameResp struct {
|
||||||
@ -25,10 +25,11 @@ func (baseResponse *OpenGameResp) GetHttpContentBytes() []byte {
|
|||||||
func CreateOpenGameReq(gameId int) *OpenGameReq {
|
func CreateOpenGameReq(gameId int) *OpenGameReq {
|
||||||
req := &OpenGameReq{
|
req := &OpenGameReq{
|
||||||
&requests.RpcRequest{},
|
&requests.RpcRequest{},
|
||||||
|
gameId,
|
||||||
}
|
}
|
||||||
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "open_game.php?game_id="+fmt.Sprintf("%v", gameId))
|
req.InitWithApiInfo(HOST, VERSION, "open_game.php")
|
||||||
req.Method = requests.POST
|
req.Method = requests.GET
|
||||||
|
|
||||||
return req
|
return req
|
||||||
}
|
}
|
||||||
|
110
services/sms/client.go
Normal file
110
services/sms/client.go
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
package sms
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "2024-05-30"
|
||||||
|
)
|
||||||
|
|
||||||
|
var HOST = requests.Host{
|
||||||
|
Default: "sms.gaore.com",
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
sdk.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient() (client *Client, err error) {
|
||||||
|
client = new(Client)
|
||||||
|
err = client.Init()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) SendEmail(req *SendEmailRequest) (resp *SendEmailResponse, err error) {
|
||||||
|
if len(req.Addresses) == 0 {
|
||||||
|
return nil, errors.New("addresses is empty")
|
||||||
|
}
|
||||||
|
if req.FromName == "" {
|
||||||
|
return nil, errors.New("from is empty")
|
||||||
|
}
|
||||||
|
if req.Subject == "" {
|
||||||
|
return nil, errors.New("subject is empty")
|
||||||
|
}
|
||||||
|
if req.Body == "" {
|
||||||
|
return nil, errors.New("content is empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
ts, token := getToken("04573fc4c8e01999a0909ab9c00bca5a")
|
||||||
|
|
||||||
|
req.JsonParams["sign"] = token
|
||||||
|
req.JsonParams["time"] = ts
|
||||||
|
resp = CreateSendEmailResponse()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) SendFeiShuWebHook(req *SendFeiShuWebHookRequest) (resp *SendFeiShuWebHookResponse, err error) {
|
||||||
|
if req.Content == "" {
|
||||||
|
err = errors.New("content is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Do == "" {
|
||||||
|
err = errors.New("webhook is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Token == "" {
|
||||||
|
err = errors.New("token is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp = CreateSendFeiShuWebHookResponse()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) SendSms(req *SendSmsRequest) (resp *SendSmsResponse, err error) {
|
||||||
|
|
||||||
|
if req.Mobile == "" {
|
||||||
|
err = errors.New("mobile is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Type == "" {
|
||||||
|
err = errors.New("type is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Expired == 0 {
|
||||||
|
err = errors.New("expired is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Code == 0 {
|
||||||
|
err = errors.New("code is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp = CreateSendSmsResponse()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getToken(key string) (ts int64, token string) {
|
||||||
|
ts = time.Now().Unix()
|
||||||
|
hash := md5.New()
|
||||||
|
hash.Write([]byte(fmt.Sprintf("%v%v", ts, key)))
|
||||||
|
hashBytes := hash.Sum(nil)
|
||||||
|
|
||||||
|
token = hex.EncodeToString(hashBytes)
|
||||||
|
return
|
||||||
|
}
|
115
services/sms/client_test.go
Normal file
115
services/sms/client_test.go
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
package sms
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
client *Client
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMain(t *testing.M) {
|
||||||
|
var err error
|
||||||
|
client, err = NewClient()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestClient_SendEmail(t *testing.T) {
|
||||||
|
req := CreateSendEmailRequest(SendEmailParam{
|
||||||
|
Addresses: []string{"xuyang@89you.com"},
|
||||||
|
Subject: "测试邮件",
|
||||||
|
Body: "xxx已修改密码,新密码是:xxx",
|
||||||
|
FromName: "高热监控",
|
||||||
|
})
|
||||||
|
|
||||||
|
email, err := client.SendEmail(req)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(email)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestClient_SendFeiShuWebHook(t *testing.T) {
|
||||||
|
//req := CreateSendFeiShuWebHookRequest(SendFeiShuWebHookParam{
|
||||||
|
// Do: FeiShuWebHookDoTypeSendRichText,
|
||||||
|
// Token: "b762f80c-fe4f-4182-b48e-5c78041592bc",
|
||||||
|
// Content: "[[{\"tag\":\"text\",\"text\":\"富文本信息: \"},{\"tag\":\"a\",\"text\":\"请查看\",\"href\":\"http://www.example.com/\"},{\"tag\":\"at\",\"user_id\":\"ou_18eac8********17ad4f02e8bbbb\"}]]",
|
||||||
|
// Title: "卡片主标题",
|
||||||
|
// TitleColor: "purple",
|
||||||
|
//})
|
||||||
|
//
|
||||||
|
//resp, err := client.SendFeiShuWebHook(req)
|
||||||
|
//if err != nil {
|
||||||
|
// panic(err)
|
||||||
|
//}
|
||||||
|
//fmt.Println(resp.Msg)
|
||||||
|
|
||||||
|
//req2 := CreateSendFeiShuWebHookRequest(SendFeiShuWebHookParam{
|
||||||
|
// Do: FeiShuWebHookDoTypeSendSimpleText,
|
||||||
|
// Token: "b762f80c-fe4f-4182-b48e-5c78041592bc",
|
||||||
|
// Content: " - 苹果ID:XXXX\n - 游戏ID:XXXX\n - bundleID:XXXX\n - 应用名:XXX\n - 下架时间:2025-04-18 12:36:52\n - IP:XX(城市A省份)、XX(城市B省份);说明:XX为具体的IP,括号内为IP对应的城市;",
|
||||||
|
//})
|
||||||
|
//
|
||||||
|
//resp2, err := client.SendFeiShuWebHook(req2)
|
||||||
|
//if err != nil {
|
||||||
|
// panic(err)
|
||||||
|
//}
|
||||||
|
//fmt.Println(resp2)
|
||||||
|
|
||||||
|
//[
|
||||||
|
// [
|
||||||
|
// {
|
||||||
|
// "tag": "text",
|
||||||
|
// "text": "苹果ID:XXXX"
|
||||||
|
// }
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// {
|
||||||
|
// "tag": "text",
|
||||||
|
// "text": "游戏ID:XXXX"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
//]
|
||||||
|
|
||||||
|
req3 := CreateSendFeiShuWebHookRequest(SendFeiShuWebHookParam{
|
||||||
|
TitleColor: "purple",
|
||||||
|
Title: "监控报警",
|
||||||
|
Do: FeiShuWebHookDoTypeSendCardText,
|
||||||
|
Token: "b762f80c-fe4f-4182-b48e-5c78041592bc",
|
||||||
|
Content: "[{\"tag\":\"div\",\"text\":{\"tag\":\"plain_text\",\"content\":\"苹果ID:XXXX\"}},{\"tag\":\"div\",\"text\":{\"tag\":\"plain_text\",\"content\":\"游戏ID:XXXX\"}}]",
|
||||||
|
})
|
||||||
|
|
||||||
|
resp3, err := client.SendFeiShuWebHook(req3)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Println(resp3.Msg)
|
||||||
|
fmt.Println(resp3)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestClient_SendSms(t *testing.T) {
|
||||||
|
req := CreateSendSmsRequest(SendSmsParam{
|
||||||
|
Mobile: "18320021439",
|
||||||
|
Type: SmsTypeBindPhone,
|
||||||
|
Code: 123456,
|
||||||
|
Expired: 5,
|
||||||
|
})
|
||||||
|
|
||||||
|
req.Domain = requests.Host{
|
||||||
|
Default: "127.0.0.1:8804",
|
||||||
|
}
|
||||||
|
|
||||||
|
sms, err := client.SendSms(req)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(sms)
|
||||||
|
}
|
45
services/sms/email.go
Normal file
45
services/sms/email.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package sms
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SendEmailRequest struct {
|
||||||
|
*requests.JsonRequest
|
||||||
|
Addresses []string `position:"Json" field:"addresses"`
|
||||||
|
Subject string `position:"Json" field:"subject"`
|
||||||
|
Body string `position:"Json" field:"body"`
|
||||||
|
FromName string `position:"Json" field:"from_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SendEmailResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
type SendEmailParam struct {
|
||||||
|
Addresses []string
|
||||||
|
Subject string
|
||||||
|
Body string
|
||||||
|
FromName string
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateSendEmailRequest(param SendEmailParam) (req *SendEmailRequest) {
|
||||||
|
req = &SendEmailRequest{
|
||||||
|
JsonRequest: &requests.JsonRequest{},
|
||||||
|
Addresses: param.Addresses,
|
||||||
|
Subject: param.Subject,
|
||||||
|
Body: param.Body,
|
||||||
|
FromName: param.FromName,
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/email/send")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateSendEmailResponse() (resp *SendEmailResponse) {
|
||||||
|
resp = &SendEmailResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
57
services/sms/feishu.go
Normal file
57
services/sms/feishu.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package sms
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SendFeiShuWebHookRequest struct {
|
||||||
|
*requests.JsonRequest
|
||||||
|
Do string `position:"Json" field:"do"`
|
||||||
|
Token string `position:"Json" field:"token"`
|
||||||
|
Content string `position:"Json" field:"content"`
|
||||||
|
Title string `position:"Json" field:"title"`
|
||||||
|
TitleColor string `position:"Json" field:"title_color"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SendFeiShuWebHookResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
FeishuData string `json:"feishu_data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type FeiShuWebHookDoType = string
|
||||||
|
|
||||||
|
const (
|
||||||
|
FeiShuWebHookDoTypeSendSimpleText FeiShuWebHookDoType = "sendSimpleText"
|
||||||
|
FeiShuWebHookDoTypeSendRichText FeiShuWebHookDoType = "sendRichText"
|
||||||
|
FeiShuWebHookDoTypeSendCardText FeiShuWebHookDoType = "sendCardText"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SendFeiShuWebHookParam struct {
|
||||||
|
Do FeiShuWebHookDoType
|
||||||
|
Token string
|
||||||
|
Content string
|
||||||
|
Title string
|
||||||
|
TitleColor string
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateSendFeiShuWebHookRequest(param SendFeiShuWebHookParam) (req *SendFeiShuWebHookRequest) {
|
||||||
|
req = &SendFeiShuWebHookRequest{
|
||||||
|
JsonRequest: &requests.JsonRequest{},
|
||||||
|
Do: param.Do,
|
||||||
|
Token: param.Token,
|
||||||
|
Content: param.Content,
|
||||||
|
Title: param.Title,
|
||||||
|
TitleColor: param.TitleColor,
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/feishu/webhook_send")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateSendFeiShuWebHookResponse() (resp *SendFeiShuWebHookResponse) {
|
||||||
|
resp = &SendFeiShuWebHookResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
52
services/sms/sms.go
Normal file
52
services/sms/sms.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package sms
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SendSmsRequest struct {
|
||||||
|
*requests.JsonRequest
|
||||||
|
Mobile string `position:"Json" field:"mobile"`
|
||||||
|
Type string `position:"Json" field:"type"`
|
||||||
|
Expired int64 `position:"Json" field:"expired"`
|
||||||
|
Code int64 `position:"Json" field:"code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SendSmsResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
type SmsType = string
|
||||||
|
|
||||||
|
const (
|
||||||
|
SmsTypeRegister SmsType = "reg" // 注册
|
||||||
|
SmsTypeBindPhone SmsType = "bind_phone" // 绑定手机号
|
||||||
|
)
|
||||||
|
|
||||||
|
type SendSmsParam struct {
|
||||||
|
Mobile string // 手机号
|
||||||
|
Type SmsType // 验证码类型
|
||||||
|
Expired int64 // 过期时间,秒数
|
||||||
|
Code int64 // 验证码
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
||||||
|
req = &SendSmsRequest{
|
||||||
|
JsonRequest: &requests.JsonRequest{},
|
||||||
|
Mobile: param.Mobile,
|
||||||
|
Type: param.Type,
|
||||||
|
Expired: param.Expired,
|
||||||
|
Code: param.Code,
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/sms/agg/send")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateSendSmsResponse() (resp *SendSmsResponse) {
|
||||||
|
resp = &SendSmsResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
77
services/stat/agent.go
Normal file
77
services/stat/agent.go
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package stat
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetAgentListReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
返回json格式如下:
|
||||||
|
{
|
||||||
|
“code": 0,
|
||||||
|
"msg": "success",
|
||||||
|
"data": {
|
||||||
|
"list": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
type GetAgentListResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data AgentList `json:"data"`
|
||||||
|
}
|
||||||
|
type AgentList struct {
|
||||||
|
List []Agent `json:"list"`
|
||||||
|
}
|
||||||
|
type Agent struct {
|
||||||
|
AgentId string `json:"agent_id"`
|
||||||
|
AgentName string `json:"agent_name"`
|
||||||
|
Media string `json:"media"`
|
||||||
|
Channel string `json:"channel"`
|
||||||
|
MediaName string `json:"media_name"`
|
||||||
|
ChannelName string `json:"channel_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//const key = "gr_new_game"
|
||||||
|
|
||||||
|
// CreateGetAgentListReq 获取推广渠道列表请求
|
||||||
|
func CreateGetAgentListReq(data map[string]string) *GetAgentListReq {
|
||||||
|
req := &GetAgentListReq{
|
||||||
|
&requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
|
||||||
|
ts := time.Now().Unix()
|
||||||
|
hash := md5.New()
|
||||||
|
hash.Write([]byte(fmt.Sprintf("%v%v", ts, key)))
|
||||||
|
hashBytes := hash.Sum(nil)
|
||||||
|
|
||||||
|
token := hex.EncodeToString(hashBytes)
|
||||||
|
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/agent/getAgentList")
|
||||||
|
req.Method = requests.POST
|
||||||
|
|
||||||
|
req.FormParams = data
|
||||||
|
if req.FormParams == nil {
|
||||||
|
req.FormParams = make(map[string]string)
|
||||||
|
}
|
||||||
|
req.FormParams["sign"] = token
|
||||||
|
req.FormParams["time"] = fmt.Sprintf("%v", ts)
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateGetAgentListResp 获取推广渠道列表响应
|
||||||
|
func CreateGetAgentListResp() *GetAgentListResp {
|
||||||
|
return &GetAgentListResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
@ -39,3 +39,13 @@ func (c *Client) SetUserNewGameAuth(req *SetUserNewGameAuthReq) (resp *SetUserNe
|
|||||||
err = c.DoAction(req, resp)
|
err = c.DoAction(req, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAgentList 获取推广渠道列表
|
||||||
|
func (c *Client) GetAgentList(req *GetAgentListReq) (resp *GetAgentListResp, err error) {
|
||||||
|
resp = CreateGetAgentListResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -52,3 +52,29 @@ func TestClient_SetUserNewGameAuth(t *testing.T) {
|
|||||||
|
|
||||||
fmt.Println(resp.Code, resp.Msg, resp.Data.Result)
|
fmt.Println(resp.Code, resp.Msg, resp.Data.Result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestClient_GetAgentList 查询代理列表单元测试
|
||||||
|
func TestClient_GetAgentList(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
req := CreateGetAgentListReq(map[string]string{
|
||||||
|
"agent_id": "4051,68017",
|
||||||
|
//"agent_id": "99",
|
||||||
|
})
|
||||||
|
|
||||||
|
resp, err := client.GetAgentList(req)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(resp.Code, resp.Msg, resp.Data)
|
||||||
|
|
||||||
|
// 断言 resp.Code = 1,且 resp.Data 不空为正常
|
||||||
|
if resp.Code != 1 || len(resp.Data.List) == 0 {
|
||||||
|
t.Errorf("GetAgentList test failed")
|
||||||
|
} else {
|
||||||
|
t.Log("GetAgentList test passed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user