Compare commits
No commits in common. "master" and "v1.1.4" have entirely different histories.
@ -171,9 +171,4 @@ func CreateDemoTestResponse() *DemoTestResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
终端调试打开方式, 需要在系统环境变量上加入(三选一):
|
|
||||||
```
|
|
||||||
DEBUG=sdk,signer,request
|
|
||||||
```
|
```
|
10
go.mod
10
go.mod
@ -1,10 +0,0 @@
|
|||||||
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
15
go.sum
@ -1,15 +0,0 @@
|
|||||||
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=
|
|
@ -1,13 +0,0 @@
|
|||||||
package credentials
|
|
||||||
|
|
||||||
type AliAppcodeCredential struct {
|
|
||||||
AccessKeyId string `json:"access_key_id" yaml:"access_key_id"`
|
|
||||||
AccessKeySecret string `json:"access_key_secret" yaml:"access_key_secret"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAliAppcodeCredential(accessKeyId, accessKeySecret string) *AliAppcodeCredential {
|
|
||||||
return &AliAppcodeCredential{
|
|
||||||
AccessKeyId: accessKeyId,
|
|
||||||
AccessKeySecret: accessKeySecret,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,160 +0,0 @@
|
|||||||
package auth
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"sort"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func signRaliRequest(request requests.AcsRequest, signer Signer) (err error) {
|
|
||||||
err = completeRaliSignParams(request, signer)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
stringToSign := buildRaliStringToSign(request)
|
|
||||||
request.SetStringToSign(stringToSign)
|
|
||||||
signature := signer.Sign(stringToSign, "")
|
|
||||||
request.GetHeaders()["X-Ca-Signature"] = signature
|
|
||||||
|
|
||||||
debug("GrSdk sign: %s", signature)
|
|
||||||
debug("GrSdk sign string: %s", strings.ReplaceAll(stringToSign, "\n", "#"))
|
|
||||||
debug("GrSdk sign: \r\n")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func completeRaliSignParams(request requests.AcsRequest, signer Signer) (err error) {
|
|
||||||
|
|
||||||
request.GetHeaders()["X-Ca-Timestamp"] = fmt.Sprintf("%d", time.Now().Unix()*1000)
|
|
||||||
request.GetHeaders()["X-Ca-Signature-Method"] = signer.GetName()
|
|
||||||
request.GetHeaders()["X-Ca-Nonce"] = utils.GetUUID()
|
|
||||||
request.GetHeaders()["X-Ca-Key"], err = signer.GetAccessKeyId()
|
|
||||||
|
|
||||||
if request.GetEnv() != "" {
|
|
||||||
request.GetHeaders()["X-Ca-Stage"] = request.GetEnv()
|
|
||||||
}
|
|
||||||
|
|
||||||
if request.GetMethod() == requests.POST {
|
|
||||||
request.GetHeaders()["Content-type"] = requests.Form
|
|
||||||
}
|
|
||||||
|
|
||||||
formString := utils.GetUrlFormedMap(request.GetFormParams())
|
|
||||||
request.SetContent(bytes.NewBufferString(formString).Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func buildRaliSignHeader(request requests.AcsRequest) (str1, str2 string) {
|
|
||||||
|
|
||||||
headParams := make(map[string]string)
|
|
||||||
signatureHeaders := make([]string, 0)
|
|
||||||
|
|
||||||
for key, val := range request.GetHeaders() {
|
|
||||||
headParams[key] = val
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(headParams, "X-Ca-Signature")
|
|
||||||
delete(headParams, "X-Ca-Signature-Headers")
|
|
||||||
delete(headParams, "Accept")
|
|
||||||
delete(headParams, "Content-MD5")
|
|
||||||
delete(headParams, "Content-Type")
|
|
||||||
delete(headParams, "Date")
|
|
||||||
|
|
||||||
for key, _ := range headParams {
|
|
||||||
signatureHeaders = append(signatureHeaders, key)
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Strings(signatureHeaders)
|
|
||||||
|
|
||||||
for _, key := range signatureHeaders {
|
|
||||||
str1 += fmt.Sprintf("%s:%s\n", key, headParams[key])
|
|
||||||
}
|
|
||||||
|
|
||||||
return strings.TrimRight(str1, "\n"), strings.Join(signatureHeaders, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
func buildRaliStringToSign(request requests.AcsRequest) (stringToSign string) {
|
|
||||||
signParams := make(map[string]string)
|
|
||||||
for key, value := range request.GetQueryParams() {
|
|
||||||
signParams[key] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.ToUpper(request.GetMethod()) == requests.POST {
|
|
||||||
for key, value := range request.GetFormParams() {
|
|
||||||
signParams[key] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
str1, str2 := buildRaliSignHeader(request)
|
|
||||||
|
|
||||||
stringToSign = request.GetMethod() + "\n"
|
|
||||||
stringToSign += request.GetHeaders()["Accept"] + "\n\n"
|
|
||||||
stringToSign += request.GetHeaders()["Content-type"] + "\n\n"
|
|
||||||
stringToSign += str1 + "\n"
|
|
||||||
stringToSign += request.GetActionName() + "?" + utils.GetUrlByKeySort(signParams)
|
|
||||||
request.GetHeaders()["X-Ca-Signature-Headers"] = str2
|
|
||||||
|
|
||||||
//stringToSign = utils.GetUrlFormedMap(signParams)
|
|
||||||
//stringToSign = strings.Replace(stringToSign, "+", "%20", -1)
|
|
||||||
//stringToSign = strings.Replace(stringToSign, "*", "%2A", -1)
|
|
||||||
//stringToSign = strings.Replace(stringToSign, "%7E", "~", -1)
|
|
||||||
//stringToSign = url.QueryEscape(stringToSign)
|
|
||||||
//stringToSign = request.GetMethod() + "&%2F&" + stringToSign
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func unsignRaliRequest(request *http.Request, signer Signer) (err error) {
|
|
||||||
signParams := make(map[string]string)
|
|
||||||
for key, value := range request.URL.Query() {
|
|
||||||
signParams[key] = value[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.ToUpper(request.Method) == requests.POST {
|
|
||||||
for key, value := range request.Form {
|
|
||||||
signParams[key] = value[0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if accessKey, err := signer.GetAccessKeyId(); err != nil {
|
|
||||||
return err
|
|
||||||
} else if accessKey == "" {
|
|
||||||
return errors.New("access key is not allow empty")
|
|
||||||
} else if accessKey != signParams["access_key"] {
|
|
||||||
return errors.New("illegal access key")
|
|
||||||
}
|
|
||||||
|
|
||||||
signValue, ok := signParams["sign"]
|
|
||||||
if !ok {
|
|
||||||
return errors.New("sign value is not exists")
|
|
||||||
} else {
|
|
||||||
delete(signParams, "sign")
|
|
||||||
}
|
|
||||||
|
|
||||||
stringToSign := utils.GetUrlFormedMap(signParams)
|
|
||||||
stringToSign = strings.Replace(stringToSign, "+", "%20", -1)
|
|
||||||
stringToSign = strings.Replace(stringToSign, "*", "%2A", -1)
|
|
||||||
stringToSign = strings.Replace(stringToSign, "%7E", "~", -1)
|
|
||||||
stringToSign = url.QueryEscape(stringToSign)
|
|
||||||
stringToSign = request.Method + "&%2F&" + stringToSign
|
|
||||||
debug("GrSdk sign: %s", stringToSign)
|
|
||||||
|
|
||||||
if timestamp, err := strconv.ParseInt(signParams["access_time"], 10, 64); err != nil {
|
|
||||||
return err
|
|
||||||
} else {
|
|
||||||
if time.Unix(timestamp, 0).Before(time.Now().Add(-5 * time.Minute)) {
|
|
||||||
err = errors.New("sign timeout 5 minute")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if signer.Sign(stringToSign, "&") != signValue {
|
|
||||||
return errors.New("sign string is not correct")
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,128 +0,0 @@
|
|||||||
package auth
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func signRoaRequest(request requests.AcsRequest, signer Signer) (err error) {
|
|
||||||
err = completeRoaSignParams(request, signer)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if _, isContainsSign := request.GetQueryParams()["sign"]; isContainsSign {
|
|
||||||
delete(request.GetQueryParams(), "sign")
|
|
||||||
}
|
|
||||||
|
|
||||||
stringToSign := buildRoaStringToSign(request)
|
|
||||||
request.SetStringToSign(stringToSign)
|
|
||||||
signature := signer.Sign(stringToSign, "&")
|
|
||||||
request.GetQueryParams()["sign"] = signature
|
|
||||||
debug("GrSdk sign: %s", signature)
|
|
||||||
debug("GrSdk sign string: %s", stringToSign)
|
|
||||||
debug("GrSdk sign: \r\n")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func completeRoaSignParams(request requests.AcsRequest, signer Signer) (err error) {
|
|
||||||
|
|
||||||
var accessKeyFrom string
|
|
||||||
if accessKeyFrom, err = signer.GetAccessKeyFrom(); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
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 request.GetMethod() == requests.POST {
|
|
||||||
request.GetHeaders()["Content-type"] = requests.Form
|
|
||||||
}
|
|
||||||
request.GetHeaders()["Gr-Sdk-From"] = accessKeyFrom
|
|
||||||
formString := utils.GetUrlFormedMap(request.GetFormParams())
|
|
||||||
request.SetContent(bytes.NewBufferString(formString).Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func buildRoaStringToSign(request requests.AcsRequest) (stringToSign string) {
|
|
||||||
signParams := make(map[string]string)
|
|
||||||
for key, value := range request.GetQueryParams() {
|
|
||||||
signParams[key] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.ToUpper(request.GetMethod()) == requests.POST {
|
|
||||||
for key, value := range request.GetFormParams() {
|
|
||||||
signParams[key] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stringToSign = utils.GetUrlFormedMap(signParams)
|
|
||||||
stringToSign = strings.Replace(stringToSign, "+", "%20", -1)
|
|
||||||
stringToSign = strings.Replace(stringToSign, "*", "%2A", -1)
|
|
||||||
stringToSign = strings.Replace(stringToSign, "%7E", "~", -1)
|
|
||||||
stringToSign = url.QueryEscape(stringToSign)
|
|
||||||
stringToSign = request.GetMethod() + "&%2F&" + stringToSign
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func unsignRoaRequest(request *http.Request, signer Signer) (err error) {
|
|
||||||
signParams := make(map[string]string)
|
|
||||||
for key, value := range request.URL.Query() {
|
|
||||||
signParams[key] = value[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.ToUpper(request.Method) == requests.POST {
|
|
||||||
for key, value := range request.Form {
|
|
||||||
signParams[key] = value[0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if accessKey, err := signer.GetAccessKeyId(); err != nil {
|
|
||||||
return err
|
|
||||||
} else if accessKey == "" {
|
|
||||||
return errors.New("access key is not allow empty")
|
|
||||||
} else if accessKey != signParams["access_key"] {
|
|
||||||
return errors.New("illegal access key")
|
|
||||||
}
|
|
||||||
|
|
||||||
signValue, ok := signParams["sign"]
|
|
||||||
if !ok {
|
|
||||||
return errors.New("sign value is not exists")
|
|
||||||
} else {
|
|
||||||
delete(signParams, "sign")
|
|
||||||
}
|
|
||||||
|
|
||||||
stringToSign := utils.GetUrlFormedMap(signParams)
|
|
||||||
stringToSign = strings.Replace(stringToSign, "+", "%20", -1)
|
|
||||||
stringToSign = strings.Replace(stringToSign, "*", "%2A", -1)
|
|
||||||
stringToSign = strings.Replace(stringToSign, "%7E", "~", -1)
|
|
||||||
stringToSign = url.QueryEscape(stringToSign)
|
|
||||||
stringToSign = request.Method + "&%2F&" + stringToSign
|
|
||||||
debug("GrSdk sign: %s", stringToSign)
|
|
||||||
|
|
||||||
if timestamp, err := strconv.ParseInt(signParams["access_time"], 10, 64); err != nil {
|
|
||||||
return err
|
|
||||||
} else {
|
|
||||||
if time.Unix(timestamp, 0).Before(time.Now().Add(-5 * time.Minute)) {
|
|
||||||
err = errors.New("sign timeout 5 minute")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if signer.Sign(stringToSign, "&") != signValue {
|
|
||||||
return errors.New("sign string is not correct")
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -24,8 +24,6 @@ func NewSignerWithCredential(credential Credential, commonApi func(request *requ
|
|||||||
signer = signers.NewAccessKeySigner(instance.ToAccessKeyCredential())
|
signer = signers.NewAccessKeySigner(instance.ToAccessKeyCredential())
|
||||||
case *credentials.StdTokenCredential:
|
case *credentials.StdTokenCredential:
|
||||||
signer = signers.NewStsTokenSigner(instance)
|
signer = signers.NewStsTokenSigner(instance)
|
||||||
case *credentials.AliAppcodeCredential:
|
|
||||||
signer = signers.NewAliAppcodeSigner(instance)
|
|
||||||
default:
|
default:
|
||||||
err = errors.New("UnsupportedCredentialErrorCode = SDK.UnsupportedCredential")
|
err = errors.New("UnsupportedCredentialErrorCode = SDK.UnsupportedCredential")
|
||||||
}
|
}
|
||||||
@ -33,19 +31,8 @@ func NewSignerWithCredential(credential Credential, commonApi func(request *requ
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Sign(request requests.AcsRequest, signer Signer) (err error) {
|
func Sign(request requests.AcsRequest, signer Signer) (err error) {
|
||||||
switch signer.(type) {
|
|
||||||
case *signers.AliAppcodeSigner:
|
|
||||||
err = signRaliRequest(request, signer)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO 根据rpc和roa两种风格签名,自行选择
|
//TODO 根据rpc和roa两种风格签名,自行选择
|
||||||
switch request.GetStyle() {
|
err = signRpcRequest(request, signer)
|
||||||
case requests.RPC:
|
|
||||||
err = signRpcRequest(request, signer)
|
|
||||||
case requests.ROA:
|
|
||||||
err = signRoaRequest(request, signer)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
package signers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/hmac"
|
|
||||||
"crypto/sha256"
|
|
||||||
"encoding/base64"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/auth/credentials"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AliAppcodeSigner struct {
|
|
||||||
credential *credentials.AliAppcodeCredential
|
|
||||||
}
|
|
||||||
|
|
||||||
func (signer *AliAppcodeSigner) GetName() string {
|
|
||||||
return "HmacSHA256"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (signer *AliAppcodeSigner) GetAccessKeyId() (string, error) {
|
|
||||||
return signer.credential.AccessKeyId, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (signer *AliAppcodeSigner) GetAccessKeyFrom() (string, error) {
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (signer *AliAppcodeSigner) Sign(stringToSign, secretSuffix string) string {
|
|
||||||
secret := signer.credential.AccessKeySecret + secretSuffix
|
|
||||||
return ShaHmac256(stringToSign, secret)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAliAppcodeSigner(credential *credentials.AliAppcodeCredential) *AliAppcodeSigner {
|
|
||||||
return &AliAppcodeSigner{
|
|
||||||
credential: credential,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ShaHmac256(source, secret string) string {
|
|
||||||
key := []byte(secret)
|
|
||||||
hmac1 := hmac.New(sha256.New, key)
|
|
||||||
hmac1.Write([]byte(source))
|
|
||||||
signedString := base64.StdEncoding.EncodeToString(hmac1.Sum(nil))
|
|
||||||
return signedString
|
|
||||||
}
|
|
@ -5,7 +5,6 @@ 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"
|
||||||
@ -19,7 +18,6 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -85,10 +83,6 @@ func (client *Client) InitClientConfig() (config *Config) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) Init() (err error) {
|
|
||||||
return client.InitWithAccessKey("", "", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) InitWithAccessKey(accessKeyId, accessKeySecret, accessKeyFrom string) (err error) {
|
func (client *Client) InitWithAccessKey(accessKeyId, accessKeySecret, accessKeyFrom string) (err error) {
|
||||||
config := client.InitWithConfig()
|
config := client.InitWithConfig()
|
||||||
credential := &credentials.BaseCredential{
|
credential := &credentials.BaseCredential{
|
||||||
@ -99,17 +93,6 @@ func (client *Client) InitWithAccessKey(accessKeyId, accessKeySecret, accessKeyF
|
|||||||
return client.InitWithOptions(config, credential)
|
return client.InitWithOptions(config, credential)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) InitWithAliAppcode(accessKeyId, accessKeySecret string, env ...string) (err error) {
|
|
||||||
config := client.InitWithConfig()
|
|
||||||
credential := credentials.NewAliAppcodeCredential(accessKeyId, accessKeySecret)
|
|
||||||
|
|
||||||
if len(env) > 0 {
|
|
||||||
config.Env = env[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
return client.InitWithOptions(config, credential)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) InitWithStsToken(accessKeyId, accessKeySecret, accessKeyFrom string) (err error) {
|
func (client *Client) InitWithStsToken(accessKeyId, accessKeySecret, accessKeyFrom string) (err error) {
|
||||||
config := client.InitWithConfig()
|
config := client.InitWithConfig()
|
||||||
credential := &credentials.StdTokenCredential{
|
credential := &credentials.StdTokenCredential{
|
||||||
@ -272,8 +255,8 @@ func (client *Client) DoActionWithSigner(request requests.AcsRequest, response r
|
|||||||
func (client *Client) buildRequestWithSigner(request requests.AcsRequest, signer auth.Signer) (httpRequest *http.Request, err error) {
|
func (client *Client) buildRequestWithSigner(request requests.AcsRequest, signer auth.Signer) (httpRequest *http.Request, err error) {
|
||||||
// init param
|
// init param
|
||||||
domain := request.GetDomain()
|
domain := request.GetDomain()
|
||||||
if strings.Index(domain.Default, ".") < 0 {
|
if strings.Index(domain, ".") < 0 {
|
||||||
domain.Default += defaultDomain
|
domain += defaultDomain
|
||||||
request.SetDomain(domain)
|
request.SetDomain(domain)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,10 +264,6 @@ func (client *Client) buildRequestWithSigner(request requests.AcsRequest, signer
|
|||||||
request.SetScheme(client.config.Scheme)
|
request.SetScheme(client.config.Scheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
if request.GetEnv() == "" && client.config.Env != "" {
|
|
||||||
request.SetEnv(client.config.Env)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = requests.InitParam(request)
|
err = requests.InitParam(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -317,7 +296,6 @@ func (client *Client) buildRequestWithSigner(request requests.AcsRequest, signer
|
|||||||
if host, isContainsHost := request.GetHeaders()["host"]; isContainsHost {
|
if host, isContainsHost := request.GetHeaders()["host"]; isContainsHost {
|
||||||
httpRequest.Host = host
|
httpRequest.Host = host
|
||||||
}
|
}
|
||||||
|
|
||||||
userAgent := DefaultUserAgent
|
userAgent := DefaultUserAgent
|
||||||
httpRequest.Header.Set("User-Agent", userAgent)
|
httpRequest.Header.Set("User-Agent", userAgent)
|
||||||
|
|
||||||
@ -361,10 +339,3 @@ 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()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
@ -14,7 +14,6 @@ type Config struct {
|
|||||||
UserAgent string `default:""`
|
UserAgent string `default:""`
|
||||||
Scheme string `default:"HTTP"`
|
Scheme string `default:"HTTP"`
|
||||||
Timeout time.Duration `default:"5"`
|
Timeout time.Duration `default:"5"`
|
||||||
Env string `default:""`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig() *Config {
|
func NewConfig() *Config {
|
||||||
|
@ -26,11 +26,3 @@ func (request *CommonRequest) BuildQueries() string {
|
|||||||
func (request *CommonRequest) GetBodyReader() io.Reader {
|
func (request *CommonRequest) GetBodyReader() io.Reader {
|
||||||
return request.Ontology.GetBodyReader()
|
return request.Ontology.GetBodyReader()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *CommonRequest) GetStyle() string {
|
|
||||||
return request.Ontology.GetStyle()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *CommonRequest) InitWithApiInfo(domain Host, version, urlPath string) {
|
|
||||||
request.Ontology.InitWithApiInfo(domain, version, urlPath)
|
|
||||||
}
|
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
package requests
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils"
|
|
||||||
"io"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type JsonRequest struct {
|
|
||||||
*baseRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) init() {
|
|
||||||
request.baseRequest = defaultBaseRequest()
|
|
||||||
request.baseRequest.AddHeaderParam("Content-Type", Json)
|
|
||||||
request.Method = POST
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) BuildUrl() string {
|
|
||||||
|
|
||||||
var hostname string
|
|
||||||
if request.Domain.Func == nil {
|
|
||||||
hostname = request.Domain.Default
|
|
||||||
} else if hostname = request.Domain.Func(request.GetEnv()); hostname == "" {
|
|
||||||
hostname = request.Domain.Default
|
|
||||||
}
|
|
||||||
|
|
||||||
url := fmt.Sprintf("%s://%s", strings.ToLower(request.Scheme), hostname)
|
|
||||||
if len(request.Port) > 0 {
|
|
||||||
url = fmt.Sprintf("%s:%s", url, request.Port)
|
|
||||||
}
|
|
||||||
return url + request.BuildQueries()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) GetStyle() string {
|
|
||||||
return STREAM
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) BuildQueries() string {
|
|
||||||
path := strings.TrimLeft(strings.TrimSpace(request.GetActionName()), "/")
|
|
||||||
mod := "&"
|
|
||||||
if !strings.Contains(path, "?") {
|
|
||||||
mod = "?"
|
|
||||||
}
|
|
||||||
request.queries = "/" + path + mod + utils.GetUrlFormedMap(request.QueryParams)
|
|
||||||
return request.queries
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) GetActionName() string {
|
|
||||||
return request.actionName
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) InitWithApiInfo(domain Host, version, urlPath string) {
|
|
||||||
request.init()
|
|
||||||
request.SetDomain(domain)
|
|
||||||
request.version = version
|
|
||||||
request.actionName = urlPath
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *JsonRequest) GetBodyReader() io.Reader {
|
|
||||||
if request.JsonParams != nil && len(request.JsonParams) > 0 {
|
|
||||||
body, err := json.Marshal(request.JsonParams)
|
|
||||||
if err == nil {
|
|
||||||
return bytes.NewReader(body)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return strings.NewReader("")
|
|
||||||
}
|
|
@ -12,9 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RPC = "RPC"
|
RPC = "RPC"
|
||||||
ROA = "ROA"
|
ROA = "ROA"
|
||||||
STREAM = "STREAM"
|
|
||||||
|
|
||||||
HTTP = "HTTP"
|
HTTP = "HTTP"
|
||||||
HTTPS = "HTTPS"
|
HTTPS = "HTTPS"
|
||||||
@ -32,30 +31,19 @@ const (
|
|||||||
HEAD = "HEAD"
|
HEAD = "HEAD"
|
||||||
OPTIONS = "OPTIONS"
|
OPTIONS = "OPTIONS"
|
||||||
|
|
||||||
Json = "application/json"
|
Json = "application/json"
|
||||||
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"
|
|
||||||
PRE = "PRE"
|
|
||||||
RELEASE = "RELEASE"
|
|
||||||
|
|
||||||
HeaderSeparator = "\n"
|
HeaderSeparator = "\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Host struct {
|
|
||||||
Default string
|
|
||||||
Func func(string) string
|
|
||||||
}
|
|
||||||
|
|
||||||
var debug utils.Debug
|
var debug utils.Debug
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -73,43 +61,35 @@ type AcsRequest interface {
|
|||||||
GetFormParams() map[string]string
|
GetFormParams() map[string]string
|
||||||
GetMethod() string
|
GetMethod() string
|
||||||
GetScheme() string
|
GetScheme() string
|
||||||
GetDomain() Host
|
GetDomain() string
|
||||||
SetDomain(host Host)
|
|
||||||
GetActionName() string
|
GetActionName() string
|
||||||
GetAcceptFormat() string
|
GetAcceptFormat() string
|
||||||
GetAccept() string
|
|
||||||
GetHeaders() map[string]string
|
GetHeaders() map[string]string
|
||||||
GetStyle() string
|
|
||||||
InitWithApiInfo(domain Host, version, urlPath string)
|
|
||||||
GetEnv() string
|
|
||||||
SetEnv(string)
|
|
||||||
|
|
||||||
BuildUrl() string
|
BuildUrl() string
|
||||||
BuildQueries() string
|
BuildQueries() string
|
||||||
|
|
||||||
SetScheme(scheme string)
|
SetScheme(scheme string)
|
||||||
SetContent(content []byte)
|
SetContent(content []byte)
|
||||||
|
SetDomain(host string)
|
||||||
SetStringToSign(stringToSign string)
|
SetStringToSign(stringToSign string)
|
||||||
GetStringToSign() string
|
GetStringToSign() string
|
||||||
GetBodyReader() io.Reader
|
GetBodyReader() io.Reader
|
||||||
|
|
||||||
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 {
|
||||||
Scheme string
|
Scheme string
|
||||||
Method string
|
Method string
|
||||||
Port string
|
Port string
|
||||||
Domain Host
|
Domain string
|
||||||
From string
|
From string
|
||||||
ReadTimeout time.Duration
|
ReadTimeout time.Duration
|
||||||
ConnectTimeout time.Duration
|
ConnectTimeout time.Duration
|
||||||
isInsecure *bool
|
isInsecure *bool
|
||||||
Env string
|
|
||||||
|
|
||||||
AcceptFormat string
|
AcceptFormat string
|
||||||
actionName string
|
actionName string
|
||||||
@ -121,21 +101,12 @@ 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
|
||||||
stringToSign string
|
stringToSign string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *baseRequest) GetEnv() string {
|
|
||||||
return request.Env
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *baseRequest) SetEnv(e string) {
|
|
||||||
request.Env = e
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *baseRequest) GetStringToSign() string {
|
func (request *baseRequest) GetStringToSign() string {
|
||||||
return request.stringToSign
|
return request.stringToSign
|
||||||
}
|
}
|
||||||
@ -148,16 +119,6 @@ func (request *baseRequest) GetAcceptFormat() string {
|
|||||||
return request.AcceptFormat
|
return request.AcceptFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *baseRequest) GetAccept() string {
|
|
||||||
switch request.GetAcceptFormat() {
|
|
||||||
case JSON:
|
|
||||||
return Json
|
|
||||||
case XML:
|
|
||||||
return Xml
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *baseRequest) GetHeaders() map[string]string {
|
func (request *baseRequest) GetHeaders() map[string]string {
|
||||||
return request.Headers
|
return request.Headers
|
||||||
}
|
}
|
||||||
@ -170,7 +131,7 @@ func (request *baseRequest) SetScheme(scheme string) {
|
|||||||
request.Scheme = scheme
|
request.Scheme = scheme
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *baseRequest) SetDomain(host Host) {
|
func (request *baseRequest) SetDomain(host string) {
|
||||||
request.Domain = host
|
request.Domain = host
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +139,7 @@ func (request *baseRequest) GetScheme() string {
|
|||||||
return request.Scheme
|
return request.Scheme
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *baseRequest) GetDomain() Host {
|
func (request *baseRequest) GetDomain() string {
|
||||||
return request.Domain
|
return request.Domain
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +183,7 @@ func (request *baseRequest) SetStringToSign(stringToSign string) {
|
|||||||
request.stringToSign = stringToSign
|
request.stringToSign = stringToSign
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *baseRequest) AddHeaderParam(key, val string) {
|
func (request *baseRequest) addHeaderParam(key, val string) {
|
||||||
request.Headers[key] = val
|
request.Headers[key] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,10 +195,6 @@ 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,
|
||||||
@ -250,7 +207,6 @@ func defaultBaseRequest() (request *baseRequest) {
|
|||||||
"Accept-Encoding": Json,
|
"Accept-Encoding": Json,
|
||||||
},
|
},
|
||||||
FormParams: make(map[string]string),
|
FormParams: make(map[string]string),
|
||||||
JsonParams: make(map[string]any),
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -299,24 +255,22 @@ func flatRepeatedList(reflectValue reflect.Value, request AcsRequest, position s
|
|||||||
value = fieldDefault
|
value = fieldDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
err = addParam(request, fieldPosition, name, value, reflectValue.Field(i).Interface())
|
err = addParam(request, fieldPosition, name, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func addParam(request AcsRequest, position, key, value string, vAny any) (err error) {
|
func addParam(request AcsRequest, position, key, value string) (err error) {
|
||||||
if len(value) > 0 {
|
if len(value) > 0 {
|
||||||
switch position {
|
switch position {
|
||||||
case Header:
|
case Header:
|
||||||
request.AddHeaderParam(key, value)
|
request.addHeaderParam(key, value)
|
||||||
case Query:
|
case Query:
|
||||||
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,30 +13,17 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *RpcRequest) BuildUrl() string {
|
func (request *RpcRequest) BuildUrl() string {
|
||||||
|
url := fmt.Sprintf("%s://%s", strings.ToLower(request.Scheme), request.Domain)
|
||||||
var hostname string
|
|
||||||
if request.Domain.Func == nil {
|
|
||||||
hostname = request.Domain.Default
|
|
||||||
} else if hostname = request.Domain.Func(request.GetEnv()); hostname == "" {
|
|
||||||
hostname = request.Domain.Default
|
|
||||||
}
|
|
||||||
|
|
||||||
url := fmt.Sprintf("%s://%s", strings.ToLower(request.Scheme), hostname)
|
|
||||||
if len(request.Port) > 0 {
|
if len(request.Port) > 0 {
|
||||||
url = fmt.Sprintf("%s:%s", url, request.Port)
|
url = fmt.Sprintf("%s:%s", url, request.Port)
|
||||||
}
|
}
|
||||||
return url + request.BuildQueries()
|
return url + request.BuildQueries()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *RpcRequest) GetStyle() string {
|
|
||||||
return RPC
|
|
||||||
}
|
|
||||||
|
|
||||||
func (request *RpcRequest) BuildQueries() string {
|
func (request *RpcRequest) BuildQueries() string {
|
||||||
path := strings.TrimLeft(strings.TrimSpace(request.GetActionName()), "/")
|
path := strings.TrimLeft(strings.TrimSpace(request.GetActionName()), "/")
|
||||||
request.queries = "/" + path + "?" + utils.GetUrlFormedMap(request.QueryParams)
|
request.queries = "/" + path + "?" + utils.GetUrlFormedMap(request.QueryParams)
|
||||||
@ -47,11 +34,12 @@ func (request *RpcRequest) GetActionName() string {
|
|||||||
return request.actionName
|
return request.actionName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *RpcRequest) InitWithApiInfo(domain Host, version, urlPath string) {
|
func (request *RpcRequest) InitWithApiInfo(domain, version, urlPath string) *RpcRequest {
|
||||||
request.init()
|
request.init()
|
||||||
request.SetDomain(domain)
|
request.SetDomain(domain)
|
||||||
request.version = version
|
request.version = version
|
||||||
request.actionName = urlPath
|
request.actionName = urlPath
|
||||||
|
return request
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *RpcRequest) GetBodyReader() io.Reader {
|
func (request *RpcRequest) GetBodyReader() io.Reader {
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
package requests
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils"
|
|
||||||
"io"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type StreamRequest struct {
|
|
||||||
*baseRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StreamRequest) init() {
|
|
||||||
s.baseRequest = defaultBaseRequest()
|
|
||||||
s.baseRequest.AddHeaderParam("Content-Type", FormData)
|
|
||||||
s.Method = POST
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StreamRequest) GetStyle() string {
|
|
||||||
return STREAM
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StreamRequest) InitWithApiInfo(domain Host, version, urlPath string) {
|
|
||||||
s.init()
|
|
||||||
s.SetDomain(domain)
|
|
||||||
s.version = version
|
|
||||||
s.actionName = urlPath
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StreamRequest) BuildUrl() string {
|
|
||||||
var hostname string
|
|
||||||
if s.Domain.Func == nil {
|
|
||||||
hostname = s.Domain.Default
|
|
||||||
} else if hostname = s.Domain.Func(s.GetEnv()); hostname == "" {
|
|
||||||
hostname = s.Domain.Default
|
|
||||||
}
|
|
||||||
|
|
||||||
url := fmt.Sprintf("%s://%s", strings.ToLower(s.Scheme), hostname)
|
|
||||||
if len(s.Port) > 0 {
|
|
||||||
url = fmt.Sprintf("%s:%s", url, s.Port)
|
|
||||||
}
|
|
||||||
return url + s.BuildQueries()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StreamRequest) BuildQueries() string {
|
|
||||||
path := strings.TrimLeft(strings.TrimSpace(s.GetActionName()), "/")
|
|
||||||
s.queries = "/" + path + "?" + utils.GetUrlFormedMap(s.QueryParams)
|
|
||||||
return s.queries
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StreamRequest) GetBodyReader() io.Reader {
|
|
||||||
return bytes.NewReader(s.Content)
|
|
||||||
}
|
|
@ -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,10 +97,7 @@ 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) {
|
||||||
err = jsoniter.Unmarshal(response.GetHttpContentBytes(), response)
|
json.Unmarshal(response.GetHttpContentBytes(), response)
|
||||||
if err != nil {
|
|
||||||
return errors.New("json Unmarshal:" + err.Error())
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,7 +108,7 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if format != "xml" {
|
if format != "xml" {
|
||||||
err = jsoniter.Unmarshal(response.GetHttpContentBytes(), response)
|
err = json.Unmarshal(response.GetHttpContentBytes(), response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("json Unmarshal:" + err.Error())
|
return errors.New("json Unmarshal:" + err.Error())
|
||||||
}
|
}
|
||||||
|
@ -1,63 +1,14 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
|
||||||
"crypto/rand"
|
|
||||||
"encoding/hex"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash"
|
|
||||||
rand2 "math/rand"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UUID [16]byte
|
|
||||||
|
|
||||||
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
||||||
|
|
||||||
func GetUUID() (uuidHex string) {
|
|
||||||
uuid := NewUUID()
|
|
||||||
uuidHex = hex.EncodeToString(uuid[:])
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewUUID() UUID {
|
|
||||||
ns := UUID{}
|
|
||||||
safeRandom(ns[:])
|
|
||||||
u := newFromHash(md5.New(), ns, RandStringBytes(16))
|
|
||||||
u[6] = (u[6] & 0x0f) | (byte(2) << 4)
|
|
||||||
u[8] = (u[8]&(0xff>>2) | (0x02 << 6))
|
|
||||||
|
|
||||||
return u
|
|
||||||
}
|
|
||||||
|
|
||||||
func RandStringBytes(n int) string {
|
|
||||||
b := make([]byte, n)
|
|
||||||
for i := range b {
|
|
||||||
b[i] = letterBytes[rand2.Intn(len(letterBytes))]
|
|
||||||
}
|
|
||||||
return string(b)
|
|
||||||
}
|
|
||||||
|
|
||||||
func newFromHash(h hash.Hash, ns UUID, name string) UUID {
|
|
||||||
u := UUID{}
|
|
||||||
h.Write(ns[:])
|
|
||||||
h.Write([]byte(name))
|
|
||||||
copy(u[:], h.Sum(nil))
|
|
||||||
|
|
||||||
return u
|
|
||||||
}
|
|
||||||
|
|
||||||
func safeRandom(dest []byte) {
|
|
||||||
if _, err := rand.Read(dest); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUrlFormedMap(source map[string]string) (urlEncoded string) {
|
func GetUrlFormedMap(source map[string]string) (urlEncoded string) {
|
||||||
urlEncoder := url.Values{}
|
urlEncoder := url.Values{}
|
||||||
for key, value := range source {
|
for key, value := range source {
|
||||||
@ -67,18 +18,6 @@ func GetUrlFormedMap(source map[string]string) (urlEncoded string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUrlByKeySort(source map[string]string) (url string) {
|
|
||||||
keys := make([]string, 0, len(source))
|
|
||||||
for k := range source {
|
|
||||||
keys = append(keys, k)
|
|
||||||
}
|
|
||||||
sort.Strings(keys)
|
|
||||||
for _, key := range keys {
|
|
||||||
url += fmt.Sprintf("%s=%s&", key, source[key])
|
|
||||||
}
|
|
||||||
return strings.TrimRight(url, "&")
|
|
||||||
}
|
|
||||||
|
|
||||||
func InitStructWithDefaultTag(bean interface{}) {
|
func InitStructWithDefaultTag(bean interface{}) {
|
||||||
beantype := reflect.TypeOf(bean)
|
beantype := reflect.TypeOf(bean)
|
||||||
for i := 0; i < beantype.Elem().NumField(); i++ {
|
for i := 0; i < beantype.Elem().NumField(); i++ {
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
package apk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AddApkRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
List string `position:"Body" field:"list" default:"[]" `
|
|
||||||
}
|
|
||||||
|
|
||||||
type AddApkResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Status bool `json:"status"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
Count int `json:"count"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateAddApkRequest() (req *AddApkRequest) {
|
|
||||||
req = &AddApkRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/apk/add")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateAddApkResponse() (response *AddApkResponse) {
|
|
||||||
response = &AddApkResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package apk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AddTopRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
Id int `position:"Body" field:"id" default:"0" `
|
|
||||||
Ids string `position:"Body" field:"ids" default:"" `
|
|
||||||
Top int `position:"Body" field:"top" default:"0"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AddTopResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Status bool `json:"status"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateAddTopRequest() (req *AddTopRequest) {
|
|
||||||
req = &AddTopRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/apk/AddTop")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateAddTopResponse() (response *AddTopResponse) {
|
|
||||||
response = &AddTopResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
package apk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2021-07-30"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
|
||||||
Default: "c.api.gaore.com",
|
|
||||||
Func: func(s string) string {
|
|
||||||
var a = map[string]string{
|
|
||||||
requests.RELEASE: "c.api.gaore.com",
|
|
||||||
requests.PRE: "c.api.gaore.com",
|
|
||||||
requests.TEST: "c.api.gaore.com",
|
|
||||||
}
|
|
||||||
return a[s]
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client) {
|
|
||||||
client = &Client{}
|
|
||||||
client.InitWithAccessKey("", "", "")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//打包任务添加优先级
|
|
||||||
func (c *Client) AddApkTop(req *AddTopRequest) (response *AddTopResponse, err error) {
|
|
||||||
response = CreateAddTopResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//添加打包任务
|
|
||||||
func (c *Client) AddApk(req *AddApkRequest) (response *AddApkResponse, err error) {
|
|
||||||
response = CreateAddApkResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//清除cdn
|
|
||||||
func (c *Client) RefreshApkR(req *RefreshApkRequest) (response *RefreshApkResponse, err error) {
|
|
||||||
response = CreateRefreshApkResponse()
|
|
||||||
if len(req.CdnUrlArray) > 0 {
|
|
||||||
cdnurls, _ := json.Marshal(req.CdnUrlArray)
|
|
||||||
req.cdnUrls = string(cdnurls)
|
|
||||||
}
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取打包日志
|
|
||||||
func (c *Client) SearchApk(req *SearchApkRequest) (response *SearchApkResponse, err error) {
|
|
||||||
response = CreateSearchApkResponse()
|
|
||||||
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package apk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestClient_GetUserInfo(t *testing.T) {
|
|
||||||
c := NewClient()
|
|
||||||
req := CreateSearchApkRequest()
|
|
||||||
req.GameIds = "3503"
|
|
||||||
req.Ver = "1.0.0"
|
|
||||||
req.SetReadTimeout(60 * time.Second)
|
|
||||||
resp, err := c.SearchApk(req)
|
|
||||||
|
|
||||||
fmt.Println(req)
|
|
||||||
fmt.Println(resp.GetHttpContentString())
|
|
||||||
fmt.Println(err)
|
|
||||||
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package apk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type RefreshApkRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
cdnUrls string `position:"Body" field:"cdn_urls" default:"[]" `
|
|
||||||
CdnUrlArray []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type RefreshApkResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Status bool `json:"status"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data map[string]string `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateRefreshApkRequest() (req *RefreshApkRequest) {
|
|
||||||
req = &RefreshApkRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/apk/refresh")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateRefreshApkResponse() (response *RefreshApkResponse) {
|
|
||||||
response = &RefreshApkResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
package apk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type SearchApkRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
StartTime string `position:"Body" field:"startTime" default:"" `
|
|
||||||
EndTime string `position:"Body" field:"endTime" default:"" `
|
|
||||||
State string `position:"Body" field:"state" default:"" `
|
|
||||||
SiteIds string `position:"Body" field:"siteIds" default:"" `
|
|
||||||
Ver string `position:"Body" field:"ver" default:"" `
|
|
||||||
SiteId int `position:"Body" field:"siteId" default:"" `
|
|
||||||
AgentId int `position:"Body" field:"agentId" default:"" `
|
|
||||||
Top int `position:"Body" field:"top" default:"" `
|
|
||||||
GameIds string `position:"Body" field:"gameIds" default:"" `
|
|
||||||
Autor string `position:"Body" field:"autor" default:"" `
|
|
||||||
Page int `position:"Body" field:"page" default:"1" `
|
|
||||||
Pagesize int `position:"Body" field:"pagesize" default:"20" `
|
|
||||||
Order string `position:"Body" field:"order" default:"" `
|
|
||||||
}
|
|
||||||
|
|
||||||
type ApkLog struct {
|
|
||||||
ID int `json:"Id"`
|
|
||||||
GameID int `json:"GameId"`
|
|
||||||
GameName string `json:"GameName"`
|
|
||||||
Ver string `json:"Ver"`
|
|
||||||
Top int `json:"Top"`
|
|
||||||
AgentID int `json:"AgentId"`
|
|
||||||
SiteID int `json:"SiteId"`
|
|
||||||
Addtime time.Time `json:"Addtime"`
|
|
||||||
Edittime time.Time `json:"Edittime"`
|
|
||||||
State int `json:"State"`
|
|
||||||
Times int `json:"Times"`
|
|
||||||
ReleaseTime int `json:"ReleaseTime"`
|
|
||||||
Env int `json:"Env"`
|
|
||||||
AliOss int `json:"AliOss"`
|
|
||||||
NeedCdn bool `json:"NeedCdn"`
|
|
||||||
Autor string `json:"Autor"`
|
|
||||||
Ext string `json:"Ext"`
|
|
||||||
IsAugment bool `json:"IsAugment"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SearchApkResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Status bool `json:"status"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
Page int `json:"Page"`
|
|
||||||
PageSize int `json:"PageSize"`
|
|
||||||
Total int `json:"Total"`
|
|
||||||
List []ApkLog `json:"List"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateSearchApkRequest() (req *SearchApkRequest) {
|
|
||||||
req = &SearchApkRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/apk/list")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateSearchApkResponse() (response *SearchApkResponse) {
|
|
||||||
response = &SearchApkResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package callback
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2021-11-30"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
|
||||||
Default: "callback.api.gaore.com",
|
|
||||||
Func: func(s string) string {
|
|
||||||
var a = map[string]string{
|
|
||||||
requests.RELEASE: "callback.api.gaore.com",
|
|
||||||
requests.PRE: "callback.api.gaore.com",
|
|
||||||
requests.TEST: "callback.api.gaore.com",
|
|
||||||
}
|
|
||||||
return a[s]
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client) {
|
|
||||||
client = &Client{}
|
|
||||||
client.InitWithAccessKey("", "", "")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//上报关键行为
|
|
||||||
func (c *Client) SendAction(req *SendActionRequest) (response *SendActionResponse, err error) {
|
|
||||||
response = CreateSendActionResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 上报激活
|
|
||||||
func (c *Client) SendActive() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 上报付费
|
|
||||||
|
|
||||||
// 上报注册
|
|
@ -1,49 +0,0 @@
|
|||||||
package callback
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
const OS_ANDROID = 2
|
|
||||||
|
|
||||||
const OS_IOS = 1
|
|
||||||
|
|
||||||
type SendActionRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
GameId int64 `position:"Query" field:"game_id" default:"" `
|
|
||||||
AgentId int64 `position:"Query" field:"agent_id" default:"" `
|
|
||||||
SiteId int64 `position:"Query" field:"site_id" default:"" `
|
|
||||||
Imei string `position:"Query" field:"imei" default:"" `
|
|
||||||
Oaid string `position:"Query" field:"oaid" default:"" `
|
|
||||||
Ip string `position:"Query" field:"ip" default:"" `
|
|
||||||
Ua string `position:"Query" field:"ua" default:"" `
|
|
||||||
Os int `position:"Query" field:"os" default:"" `
|
|
||||||
ParamsArray []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type SendActionResponseData struct {
|
|
||||||
Account string `json:"account"`
|
|
||||||
Total int `json:"total"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SendActionResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Data SendActionResponseData `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateSendActionRequest() (req *SendActionRequest) {
|
|
||||||
req = &SendActionRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/callback/ads_callback/sendAction")
|
|
||||||
req.Method = requests.GET
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateSendActionResponse() (response *SendActionResponse) {
|
|
||||||
response = &SendActionResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
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{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
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{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
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{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,134 +0,0 @@
|
|||||||
package cs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2025-06-10"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST = requests.Host{
|
|
||||||
Default: "cs",
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.Init()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) GetFaq(req *GetFaqRequest) (resp *GetFaqResponse, err error) {
|
|
||||||
resp = CreateGetFaqResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) GetUserInfo(req *GetUserInfoRequest) (resp *GetUserInfoResponse, err error) {
|
|
||||||
resp = CreateGetUserInfoResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) GetCsUserRoleList(req *GetUserRoleListRequest) (resp *GetUserRoleListResponse, err error) {
|
|
||||||
resp = CreateGetUserRoleListResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) GetUserServerList(req *GetUserServerListRequest) (resp *GetUserServerListResponse, err error) {
|
|
||||||
resp = CreateGetUserServerListResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) SendSmsCode(req *SendSmsRequest) (resp *SendSmsResponse, err error) {
|
|
||||||
resp = CreateSendSmsResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) Upload(req *UploadRequest) (resp *UploadResponse, err error) {
|
|
||||||
// check file stream
|
|
||||||
if req.FileStream == nil {
|
|
||||||
err = errors.New("stream is empty")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 必须设置content
|
|
||||||
req.SetContent(req.FileStream)
|
|
||||||
resp = CreateUploadResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (client *Client) GetOrderTemplateDetail(req *OrderTemplateDetailReq) (resp *OrderTemplateDetailResp, err error) {
|
|
||||||
resp = CreateOrderTemplateDetailResp()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) GetOrderFurtherPart(req *GetOrderFurtherPartRequest) (resp *GetOrderFurtherPartResponse, err error) {
|
|
||||||
resp = CreateGetOrderFurtherPartResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) OrderUrgent(req *OrderUrgentRequest) (resp *OrderUrgentResponse, err error) {
|
|
||||||
resp = CreateOrderUrgentResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) OrderUpdateHandle(req *OrderUpdateHandleRequest) (resp *OrderUpdateHandleResponse, err error) {
|
|
||||||
resp = CreateOrderUpdateHandleResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (client *Client) OrderAppraise(req *OrderAppraiseRequest) (resp *OrderAppraiseResponse, err error) {
|
|
||||||
resp = CreateOrderAppraiseResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (client *Client) OrderRestart(req *OrderRestartRequest) (resp *OrderRestartResponse, err error) {
|
|
||||||
resp = CreateOrderRestartResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (client *Client) OrderSubmit(req *OrderSubmitRequest) (resp *OrderSubmitResponse, err error) {
|
|
||||||
resp = CreateOrderSubmitResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) OrderFurtherPart(req *OrderFurtherPartRequest) (resp *OrderFurtherPartResponse, err error) {
|
|
||||||
resp = CreateOrderFurtherPartResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (client *Client) OrderRecordList(req *GetWorkOrderRecordListRequest) (resp *GetWorkOrderRecordListResponse, err error) {
|
|
||||||
resp = CreateGetWorkOrderRecordListResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (client *Client) OrderRecordDetail(req *GetWorkOrderRecordDetailReq) (resp *GetWorkOrderRecordDetailResp, err error) {
|
|
||||||
resp = CreateGetWorkOrderRecordDetailResp()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) GetFaqDetail(req *GetFaqDetailRequest) (resp *GetFaqDetailResponse, err error) {
|
|
||||||
resp = CreateGetFaqDetailResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) GetHotFaqList(req *GetHotFaqRequest) (resp *GetHotFaqResponse, err error) {
|
|
||||||
resp = CreateGetHotFaqResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,406 +0,0 @@
|
|||||||
package cs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客服工单服务,单元测试
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 获取faq树状数据
|
|
||||||
func TestGetFaq(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
req := CreateGetFaqRequest()
|
|
||||||
faq, err := client.GetFaq(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf(fmt.Sprintf("%#+v", faq))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取玩家基本信息
|
|
||||||
func TestGetUserInfo(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateGetUserInfoRequest("ws45265737")
|
|
||||||
info, err := client.GetUserInfo(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", info))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取玩家角色列表
|
|
||||||
func TestGetUserRoleList(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateGetUserRoleListRequest(int64(63610626), int64(2850))
|
|
||||||
info, err := client.GetCsUserRoleList(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if info.Code != 0 {
|
|
||||||
t.Error("获取玩家角色列表失败")
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", info))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", info))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取玩家区服列表
|
|
||||||
func TestGetUserServerList(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateGetUserServerListRequest(int64(63610626), int64(2850))
|
|
||||||
info, err := client.GetUserServerList(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if info.Code != 0 {
|
|
||||||
t.Error("获取玩家区服列表失败")
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", info))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", info))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 给玩家发送短信
|
|
||||||
func TestSendSms(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateSendSmsRequest(SendSmsReq{
|
|
||||||
Phone: "13725263463",
|
|
||||||
})
|
|
||||||
info, err := client.SendSmsCode(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if info.Code != 0 {
|
|
||||||
t.Error("给玩家发送短信失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", info))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 工单图片上传
|
|
||||||
func TestUpload(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
// 读取文件流
|
|
||||||
file, err := os.ReadFile("test.png")
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req := CreateUploadRequest()
|
|
||||||
req.FileStream = file
|
|
||||||
res, err := client.Upload(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("工单图片上传失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 工单模板查询
|
|
||||||
func TestGetOrderTemplateDetail(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
templateId := int64(12)
|
|
||||||
req := CreateOrderTemplateDetailReq(templateId)
|
|
||||||
res, err := client.GetOrderTemplateDetail(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("工单模板查询失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 工单补充字段设置
|
|
||||||
func TestGetOrderFurtherPart(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateGetOrderFurtherPartRequest(GetOrderFurtherPartParam{
|
|
||||||
OrderNum: "20250605092301764049"})
|
|
||||||
res, err := client.GetOrderFurtherPart(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("工单补充字段设置获取失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 用户催单
|
|
||||||
func TestOrderUrgent(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateOrderUrgentRequest(OrderUrgentParam{
|
|
||||||
OrderNum: "20250530173554491048"})
|
|
||||||
res, err := client.OrderUrgent(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("用户催单失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 用户更新工单处理标识
|
|
||||||
func TestOrderUpdateHandle(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateOrderUpdateHandleRequest(OrderUpdateHandleParam{
|
|
||||||
IsHandle: 1,
|
|
||||||
OrderNum: "20250530173554491048"})
|
|
||||||
res, err := client.OrderUpdateHandle(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("用户催单失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 用户评价工单
|
|
||||||
func TestOrderAppraise(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateOrderAppraiseRequest(OrderAppraiseParam{
|
|
||||||
OrderNum: "20250530173554491048",
|
|
||||||
Score: 5,
|
|
||||||
})
|
|
||||||
res, err := client.OrderAppraise(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("用户评价失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 工单重启
|
|
||||||
func TestOrderRestart(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateOrderRestartRequest(OrderRestartParam{
|
|
||||||
OrderNum: "20250530173554491048",
|
|
||||||
RemarkContent: "模拟用户重启",
|
|
||||||
RemarkPic: []string{},
|
|
||||||
})
|
|
||||||
res, err := client.OrderRestart(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("工单重启失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 提交工单
|
|
||||||
func TestOrderSubmit(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateOrderSubmitRequest(OrderSubmitParam{
|
|
||||||
GameId: 7991,
|
|
||||||
UserName: "ws45265737",
|
|
||||||
Uid: 65598086,
|
|
||||||
RoleId: "10676785",
|
|
||||||
RoleName: "流水行者",
|
|
||||||
ServerName: "血阳琉璃",
|
|
||||||
OrderTemplateCode: "btu7RoDj",
|
|
||||||
Detail: "我的问题是,组队这个玩法的初衷是希望实现大家能和身边认识的朋友一起下洞的目标。但是现在看来,很多玩家都选择了在游戏中随机匹配队友,而我们发现,组队机制暴露的绝大部分玩家体验问题都是在随机匹配中出现的。<br/>比如恶意踢人,又比如匹配到的玩家等级比较低,不符合自己本次下洞的目标,再或者是组队进入洞窟却发现队友已经快要收尾结束探险了。",
|
|
||||||
Phone: "13725263463",
|
|
||||||
ApplyIp: "183.63.75.58",
|
|
||||||
OrderParts: []OrderSubmitPart{
|
|
||||||
{
|
|
||||||
PartKey: "email",
|
|
||||||
PartName: "联系邮箱",
|
|
||||||
PartValue: "kingson2011@126.com",
|
|
||||||
PicValue: nil,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
PartKey: "pay_pic",
|
|
||||||
PartName: "充值凭证",
|
|
||||||
PartValue: "",
|
|
||||||
PicValue: []string{
|
|
||||||
"uploads/d1a/d1aba28357b89e7ebfc77e5c43fc81b7.jpeg",
|
|
||||||
"uploads/c37/c3726c5cf7175ed048f6c68416dbf30b.jpeg",
|
|
||||||
"uploads/ca2/ca285ae8feae8c60d51b53079fa9b2a9.jpeg",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
SmsCode: "7204",
|
|
||||||
})
|
|
||||||
res, err := client.OrderSubmit(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("工单提交失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 用户工单补充资料
|
|
||||||
func TestOrderFurtherPart(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateOrderFurtherPartRequest(OrderFurtherPartParam{
|
|
||||||
OrderNum: "20250611160840208567",
|
|
||||||
OrderParts: []OrderSubmitPart{
|
|
||||||
{
|
|
||||||
PartKey: "game_name",
|
|
||||||
PartName: "游戏名称",
|
|
||||||
PartValue: "镇魂街:最终章",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
res, err := client.OrderFurtherPart(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("用户工单补充资料失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 工单列表查询
|
|
||||||
func TestGetWorkOrderRecordList(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateGetWorkOrderRecordListRequest(GetWorkOrderRecordListParam{
|
|
||||||
HandleStatus: "",
|
|
||||||
UserName: "ws45265737",
|
|
||||||
GameId: 7991,
|
|
||||||
Page: 1,
|
|
||||||
PageSize: 20,
|
|
||||||
})
|
|
||||||
res, err := client.OrderRecordList(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("工单列表查询失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 工单详情查询
|
|
||||||
func TestOrderRecordDetail(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateGetWorkOrderRecordDetailRequest(OrderDetailParam{
|
|
||||||
OrderNum: "20250611160840208567",
|
|
||||||
})
|
|
||||||
res, err := client.OrderRecordDetail(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("工单详情查询失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取faq详情
|
|
||||||
func TestGetFaqDetail(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateGetFaqDetailRequest(FaqDetailRequest{
|
|
||||||
Id: int64(31),
|
|
||||||
})
|
|
||||||
res, err := client.GetFaqDetail(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 || res.Data.Id == 0 {
|
|
||||||
t.Error("获取faq详情失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取热门faq
|
|
||||||
func TestGetFaqHotList(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateGetHotFaqRequest()
|
|
||||||
res, err := client.GetHotFaqList(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 || len(res.Data) == 0 {
|
|
||||||
t.Error("获取热门faq失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
package cs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Faq 树状结构
|
|
||||||
type Faq struct {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
ParentId int64 `json:"parent_id"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
Answer string `json:"answer"`
|
|
||||||
Type int64 `json:"type"`
|
|
||||||
WorkOrderTemplateId int64 `json:"work_order_template_id"`
|
|
||||||
CreatedAt string `json:"created_at"`
|
|
||||||
UpdatedAt string `json:"updated_at"`
|
|
||||||
ProcessFlow string `json:"process_flow"`
|
|
||||||
Children []*Faq `json:"children"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetFaqRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetFaqResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data Faq `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetFaqRequest() (req *GetFaqRequest) {
|
|
||||||
req = &GetFaqRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/faq/list")
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetFaqResponse() (response *GetFaqResponse) {
|
|
||||||
response = &GetFaqResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// FaqDetail Faq详情
|
|
||||||
type FaqDetail struct {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
ParentId int64 `json:"parent_id"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
Answer string `json:"answer"`
|
|
||||||
Type int64 `json:"type"`
|
|
||||||
WorkOrderTemplateId int64 `json:"work_order_template_id"`
|
|
||||||
ProcessFlow string `json:"process_flow"`
|
|
||||||
}
|
|
||||||
type GetFaqDetailRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
Id int64 `position:"Json" field:"id"`
|
|
||||||
}
|
|
||||||
type GetFaqDetailResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data FaqDetail `json:"data"`
|
|
||||||
}
|
|
||||||
type FaqDetailRequest struct {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetFaqDetailRequest(param FaqDetailRequest) (req *GetFaqDetailRequest) {
|
|
||||||
req = &GetFaqDetailRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
Id: param.Id,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/faq/detail")
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateGetFaqDetailResponse() (response *GetFaqDetailResponse) {
|
|
||||||
response = &GetFaqDetailResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 热门faq列表
|
|
||||||
type HotFaq struct {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
}
|
|
||||||
type GetHotFaqRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
}
|
|
||||||
type GetHotFaqResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []HotFaq `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetHotFaqRequest() (req *GetHotFaqRequest) {
|
|
||||||
req = &GetHotFaqRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/faq/hot_list")
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateGetHotFaqResponse() (response *GetHotFaqResponse) {
|
|
||||||
response = &GetHotFaqResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,314 +0,0 @@
|
|||||||
package cs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客服工单,相关方法
|
|
||||||
*/
|
|
||||||
|
|
||||||
type UploadRequest struct {
|
|
||||||
*requests.StreamRequest
|
|
||||||
FileStream []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type UploadResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
FileName string `json:"file_name"`
|
|
||||||
FileUrl string `json:"file_url"`
|
|
||||||
FilePath string `json:"file_path"`
|
|
||||||
}
|
|
||||||
TraceId string `json:"trace_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateUploadRequest() (req *UploadRequest) {
|
|
||||||
req = &UploadRequest{
|
|
||||||
StreamRequest: &requests.StreamRequest{},
|
|
||||||
}
|
|
||||||
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/upload_image")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateUploadResponse() (resp *UploadResponse) {
|
|
||||||
return &UploadResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取工单补充字段设置
|
|
||||||
|
|
||||||
// GetOrderFurtherPartParam 请求参数
|
|
||||||
type GetOrderFurtherPartParam struct {
|
|
||||||
OrderNum string `json:"order_num"`
|
|
||||||
}
|
|
||||||
type GetOrderFurtherPartRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
OrderNum string `position:"Json" field:"order_num"`
|
|
||||||
}
|
|
||||||
type OrderFurtherPart struct {
|
|
||||||
OrderNum string `json:"order_num"`
|
|
||||||
FurtherParts []*OrderPart `json:"further_parts"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetOrderFurtherPartResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Data OrderFurtherPart `json:"data"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetOrderFurtherPartRequest(param GetOrderFurtherPartParam) (req *GetOrderFurtherPartRequest) {
|
|
||||||
req = &GetOrderFurtherPartRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
OrderNum: param.OrderNum,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/get_order_further_part")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateGetOrderFurtherPartResponse() (resp *GetOrderFurtherPartResponse) {
|
|
||||||
return &GetOrderFurtherPartResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrderUrgentParam 用户催单
|
|
||||||
type OrderUrgentParam struct {
|
|
||||||
OrderNum string `json:"order_num"`
|
|
||||||
}
|
|
||||||
type OrderUrgentRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
OrderNum string `position:"Json" field:"order_num"`
|
|
||||||
}
|
|
||||||
type OrderUrgentResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateOrderUrgentRequest(param OrderUrgentParam) (req *OrderUrgentRequest) {
|
|
||||||
req = &OrderUrgentRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
OrderNum: param.OrderNum,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/order_urgent")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateOrderUrgentResponse() (resp *OrderUrgentResponse) {
|
|
||||||
return &OrderUrgentResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrderUpdateHandleParam 更新工单处理标识
|
|
||||||
type OrderUpdateHandleParam struct {
|
|
||||||
OrderNum string `json:"order_num"`
|
|
||||||
IsHandle int64 `json:"is_handle"`
|
|
||||||
}
|
|
||||||
type OrderUpdateHandleRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
OrderNum string `position:"Json" field:"order_num"`
|
|
||||||
IsHandle int64 `position:"Json" field:"is_handle"`
|
|
||||||
}
|
|
||||||
type OrderUpdateHandleResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateOrderUpdateHandleRequest(param OrderUpdateHandleParam) (req *OrderUpdateHandleRequest) {
|
|
||||||
req = &OrderUpdateHandleRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
OrderNum: param.OrderNum,
|
|
||||||
IsHandle: param.IsHandle,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/order_handle")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateOrderUpdateHandleResponse() (resp *OrderUpdateHandleResponse) {
|
|
||||||
return &OrderUpdateHandleResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrderAppraiseParam 用户评价工单
|
|
||||||
type OrderAppraiseParam struct {
|
|
||||||
OrderNum string `json:"order_num"`
|
|
||||||
Score int `json:"score"`
|
|
||||||
}
|
|
||||||
type OrderAppraiseRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
OrderNum string `position:"Json" field:"order_num"`
|
|
||||||
Score int `position:"Json" field:"score"`
|
|
||||||
}
|
|
||||||
type OrderAppraiseResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateOrderAppraiseRequest(param OrderAppraiseParam) (req *OrderAppraiseRequest) {
|
|
||||||
req = &OrderAppraiseRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
OrderNum: param.OrderNum,
|
|
||||||
Score: param.Score,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/order_appraise")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateOrderAppraiseResponse() (resp *OrderAppraiseResponse) {
|
|
||||||
return &OrderAppraiseResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrderRestartParam 用户重启工单
|
|
||||||
type OrderRestartParam struct {
|
|
||||||
OrderNum string `json:"order_num"`
|
|
||||||
RemarkContent string `json:"remark_content"`
|
|
||||||
RemarkPic []string `json:"remark_pic"`
|
|
||||||
}
|
|
||||||
type OrderRestartRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
OrderNum string `position:"Json" field:"order_num"`
|
|
||||||
RemarkContent string `position:"Json" field:"remark_content"`
|
|
||||||
RemarkPic []string `position:"Json" field:"remark_pic"`
|
|
||||||
}
|
|
||||||
type OrderRestartResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateOrderRestartRequest(param OrderRestartParam) (req *OrderRestartRequest) {
|
|
||||||
req = &OrderRestartRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
OrderNum: param.OrderNum,
|
|
||||||
RemarkContent: param.RemarkContent,
|
|
||||||
RemarkPic: param.RemarkPic,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/order_restart")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateOrderRestartResponse() (resp *OrderRestartResponse) {
|
|
||||||
return &OrderRestartResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrderSubmitParam 工单提交
|
|
||||||
type OrderSubmitParam struct {
|
|
||||||
GameId int64 `json:"game_id"`
|
|
||||||
UserName string `json:"user_name"`
|
|
||||||
Uid int64 `json:"uid"`
|
|
||||||
RoleId string `json:"role_id"`
|
|
||||||
RoleName string `json:"role_name"`
|
|
||||||
ServerName string `json:"server_name"`
|
|
||||||
OrderTemplateCode string `json:"order_template_code"`
|
|
||||||
Detail string `json:"detail"`
|
|
||||||
Phone string `json:"phone"`
|
|
||||||
ApplyIp string `json:"apply_ip"`
|
|
||||||
OrderParts []OrderSubmitPart `json:"order_parts"`
|
|
||||||
SmsCode string `json:"sms_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type OrderSubmitPart struct {
|
|
||||||
PartId int64 `json:"part_id"`
|
|
||||||
PartKey string `json:"part_key"`
|
|
||||||
PartName string `json:"part_name"`
|
|
||||||
PartValue string `json:"part_value"`
|
|
||||||
PartType int64 `json:"part_type"`
|
|
||||||
PicValue []string `json:"pic_value"`
|
|
||||||
}
|
|
||||||
type OrderSubmitRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
GameId int64 `position:"Json" field:"game_id"`
|
|
||||||
UserName string `position:"Json" field:"user_name"`
|
|
||||||
Uid int64 `position:"Json" field:"uid"`
|
|
||||||
RoleId string `position:"Json" field:"role_id"`
|
|
||||||
RoleName string `position:"Json" field:"role_name"`
|
|
||||||
ServerName string `position:"Json" field:"server_name"`
|
|
||||||
OrderTemplateCode string `position:"Json" field:"order_template_code"`
|
|
||||||
Detail string `position:"Json" field:"detail"`
|
|
||||||
Phone string `position:"Json" field:"phone"`
|
|
||||||
ApplyIp string `position:"Json" field:"apply_ip"`
|
|
||||||
OrderParts []OrderSubmitPart `position:"Json" field:"order_parts"`
|
|
||||||
SmsCode string `position:"Json" field:"sms_code"`
|
|
||||||
}
|
|
||||||
type OrderSubmitResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
OrderNum string `json:"order_num"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateOrderSubmitRequest(param OrderSubmitParam) (req *OrderSubmitRequest) {
|
|
||||||
req = &OrderSubmitRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
GameId: param.GameId,
|
|
||||||
UserName: param.UserName,
|
|
||||||
Uid: param.Uid,
|
|
||||||
RoleId: param.RoleId,
|
|
||||||
RoleName: param.RoleName,
|
|
||||||
ServerName: param.ServerName,
|
|
||||||
OrderTemplateCode: param.OrderTemplateCode,
|
|
||||||
Detail: param.Detail,
|
|
||||||
Phone: param.Phone,
|
|
||||||
ApplyIp: param.ApplyIp,
|
|
||||||
OrderParts: param.OrderParts,
|
|
||||||
SmsCode: param.SmsCode,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/order_submit")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateOrderSubmitResponse() (resp *OrderSubmitResponse) {
|
|
||||||
return &OrderSubmitResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrderFurtherPartParam 工单补充资料
|
|
||||||
type OrderFurtherPartParam struct {
|
|
||||||
OrderNum string `json:"order_num"`
|
|
||||||
OrderParts []OrderSubmitPart `json:"order_parts"`
|
|
||||||
}
|
|
||||||
type OrderFurtherPartRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
OrderNum string `position:"Json" field:"order_num"`
|
|
||||||
OrderParts []OrderSubmitPart `position:"Json" field:"order_parts"`
|
|
||||||
}
|
|
||||||
type OrderFurtherPartResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateOrderFurtherPartRequest(param OrderFurtherPartParam) (req *OrderFurtherPartRequest) {
|
|
||||||
req = &OrderFurtherPartRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
OrderNum: param.OrderNum,
|
|
||||||
OrderParts: param.OrderParts,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/order_further_data")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateOrderFurtherPartResponse() (resp *OrderFurtherPartResponse) {
|
|
||||||
return &OrderFurtherPartResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,135 +0,0 @@
|
|||||||
package cs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 获取客服工单列表
|
|
||||||
|
|
||||||
type GetWorkOrderRecordListParam struct {
|
|
||||||
OrderNum string `position:"Json" field:"order_num"`
|
|
||||||
Page int64 `position:"Json" field:"page"`
|
|
||||||
PageSize int64 `position:"Json" field:"page_size"`
|
|
||||||
UserName string `position:"Json" field:"user_name"`
|
|
||||||
GameId int64 `position:"Json" field:"game_id"`
|
|
||||||
HandleStatus string `position:"Json" field:"handle_status"`
|
|
||||||
}
|
|
||||||
type OrderRecord struct {
|
|
||||||
OrderNum string `json:"order_num"`
|
|
||||||
WorkOrderTemplateFirstLevelName string `json:"work_order_template_first_level_name"`
|
|
||||||
UserName string `json:"user_name"`
|
|
||||||
GameId int64 `json:"game_id"`
|
|
||||||
GameName string `json:"game_name"`
|
|
||||||
RoleId string `json:"role_id"`
|
|
||||||
RoleName string `json:"role_name"`
|
|
||||||
ServerName string `json:"server_name"`
|
|
||||||
Detail string `json:"detail"`
|
|
||||||
ApplyTime string `json:"apply_time"`
|
|
||||||
HandleStatus string `json:"handle_status"`
|
|
||||||
HandleStatusName string `json:"handle_status_name"`
|
|
||||||
IsUrgent int64 `json:"is_urgent"`
|
|
||||||
IsAppraise int64 `json:"is_appraise"`
|
|
||||||
FinishTime string `json:"finish_time"`
|
|
||||||
OrderParts []*OrderSubmitPart `json:"order_parts"`
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
WorkOrderTemplateFirstLevelId int64 `json:"work_order_template_first_level_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PageInfoResp 分页响应
|
|
||||||
type PageInfoResp struct {
|
|
||||||
Page int `json:"page"`
|
|
||||||
PageSize int `json:"page_size"`
|
|
||||||
TotalNumber int `json:"total_number"`
|
|
||||||
TotalPage int `json:"total_page"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetWorkOrderRecordListResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Data struct {
|
|
||||||
Data []*OrderRecord `json:"data"`
|
|
||||||
PageInfo *PageInfoResp `json:"page_info"`
|
|
||||||
} `json:"data"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
TraceId string `json:"trace_id"`
|
|
||||||
}
|
|
||||||
type GetWorkOrderRecordListRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
OrderNum string `position:"Json" field:"order_num"`
|
|
||||||
Page int64 `position:"Json" field:"page"`
|
|
||||||
PageSize int64 `position:"Json" field:"page_size"`
|
|
||||||
UserName string `position:"Json" field:"user_name"`
|
|
||||||
GameId int64 `position:"Json" field:"game_id"`
|
|
||||||
HandleStatus string `position:"Json" field:"handle_status"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetWorkOrderRecordListRequest(param GetWorkOrderRecordListParam) (req *GetWorkOrderRecordListRequest) {
|
|
||||||
req = &GetWorkOrderRecordListRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
}
|
|
||||||
req.OrderNum = param.OrderNum
|
|
||||||
req.Page = param.Page
|
|
||||||
req.PageSize = param.PageSize
|
|
||||||
req.UserName = param.UserName
|
|
||||||
req.GameId = param.GameId
|
|
||||||
req.HandleStatus = param.HandleStatus
|
|
||||||
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/order_record_list")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateGetWorkOrderRecordListResponse() (resp *GetWorkOrderRecordListResponse) {
|
|
||||||
resp = &GetWorkOrderRecordListResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 工单详情
|
|
||||||
|
|
||||||
type OrderDetailParam struct {
|
|
||||||
OrderNum string `json:"order_num"`
|
|
||||||
}
|
|
||||||
type OrderLog struct {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
ApplyCount int64 `json:"apply_count"`
|
|
||||||
ActionType string `json:"action_type"`
|
|
||||||
PlayerLinkType string `json:"player_link_type"`
|
|
||||||
PlayerLinkTypeName string `json:"player_link_type_name"`
|
|
||||||
Content []*OrderSubmitPart `json:"content"`
|
|
||||||
PicContent []*OrderSubmitPart `json:"pic_content"`
|
|
||||||
CreatedAt string `json:"created_at"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type OrderDetail struct {
|
|
||||||
OrderRecord *OrderRecord `json:"order_record"`
|
|
||||||
OrderLogs []*OrderLog `json:"order_logs"`
|
|
||||||
}
|
|
||||||
type GetWorkOrderRecordDetailResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Data OrderDetail `json:"data"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
type GetWorkOrderRecordDetailReq struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
OrderNum string `position:"Json" field:"order_num"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetWorkOrderRecordDetailRequest(param OrderDetailParam) (req *GetWorkOrderRecordDetailReq) {
|
|
||||||
req = &GetWorkOrderRecordDetailReq{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
}
|
|
||||||
req.OrderNum = param.OrderNum
|
|
||||||
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/order_record_detail")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateGetWorkOrderRecordDetailResp() (resp *GetWorkOrderRecordDetailResp) {
|
|
||||||
resp = &GetWorkOrderRecordDetailResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package cs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
// OrderTemplate 工单模板
|
|
||||||
type OrderTemplate struct {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
UniqueCode string `json:"unique_code"`
|
|
||||||
CreatedAt string `json:"created_at"`
|
|
||||||
UpdatedAt string `json:"updated_at"`
|
|
||||||
TemplateParts []*OrderPart `json:"template_parts"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrderPart 工单字段
|
|
||||||
type OrderPart struct {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
PartName string `json:"part_name"`
|
|
||||||
PartKey string `json:"part_key"`
|
|
||||||
PartType int64 `json:"part_type"`
|
|
||||||
IsRequire int64 `json:"is_require"`
|
|
||||||
TipsContent string `json:"tips_content"`
|
|
||||||
MaxNum int64 `json:"max_num"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type OrderTemplateDetailReq struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
Id int64 `position:"Json" field:"id"`
|
|
||||||
}
|
|
||||||
type OrderTemplateDetailResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data OrderTemplate `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateOrderTemplateDetailReq(templateId int64) (req *OrderTemplateDetailReq) {
|
|
||||||
req = &OrderTemplateDetailReq{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
Id: templateId,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order_template/detail")
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateOrderTemplateDetailResp() (response *OrderTemplateDetailResp) {
|
|
||||||
response = &OrderTemplateDetailResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 25 KiB |
@ -1,157 +0,0 @@
|
|||||||
package cs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取玩家(用户)相关信息
|
|
||||||
*/
|
|
||||||
|
|
||||||
// UserInfo 用户信息
|
|
||||||
type UserInfo struct {
|
|
||||||
UserName string `json:"user_name"`
|
|
||||||
Uid int64 `json:"uid"`
|
|
||||||
Telephone string `json:"telephone"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserInfoRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserInfoResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data UserInfo `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetUserInfoRequest(userName string) (req *GetUserInfoRequest) {
|
|
||||||
req = &GetUserInfoRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/user/info")
|
|
||||||
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"user_name": userName,
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetUserInfoResponse() (response *GetUserInfoResponse) {
|
|
||||||
response = &GetUserInfoResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// UserRoleInfo 玩家角色信息
|
|
||||||
type UserRoleInfo struct {
|
|
||||||
Uid int64 `json:"uid"`
|
|
||||||
RoleName string `json:"role_name"`
|
|
||||||
RoleId string `json:"role_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserRoleListRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserRoleListResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []UserRoleInfo `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetUserRoleListRequest(uId int64, gameId int64) (req *GetUserRoleListRequest) {
|
|
||||||
req = &GetUserRoleListRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/user/role_list")
|
|
||||||
|
|
||||||
req.JsonParams["uid"] = uId
|
|
||||||
req.JsonParams["game_id"] = gameId
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateGetUserRoleListResponse() (response *GetUserRoleListResponse) {
|
|
||||||
response = &GetUserRoleListResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// UserServerInfo 玩家区服信息
|
|
||||||
type UserServerInfo struct {
|
|
||||||
ServerName string `json:"server_name"`
|
|
||||||
}
|
|
||||||
type GetUserServerListRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
}
|
|
||||||
type GetUserServerListResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []UserServerInfo `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetUserServerListRequest(uId int64, gameId int64) (req *GetUserServerListRequest) {
|
|
||||||
req = &GetUserServerListRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/user/server_list")
|
|
||||||
|
|
||||||
req.JsonParams["uid"] = uId
|
|
||||||
req.JsonParams["game_id"] = gameId
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateGetUserServerListResponse() (response *GetUserServerListResponse) {
|
|
||||||
response = &GetUserServerListResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
type SendSmsReq struct {
|
|
||||||
Phone string `json:"phone"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SendSmsResp 发送短信返回
|
|
||||||
type SendSmsResp struct {
|
|
||||||
// 短信发送时间戳,工单模块 有效期5分钟
|
|
||||||
SendCodeTime int64 `json:"send_code_time"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SendSmsRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
Phone string `position:"Json" field:"phone"`
|
|
||||||
}
|
|
||||||
type SendSmsResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data SendSmsResp `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateSendSmsRequest(param SendSmsReq) (req *SendSmsRequest) {
|
|
||||||
req = &SendSmsRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
Phone: param.Phone,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/user/send_sms")
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateSendSmsResponse() (response *SendSmsResponse) {
|
|
||||||
response = &SendSmsResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2025-05-28"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST = requests.Host{
|
|
||||||
Default: "game",
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.Init()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGameOsInfo 获取游戏系统信息
|
|
||||||
func (c *Client) GetGameOsInfo(req *GetGameOsInfoReq) (resp *GetGameOsInfoResp, err error) {
|
|
||||||
resp = CreateGetGameOsInfoResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGameSimpleList 获取子游戏简单列表
|
|
||||||
func (c *Client) GetGameSimpleList(req *GetGameSimpleListReq) (resp *GetGameSimpleListResp, err error) {
|
|
||||||
resp = CreateGetGameSimpleListResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGameServerV2 获取游戏服务器列表v2
|
|
||||||
func (c *Client) GetGameServerV2(req *GetServerV2Request) (resp *GetServerV2Response, err error) {
|
|
||||||
resp = CreateGetServerV2Response()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGameCompany 获取单个根游戏信息
|
|
||||||
func (c *Client) GetGameCompany(req *GetGameCompanyReq) (resp *GetGameCompanyResp, err error) {
|
|
||||||
resp = CreateGetGameCompanyResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetIsBlockOutIos 获取iOS切支付规则
|
|
||||||
func (c *Client) GetIsBlockOutIos(req *IsBlockOutIosReq) (resp *IsBlockOutIosResp, err error) {
|
|
||||||
resp = CreateIsBlockOutIosResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GetGameVersion(req *GetGameVersionReq) (resp *GetGameVersionResp, err error) {
|
|
||||||
resp = CreateGetGameVersionResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,136 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestGetGameOsInfo(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
req := CreateGetGameOsInfoReq()
|
|
||||||
|
|
||||||
resp, err := client.GetGameOsInfo(req)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetGameSimpleList(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
req := CreateGetGameSimpleListReq("8071,8062", "")
|
|
||||||
info, err := client.GetGameSimpleList(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println(info)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetGameServerV2(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateGetServerV2Request("n2", "", "")
|
|
||||||
info, err := client.GetGameServerV2(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println(info)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetGameCompany(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
req := CreateGetGameCompanyReq("ascq")
|
|
||||||
gameCompany, err := client.GetGameCompany(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println(gameCompany)
|
|
||||||
fmt.Println(gameCompany.Data.System)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestIsBlockOutIos(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
isBlockOutIosReq := CreateIsBlockOutIosReq("ec63860282", 4570, "116.26.129.38", "", 0, 0)
|
|
||||||
isBlockOutIos, err := client.GetIsBlockOutIos(isBlockOutIosReq)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(isBlockOutIos)
|
|
||||||
}
|
|
@ -1,317 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetGameOsInfoReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGameOsInfoResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data Data `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Data struct {
|
|
||||||
OsRelList2 []OsRelList2 `json:"os_rel_list2"`
|
|
||||||
OsList map[string]OsList `json:"os_list"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type OsRelList2 struct {
|
|
||||||
TwPlatID int `json:"tw_plat_id"`
|
|
||||||
TwOs int `json:"tw_os"`
|
|
||||||
Os int `json:"os"`
|
|
||||||
OsTwo int `json:"os_two"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type OsList struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
OsTwo map[string]interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetGameOsInfoReq() *GetGameOsInfoReq {
|
|
||||||
req := &GetGameOsInfoReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getGameOsInfo")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetGameOsInfoResp() *GetGameOsInfoResp {
|
|
||||||
return &GetGameOsInfoResp{
|
|
||||||
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 string `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"`
|
|
||||||
FlashPassId string `json:"flash_pass_id"`
|
|
||||||
FlashPassKey string `json:"flash_pass_key"`
|
|
||||||
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{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGameSimpleListReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGameSimpleListResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data map[string]GameSimple `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GameSimple struct {
|
|
||||||
ID int `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
GameSign string `json:"game_sign"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetGameSimpleListReq
|
|
||||||
// gids 子游戏字符串,多个子游戏id用英文逗号分割
|
|
||||||
// game_signs 根游戏标识字符串,多个标识用英文逗号分割
|
|
||||||
func CreateGetGameSimpleListReq(gameIds string, gameSigns string) *GetGameSimpleListReq {
|
|
||||||
req := &GetGameSimpleListReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getSimpleList")
|
|
||||||
tmpParams := make(map[string]string)
|
|
||||||
if gameIds != "" {
|
|
||||||
tmpParams["gids"] = gameIds
|
|
||||||
}
|
|
||||||
if gameSigns != "" {
|
|
||||||
tmpParams["game_signs"] = gameSigns
|
|
||||||
}
|
|
||||||
req.FormParams = tmpParams
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetGameSimpleListResp() *GetGameSimpleListResp {
|
|
||||||
return &GetGameSimpleListResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GameCompany
|
|
||||||
// ==== 获取根游戏信息
|
|
||||||
type GameCompany struct {
|
|
||||||
Id int `json:"id"`
|
|
||||||
GameSign string `json:"game_sign"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
GameName string `json:"game_name"`
|
|
||||||
ContractName string `json:"contract_name"`
|
|
||||||
PayKey string `json:"pay_key"`
|
|
||||||
LoginKey string `json:"login_key"`
|
|
||||||
LoginUrlH5 string `json:"login_url_h5"`
|
|
||||||
LoginUrlIos string `json:"login_url_ios"`
|
|
||||||
LoginUrlAndroid string `json:"login_url_android"`
|
|
||||||
PayUrl string `json:"pay_url"`
|
|
||||||
Ext string `json:"ext"`
|
|
||||||
Status int `json:"status"`
|
|
||||||
Company string `json:"company"`
|
|
||||||
System string `json:"system"`
|
|
||||||
Sync int `json:"sync"`
|
|
||||||
Type int `json:"type"`
|
|
||||||
GameProductId int `json:"game_product_id"`
|
|
||||||
}
|
|
||||||
type GetGameCompanyReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
type GetGameCompanyResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data GameCompany `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetGameCompanyReq(gameSign string) *GetGameCompanyReq {
|
|
||||||
req := &GetGameCompanyReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getGameCompanyBySign")
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"gameSign": gameSign,
|
|
||||||
}
|
|
||||||
req.Method = requests.POST
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
func CreateGetGameCompanyResp() *GetGameCompanyResp {
|
|
||||||
return &GetGameCompanyResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==== 获取游戏客户端版本配置
|
|
||||||
|
|
||||||
type GameVersion struct {
|
|
||||||
ID int `json:"id"`
|
|
||||||
GameID int `json:"game_id"`
|
|
||||||
GameVersion string `json:"version"`
|
|
||||||
GameURL string `json:"url"`
|
|
||||||
PayCallbackURL string `json:"pay_callback_url"`
|
|
||||||
DomainURL string `json:"domain_url"`
|
|
||||||
Status int `json:"status"`
|
|
||||||
H5Version int `json:"h5_version"`
|
|
||||||
H5Status int `json:"h5_status"`
|
|
||||||
IsH5Logout int `json:"is_h5_logout"`
|
|
||||||
HideWindow int `json:"hidewindow"`
|
|
||||||
PayInfo PayInfo `json:"pay_display_info"`
|
|
||||||
IsYsdk int `json:"is_ysdk"`
|
|
||||||
CheckVerified int `json:"check_verified"`
|
|
||||||
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"`
|
|
||||||
ExtData map[string]any `json:"ext_data"`
|
|
||||||
VersionStatus int `json:"version_status"`
|
|
||||||
VersionTime int `json:"version_time"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGameVersionReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
GameId int `position:"Body" field:"game_id"`
|
|
||||||
GameVersion string `position:"Body" field:"game_version"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGameVersionResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data GameVersion `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetGameVersionReq(gameId int, gameVersion string) *GetGameVersionReq {
|
|
||||||
req := &GetGameVersionReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.GameId = gameId
|
|
||||||
req.GameVersion = gameVersion
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getGameVersion")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetGameVersionResp() *GetGameVersionResp {
|
|
||||||
return &GetGameVersionResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,107 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
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"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
gameServerKey = "gaoreapi"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetGameServerSign 子游戏区服信息,特有验签
|
|
||||||
func GetGameServerSign(gameId int) (ts int64, sign string) {
|
|
||||||
ts = time.Now().Unix()
|
|
||||||
hash := md5.New()
|
|
||||||
hash.Write([]byte(fmt.Sprintf("%v%v%v", gameId, ts, gameServerKey)))
|
|
||||||
hashBytes := hash.Sum(nil)
|
|
||||||
sign = hex.EncodeToString(hashBytes)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetServerIdRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetServerIdResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data map[string]string `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetServerIdRequest
|
|
||||||
// Deprecated 方法已废弃,不要用
|
|
||||||
func CreateGetServerIdRequest(gameId int) (req *GetServerIdRequest) {
|
|
||||||
req = &GetServerIdRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getServerId")
|
|
||||||
// 获取时间戳、签名
|
|
||||||
ts, sign := GetGameServerSign(gameId)
|
|
||||||
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"appid": fmt.Sprintf("%v", gameId),
|
|
||||||
"time": fmt.Sprintf("%v", ts),
|
|
||||||
"sign": sign,
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetServerIdResponse
|
|
||||||
// Deprecated 方法已废弃,不要用
|
|
||||||
func CreateGetServerIdResponse() (response *GetServerIdResponse) {
|
|
||||||
response = &GetServerIdResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------游戏区服v2列表查询----------
|
|
||||||
|
|
||||||
// GetServerV2Request 请求结构体
|
|
||||||
type GetServerV2Request struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetServerV2Response struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []GameServerV2 `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GameServerV2 struct {
|
|
||||||
ServerId int `json:"server_id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
GameSign string `json:"game_sign"`
|
|
||||||
ServerSign int `json:"server_sign"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetServerV2Request(gameSign string, serverSigns string, types string) (req *GetServerV2Request) {
|
|
||||||
req = &GetServerV2Request{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getServerV2")
|
|
||||||
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"game_sign": gameSign,
|
|
||||||
"server_signs": serverSigns,
|
|
||||||
"types": types,
|
|
||||||
}
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetServerV2Response() (response *GetServerV2Response) {
|
|
||||||
response = &GetServerV2Response{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
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,60 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsBlockOutIosReq
|
|
||||||
// 获取切支付规则
|
|
||||||
type IsBlockOutIosReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
UserName string `position:"Body" field:"user_name"`
|
|
||||||
GameId int64 `position:"Body" field:"appid"`
|
|
||||||
Ip string `position:"Body" field:"ip"`
|
|
||||||
Imei string `position:"Body" field:"imei"`
|
|
||||||
LoginDays int64 `position:"Body" field:"login_days"`
|
|
||||||
PlayTime int64 `position:"Body" field:"play_time"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type IsBlockOutIosRespData struct {
|
|
||||||
PayInChannel bool `json:"pay_in_channel"`
|
|
||||||
PayInChannelMatchedRule []int64 `json:"pay_in_channel_matched_rule"`
|
|
||||||
DoDisplayIos bool `json:"do_display_ios"`
|
|
||||||
DoDisplayIosMatchedRule []int64 `json:"do_display_ios_matched_rule"`
|
|
||||||
DoDisplayWebsite bool `json:"do_display_website"`
|
|
||||||
DoDisplayWebsiteMatchedRule []int64 `json:"do_display_website_matched_rule"`
|
|
||||||
DoDisplayWebsiteWechatInfo string `json:"do_display_website_wechat_info"`
|
|
||||||
DoWebOrderPay bool `json:"do_web_order_pay"`
|
|
||||||
DoWebOrderPayMatchedRule []int64 `json:"do_web_order_pay_matched_rule"`
|
|
||||||
DoWebOrderPayWechatInfo string `json:"do_web_order_pay_wechat_info"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type IsBlockOutIosResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data IsBlockOutIosRespData `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateIsBlockOutIosReq(userName string, gameId int64, ip string, imei string, loginDays, playTime int64) *IsBlockOutIosReq {
|
|
||||||
req := &IsBlockOutIosReq{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.UserName = userName
|
|
||||||
req.GameId = gameId
|
|
||||||
req.Ip = ip
|
|
||||||
req.Imei = imei
|
|
||||||
req.LoginDays = loginDays
|
|
||||||
req.PlayTime = playTime
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/pay/isBlockOutIos")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateIsBlockOutIosResp() *IsBlockOutIosResp {
|
|
||||||
resp := &IsBlockOutIosResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return resp
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package ip
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2025-06-24"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST = requests.Host{
|
|
||||||
Default: "ip",
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.Init()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) CreateGetIpRequest(req *IpRequest) (resp *IpResponse, err error) {
|
|
||||||
resp = CreateIpResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) CreateGetIpsRequest(req *IpsRequest) (resp *IpsResponse, err error) {
|
|
||||||
resp = CreateIpsResponse()
|
|
||||||
err = client.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package ip
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 测试获取单个ip地区信息
|
|
||||||
func TestGetIp(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateIpRequest(IpParam{
|
|
||||||
Ip: "114.234.202.136",
|
|
||||||
})
|
|
||||||
res, doErr := client.CreateGetIpRequest(req)
|
|
||||||
if doErr != nil {
|
|
||||||
panic(doErr)
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("查询多个ip失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 测试获取多个ip地区信息
|
|
||||||
func TestGetIps(t *testing.T) {
|
|
||||||
client, newErr := NewClient()
|
|
||||||
if newErr != nil {
|
|
||||||
panic(newErr)
|
|
||||||
}
|
|
||||||
req := CreateIpsRequest(IpsParam{
|
|
||||||
Ips: []string{
|
|
||||||
"2001:ee0:5208:e600:4c51:3189:28a4:b668",
|
|
||||||
"114.234.202.136",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
res, err := client.CreateGetIpsRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.Code != 0 {
|
|
||||||
t.Error("查询多个ip失败")
|
|
||||||
}
|
|
||||||
fmt.Printf(fmt.Sprintf("%v", res))
|
|
||||||
}
|
|
@ -1,100 +0,0 @@
|
|||||||
package ip
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type IpInfo struct {
|
|
||||||
Ip string `json:"ip"`
|
|
||||||
City string `json:"city"`
|
|
||||||
Province string `json:"province"`
|
|
||||||
Country string `json:"country"`
|
|
||||||
Isp string `json:"isp"`
|
|
||||||
Owner string `json:"owner"`
|
|
||||||
Continent string `json:"continent"`
|
|
||||||
Accuracy string `json:"accuracy"`
|
|
||||||
Adcode string `json:"adcode"`
|
|
||||||
Areacode string `json:"areacode"`
|
|
||||||
Asnumber string `json:"asnumber"`
|
|
||||||
Radius string `json:"radius"`
|
|
||||||
Latwgs string `json:"latwgs"`
|
|
||||||
Lngwgs string `json:"lngwgs"`
|
|
||||||
Source string `json:"source"`
|
|
||||||
Timezone string `json:"timezone"`
|
|
||||||
Zipcode string `json:"zipcode"`
|
|
||||||
District string `json:"district"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// IpsParam
|
|
||||||
// 单个ip请求参数
|
|
||||||
type IpParam struct {
|
|
||||||
Ip string `json:"ip"`
|
|
||||||
}
|
|
||||||
type IpRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
Ip string `position:"Json" field:"ip"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// IpResponse
|
|
||||||
// 单个ip返回参数
|
|
||||||
type IpResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data IpInfo `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateIpRequest
|
|
||||||
// 同时支持ipv4、ipv6格式查询
|
|
||||||
func CreateIpRequest(param IpParam) (req *IpRequest) {
|
|
||||||
req = &IpRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
Ip: param.Ip,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/getIp")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateIpResponse() (resp *IpResponse) {
|
|
||||||
resp = &IpResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 多个ip请求参数
|
|
||||||
type IpsParam struct {
|
|
||||||
Ips []string `json:"ips"`
|
|
||||||
}
|
|
||||||
type IpsRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
Ips []string `position:"Json" field:"ips"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// IpsResponse
|
|
||||||
// 多个ip返回参数
|
|
||||||
type IpsResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data map[string]IpInfo `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateIpsRequest
|
|
||||||
// 同时支持ipv4、ipv6格式查询
|
|
||||||
func CreateIpsRequest(param IpsParam) (req *IpsRequest) {
|
|
||||||
req = &IpsRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
Ips: param.Ips,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/getIps")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func CreateIpsResponse() (resp *IpsResponse) {
|
|
||||||
resp = &IpsResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -2,26 +2,14 @@ package jedi
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "2020-09-24"
|
HOST = "jedi"
|
||||||
|
VERSION = "2020-08-04"
|
||||||
)
|
)
|
||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
|
||||||
Default: "jedi.api.gaore.com",
|
|
||||||
Func: func(s string) string {
|
|
||||||
var a = map[string]string{
|
|
||||||
requests.RELEASE: "jedi.api.gaore.com",
|
|
||||||
requests.PRE: "jedi.api.gaore.com",
|
|
||||||
requests.TEST: "jedi.oapi.gaore.com",
|
|
||||||
}
|
|
||||||
return a[s]
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
sdk.Client
|
sdk.Client
|
||||||
}
|
}
|
||||||
@ -35,14 +23,14 @@ func (c *Client) SendSms(req *SendSmsRequest) (response *SendSmsResponse, err er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) Test(req *DemoTestRequest) (response *DemoTestResponse, err error) {
|
||||||
|
response = CreateDemoTestResponse()
|
||||||
|
err = c.DoAction(req, response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) {
|
func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) {
|
||||||
client = &Client{}
|
client = &Client{}
|
||||||
err = client.InitWithAccessKey(accesskey, secrect, source)
|
err = client.InitWithAccessKey(accesskey, secrect, source)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClientWithAliAppcode(accesskey, secrect string, env ...string) (client *Client, err error) {
|
|
||||||
client = &Client{}
|
|
||||||
err = client.InitWithAliAppcode(accesskey, secrect, env...)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
|
|
||||||
type SendSmsRequest struct {
|
type SendSmsRequest struct {
|
||||||
*requests.RpcRequest
|
*requests.RpcRequest
|
||||||
User string `position:"Body" field:"user" default:"" `
|
User string `position:"Query" field:"user" default:"" `
|
||||||
Code string `position:"Body" field:"code" default:"" `
|
Code string `position:"Query" field:"code" default:"" `
|
||||||
Params string `position:"Body" field:"params" default:"" `
|
Params string `position:"Query" field:"params" default:"" `
|
||||||
ParamsArray []string
|
ParamsArray []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ func CreateSendSmsRequest() (req *SendSmsRequest) {
|
|||||||
RpcRequest: &requests.RpcRequest{},
|
RpcRequest: &requests.RpcRequest{},
|
||||||
}
|
}
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/sms/send")
|
req.InitWithApiInfo(HOST, VERSION, "/api/sms/send")
|
||||||
req.Method = requests.POST
|
req.Method = requests.GET
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
services/jedi/test_demo.go
Normal file
37
services/jedi/test_demo.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package jedi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DemoTestRequest struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
Param1 string `position:"Query" field:"param_1" default:"" `
|
||||||
|
Param2 int `position:"Query" field:"param_2" default:"10086" `
|
||||||
|
Param3 bool `position:"Query" field:"param_3" default:"false" `
|
||||||
|
ParamBody string `position:"Body" field:"param_body" default:"foobar" `
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateDemoTestRequest() (req *DemoTestRequest) {
|
||||||
|
req = &DemoTestRequest{RpcRequest: &requests.RpcRequest{}}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/api/sms/Index")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
type DemoTestResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Data DemoTestResponseData `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DemoTestResponseData struct {
|
||||||
|
Account string `json:"account"`
|
||||||
|
Total int `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateDemoTestResponse() *DemoTestResponse {
|
||||||
|
return &DemoTestResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
@ -1,50 +0,0 @@
|
|||||||
package mail
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/md5"
|
|
||||||
"fmt"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2021-09-27"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
|
||||||
Default: "mail.gaore.com",
|
|
||||||
Func: func(s string) string {
|
|
||||||
var a = map[string]string{
|
|
||||||
requests.RELEASE: "mail.gaore.com",
|
|
||||||
requests.PRE: "mail.gaore.com",
|
|
||||||
requests.TEST: "mail.gaore.com",
|
|
||||||
}
|
|
||||||
return a[s]
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client) {
|
|
||||||
client = &Client{}
|
|
||||||
client.InitWithAccessKey("", "", "")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) SendEmail(req *PostEmailRequest) (response *PostEmailResponse, err error) {
|
|
||||||
|
|
||||||
now := time.Now().Second()
|
|
||||||
key := "04573fc4c8e01999a0909ab9c00bca5a"
|
|
||||||
signstr := fmt.Sprintf("%d%s", now, key)
|
|
||||||
data := []byte(signstr)
|
|
||||||
has := md5.Sum(data)
|
|
||||||
sign := fmt.Sprintf("%x", has)
|
|
||||||
req.Time = now
|
|
||||||
req.Sign = sign
|
|
||||||
response = CreatePostEmailResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package mail
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestClient_GetUserInfo(t *testing.T) {
|
|
||||||
c := NewClient()
|
|
||||||
req := CreatePostEmailRequest()
|
|
||||||
req.Addresses = "3002467428@qq.com"
|
|
||||||
req.Body = "1111"
|
|
||||||
req.FromName = "213123121"
|
|
||||||
req.SetReadTimeout(60 * time.Second)
|
|
||||||
resp, err := c.SendEmail(req)
|
|
||||||
|
|
||||||
fmt.Println(req)
|
|
||||||
fmt.Println(resp.GetHttpContentString())
|
|
||||||
fmt.Println(err)
|
|
||||||
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package mail
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PostEmailRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
Addresses string `position:"Body" field:"addresses" default:"" `
|
|
||||||
Subject string `position:"Body" field:"subject" default:"" `
|
|
||||||
Body string `position:"Body" field:"body" default:""`
|
|
||||||
FromName string `position:"Body" field:"fromName" default:""`
|
|
||||||
Time int `position:"Body" field:"time" default:""`
|
|
||||||
Sign string `position:"Body" field:"sign" default:""`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PostEmailResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreatePostEmailRequest() (req *PostEmailRequest) {
|
|
||||||
req = &PostEmailRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/email/post_email.php")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreatePostEmailResponse() (response *PostEmailResponse) {
|
|
||||||
response = &PostEmailResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package mkt
|
|
||||||
|
|
||||||
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: "mkt",
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// PkgNotice 打包通知
|
|
||||||
func (c *Client) PkgNotice(req *PkgNoticeRequest) (response *PkgNoticeResponse, err error) {
|
|
||||||
response = CreatePkgNoticeResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) {
|
|
||||||
client = &Client{}
|
|
||||||
err = client.InitWithAccessKey(accesskey, secrect, source)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.Init()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) SubjectList(req *SubjectListRequest) (response *SubjectListResponse, err error) {
|
|
||||||
response = CreateSubjectListResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package mkt
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSubjectList(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
req := CreateSubjectListRequest(0)
|
|
||||||
req.Port = "9090"
|
|
||||||
list, err := client.SubjectList(req)
|
|
||||||
if err != nil {
|
|
||||||
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)
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package mkt
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
//PkgNoticeRequest 打包通知请求信息
|
|
||||||
type PkgNoticeRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
SiteID int64 `position:"Body" field:"site_id"` // 广告位ID
|
|
||||||
Status int `position:"Body" field:"status"` // 打包状态(0:失败 1:成功)
|
|
||||||
}
|
|
||||||
|
|
||||||
//PkgNoticeResponse 打包通知响应信息
|
|
||||||
type PkgNoticeResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
//CreatePkgNoticeRequest 创建通知接口
|
|
||||||
func CreatePkgNoticeRequest() (req *PkgNoticeRequest) {
|
|
||||||
req = &PkgNoticeRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/pkgnotice")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//CreatePkgNoticeResponse 创建通知响应
|
|
||||||
func CreatePkgNoticeResponse() (response *PkgNoticeResponse) {
|
|
||||||
response = &PkgNoticeResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
package mkt
|
|
||||||
|
|
||||||
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"
|
|
||||||
)
|
|
||||||
|
|
||||||
const appKey = "fc1f841#@de!!08"
|
|
||||||
|
|
||||||
type SubjectListRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type SubjectListResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Status bool `json:"status"`
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
List map[int]Data `json:"list"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Data struct {
|
|
||||||
Abbr string `json:"abbr"`
|
|
||||||
AbbrSign string `json:"abbr_sign"`
|
|
||||||
Id int `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
State int `json:"state"`
|
|
||||||
System string `json:"system"`
|
|
||||||
Type int `json:"type"`
|
|
||||||
Uscc string `json:"uscc"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSubjectListRequest 公司列表请求
|
|
||||||
func CreateSubjectListRequest(state int) (req *SubjectListRequest) {
|
|
||||||
ts := time.Now().Unix()
|
|
||||||
hash := md5.New()
|
|
||||||
hash.Write([]byte(fmt.Sprintf("%v%v", ts, appKey)))
|
|
||||||
hashBytes := hash.Sum(nil)
|
|
||||||
|
|
||||||
token := hex.EncodeToString(hashBytes)
|
|
||||||
|
|
||||||
req = &SubjectListRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, fmt.Sprintf("/api/subject/list"))
|
|
||||||
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"token": token,
|
|
||||||
"ts": fmt.Sprintf("%v", ts),
|
|
||||||
"state": fmt.Sprintf("%v", state),
|
|
||||||
}
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSubjectListResponse 公司列表请求响应
|
|
||||||
func CreateSubjectListResponse() (response *SubjectListResponse) {
|
|
||||||
response = &SubjectListResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package oss
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetApkVersionRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
Filepath string `position:"Json" field:"filepath"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetApkVersionResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
VersionCode string `json:"versionCode"`
|
|
||||||
VersionName string `json:"versionName"`
|
|
||||||
MinSdkVersion string `json:"minSdkVersion"`
|
|
||||||
TargetSdkVersion string `json:"targetSdkVersion"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetApkVersionRequest() (req *GetApkVersionRequest) {
|
|
||||||
req = &GetApkVersionRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/apk/version")
|
|
||||||
req.Method = requests.POST
|
|
||||||
req.SetReadTimeout(30 * time.Second)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetApkVersionResponse() *GetApkVersionResponse {
|
|
||||||
return &GetApkVersionResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
package oss
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"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/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2024-05-30"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST = requests.Host{
|
|
||||||
Default: "oss.gaore.com",
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.Init()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClientWithSts() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) PutOss(req *PutOssRequest) (resp *PutOssResponse, err error) {
|
|
||||||
if req.Bucket == "" {
|
|
||||||
err = errors.New("bucket name is empty")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if req.FileStream == nil {
|
|
||||||
err = errors.New("stream is empty")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.SetContent(req.FileStream)
|
|
||||||
resp = CreatePutOssResponse()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) DelOss(req *DelOssRequest) (resp *DelOssResponse, err error) {
|
|
||||||
resp = CreateDelOssResponse()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) InitMultipartUpload(req *InitMultipartUploadRequest) (resp *InitMultipartUploadResponse, err error) {
|
|
||||||
resp = CreateInitMultipartUploadResponse()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GetApkVersion(req *GetApkVersionRequest) (resp *GetApkVersionResponse, err error) {
|
|
||||||
resp = CreateGetApkVersionResponse()
|
|
||||||
sign, err := auth.NewSignerWithCredential(credentials.NewStsTokenCredential("", "ccc", ""), nil)
|
|
||||||
err = c.DoActionWithSigner(req, resp, sign)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
package oss
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestUpload_Put(t *testing.T) {
|
|
||||||
req := CreatePutOssRequest()
|
|
||||||
req.Bucket = "image"
|
|
||||||
//req.Bucket = "web"
|
|
||||||
file, err := os.ReadFile("test.jpg")
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.FileStream = file
|
|
||||||
client, err := NewClient()
|
|
||||||
resp, err := client.PutOss(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(resp.Data.Url)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpload_Del(t *testing.T) {
|
|
||||||
req := CreateDelOssRequest()
|
|
||||||
req.Bucket = "image"
|
|
||||||
req.MediaUrl = "https://image.89yoo.com/uploads/549/549e887460a72333c361661683023018.jpeg"
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, err := client.DelOss(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(resp.Code)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCreateInitMultipartUpload(t *testing.T) {
|
|
||||||
req := CreateInitMultipartUploadRequest()
|
|
||||||
|
|
||||||
extInfo := map[string]any{"game_byname": "tech_test_tencent"}
|
|
||||||
bExtInfo, _ := json.Marshal(extInfo)
|
|
||||||
|
|
||||||
req.UploadType = "package"
|
|
||||||
req.TargetType = "oss"
|
|
||||||
req.TargetName = "image"
|
|
||||||
req.FileHash = "51c68615b8d21f9b72b02f48c400cb87"
|
|
||||||
req.Filepath = "q5-01.zip"
|
|
||||||
req.ExtInfo = string(bExtInfo)
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, err := client.InitMultipartUpload(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
r, err := json.Marshal(resp)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(string(r))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestClient_GetApkVersion(t *testing.T) {
|
|
||||||
req := CreateGetApkVersionRequest()
|
|
||||||
req.Filepath = "uploads/files/package/1f57ac9693f0593fc9073f366b1c1936.zip"
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, err := client.GetApkVersion(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(resp.Data.VersionCode, resp.Data.VersionName)
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
package oss
|
|
||||||
|
|
||||||
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"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
multipartUploadKeys = "b4471b940d98"
|
|
||||||
)
|
|
||||||
|
|
||||||
type InitMultipartUploadRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
UploadType string `position:"Json" field:"upload_type"`
|
|
||||||
TargetType string `position:"Json" field:"target_type"`
|
|
||||||
TargetName string `position:"Json" field:"target_name"`
|
|
||||||
FileHash string `position:"Json" field:"file_hash"`
|
|
||||||
Filepath string `position:"Json" field:"filepath"`
|
|
||||||
ExtInfo string `position:"Json" field:"ext_info"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type InitMultipartUploadResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
FileUploaded bool `json:"file_uploaded"`
|
|
||||||
UploadId string `json:"upload_id,omitempty"`
|
|
||||||
Links []Link `json:"links,omitempty"`
|
|
||||||
Hash string `json:"hash,omitempty"`
|
|
||||||
Url string `json:"url,omitempty"`
|
|
||||||
Filepath string `json:"filepath,omitempty"`
|
|
||||||
FileName string `json:"filename,omitempty"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Link struct {
|
|
||||||
Href string `json:"href"`
|
|
||||||
Rel string `json:"rel"`
|
|
||||||
Method string `json:"method"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateInitMultipartUploadRequest() (req *InitMultipartUploadRequest) {
|
|
||||||
ts := fmt.Sprintf("%d", time.Now().Unix())
|
|
||||||
m := md5.Sum([]byte(ts + multipartUploadKeys))
|
|
||||||
sign := hex.EncodeToString(m[:])
|
|
||||||
req = &InitMultipartUploadRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
}
|
|
||||||
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/upload/multipart/init?_ts="+ts+"&_sign="+sign)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateInitMultipartUploadResponse() (resp *InitMultipartUploadResponse) {
|
|
||||||
resp = &InitMultipartUploadResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return resp
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 630 KiB |
@ -1,31 +0,0 @@
|
|||||||
package oss
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DelOssRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
Bucket string `position:"Json" field:"bucket" default:"image"`
|
|
||||||
MediaUrl string `position:"Json" field:"url" default:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DelOssResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateDelOssRequest() (req *DelOssRequest) {
|
|
||||||
req = &DelOssRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/upload/del")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateDelOssResponse() (resp *DelOssResponse) {
|
|
||||||
return &DelOssResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
package oss
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PutOssRequest struct {
|
|
||||||
*requests.StreamRequest
|
|
||||||
Bucket string `position:"Query" field:"bucket" default:"image"`
|
|
||||||
FileStream []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type PutOssResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
Url string `json:"url"`
|
|
||||||
SavePath string `json:"save_path"`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreatePutOssRequest() (req *PutOssRequest) {
|
|
||||||
req = &PutOssRequest{
|
|
||||||
StreamRequest: &requests.StreamRequest{},
|
|
||||||
}
|
|
||||||
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "api/upload/put")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreatePutOssResponse() (resp *PutOssResponse) {
|
|
||||||
return &PutOssResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package passport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2025-05-28"
|
|
||||||
// 对称加密密钥
|
|
||||||
appKey = "#gr*%com#"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
|
||||||
Default: "passport.gaore.com",
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.Init()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUserList
|
|
||||||
// 获取用户列表
|
|
||||||
func (c *Client) GetUserList(req *GetUserListRequest) (response *GetUserListResponse, err error) {
|
|
||||||
response = CreateGetUserListResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUserRoleList
|
|
||||||
// 获取用户角色列表
|
|
||||||
func (c *Client) GetUserRoleList(req *GetUserRoleListRequest) (response *GetUserRoleListResponse, err error) {
|
|
||||||
response = CreateGetUserRoleListResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package passport
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
// 单元测试
|
|
||||||
|
|
||||||
func TestGetUserList(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
req := CreateGetUserListRequest("ws45265737")
|
|
||||||
resp, err := client.GetUserList(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
t.Logf("resp code:%+v", resp.Code)
|
|
||||||
t.Logf("resp data:%+v", resp.Data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetUserRoleList(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
req := CreateGetUserRoleListRequest(63610626, 2850)
|
|
||||||
resp, err := client.GetUserRoleList(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
t.Logf("resp code:%+v", resp.Code)
|
|
||||||
t.Logf("resp data:%+v", resp.Data)
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
package passport
|
|
||||||
|
|
||||||
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 GetUserListRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserListResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []UserInfo `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserInfo struct {
|
|
||||||
UserName string `json:"user_name"` // 用户名
|
|
||||||
Uid string `json:"uid"` // uid
|
|
||||||
Telephone string `json:"telephone"` // 手机号
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetUserListRequest 获取玩家用户列表
|
|
||||||
func CreateGetUserListRequest(userName string) (req *GetUserListRequest) {
|
|
||||||
ts, sign := GetSign()
|
|
||||||
|
|
||||||
req = &GetUserListRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/remote_login.php")
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"act": "info",
|
|
||||||
"do": "get_user_list",
|
|
||||||
"user_names": userName,
|
|
||||||
"time": fmt.Sprintf("%v", ts),
|
|
||||||
"sign": sign,
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetUserListResponse() (response *GetUserListResponse) {
|
|
||||||
response = &GetUserListResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserRoleListRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserRoleListResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []UserRoleInfo `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserRoleInfo struct {
|
|
||||||
Uid string `json:"uid"` // uid
|
|
||||||
GameId string `json:"game_id"` // 子游戏id
|
|
||||||
RoleId string `json:"role_id"` // 角色id
|
|
||||||
RoleName string `json:"role_name"` // 角色名
|
|
||||||
RoleServer string `json:"role_server"` // 角色服务器名
|
|
||||||
AddTime string `json:"add_time"` // 创建时间戳
|
|
||||||
UpdateTime string `json:"update_time"` // 更新时间戳
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetSign 封装一个方法,获取当天时间戳和api签名
|
|
||||||
func GetSign() (ts int64, sign string) {
|
|
||||||
ts = time.Now().Unix()
|
|
||||||
hash := md5.New()
|
|
||||||
hash.Write([]byte(fmt.Sprintf("%v%v", ts, appKey)))
|
|
||||||
hashBytes := hash.Sum(nil)
|
|
||||||
sign = hex.EncodeToString(hashBytes)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGetUserRoleListRequest 获取玩家角色列表
|
|
||||||
func CreateGetUserRoleListRequest(uid int, gameId int) (req *GetUserRoleListRequest) {
|
|
||||||
ts, sign := GetSign()
|
|
||||||
|
|
||||||
req = &GetUserRoleListRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/remote_login.php")
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"act": "info",
|
|
||||||
"do": "user_role",
|
|
||||||
"method": "get",
|
|
||||||
"uid": fmt.Sprintf("%d", uid),
|
|
||||||
"game_id": fmt.Sprintf("%d", gameId),
|
|
||||||
"time": fmt.Sprintf("%v", ts),
|
|
||||||
"sign": sign,
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetUserRoleListResponse() (response *GetUserRoleListResponse) {
|
|
||||||
response = &GetUserRoleListResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
package pay
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2024-06-03"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
|
||||||
Default: "pay.api.gaore.com",
|
|
||||||
Func: func(s string) string {
|
|
||||||
var a = map[string]string{
|
|
||||||
requests.RELEASE: "pay.api.gaore.com",
|
|
||||||
requests.PRE: "pay.api.gaore.com",
|
|
||||||
requests.TEST: "pay.gaore.com",
|
|
||||||
}
|
|
||||||
return a[s]
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.Init()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) ComplaintReply(req *ComplaintReplyRequest) (response *ComplaintReplyResponse, err error) {
|
|
||||||
response = CreateComplaintReplyResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) ComplaintComplete(req *ComplaintCompleteRequest) (response *ComplaintCompleteResponse, err error) {
|
|
||||||
response = CreateComplaintCompleteResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) ComplaintUpload(req *ComplaintUploadRequest) (response *ComplaintUploadResponse, err error) {
|
|
||||||
response = CreateComplaintUploadResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) MerchantConfigDebug(req *merchantConfigDebugRequest) (response *merchantConfigDebugResponse, err error) {
|
|
||||||
response = CreateMerchantConfigDebugResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetOrderState
|
|
||||||
// 获取订单状态
|
|
||||||
func (c *Client) GetOrderState(req *GetOrderStateRequest) (response *GetOrderStateResponse, err error) {
|
|
||||||
response = CreateGetOrderStateResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package pay
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestClient_GetUserInfo(t *testing.T) {
|
|
||||||
|
|
||||||
//c, err := NewClient()
|
|
||||||
//if err != nil {
|
|
||||||
// t.Error(err)
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//req := CreateComplaintNotifyUrlRequest()
|
|
||||||
//
|
|
||||||
//req.MchId = "3503"
|
|
||||||
//req.NotifyUrl = "https://pay.uu89.com/api/complaint/wxNotify/3503"
|
|
||||||
//req.Type = 1
|
|
||||||
//
|
|
||||||
//resp, err := c.ComplaintNotifyUrl(req)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatalln(err)
|
|
||||||
//}
|
|
||||||
//fmt.Println(resp.GetHttpContentString())
|
|
||||||
//fmt.Println(resp.GetHttpHeaders())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetOrderState(t *testing.T) {
|
|
||||||
getOrderStateRequest := CreateGetOrderStateRequest("202112060000193551730")
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
getOrderStateResponse, err := client.GetOrderState(getOrderStateRequest)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(getOrderStateResponse.GetHttpContentString())
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package pay
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ComplaintCompleteRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
MchId string `position:"Body" field:"mch_id" default:"" `
|
|
||||||
ComplaintId string `position:"Body" field:"complaint_id" default:"" `
|
|
||||||
ExtData string `position:"Body" field:"ext_data" default:"" `
|
|
||||||
}
|
|
||||||
|
|
||||||
type ComplaintCompleteResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateComplaintCompleteRequest() (req *ComplaintCompleteRequest) {
|
|
||||||
req = &ComplaintCompleteRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/complaint/complete")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateComplaintCompleteResponse() (response *ComplaintCompleteResponse) {
|
|
||||||
response = &ComplaintCompleteResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package pay
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ComplaintReplyRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
MchId string `position:"Body" field:"mch_id" default:"" `
|
|
||||||
ComplaintId string `position:"Body" field:"complaint_id" default:"" `
|
|
||||||
Content string `position:"Body" field:"content" default:"" `
|
|
||||||
Images string `position:"Body" field:"images" default:"" `
|
|
||||||
}
|
|
||||||
|
|
||||||
type ComplaintReplyResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateComplaintReplyRequest() (req *ComplaintReplyRequest) {
|
|
||||||
req = &ComplaintReplyRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/complaint/reply")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateComplaintReplyResponse() (response *ComplaintReplyResponse) {
|
|
||||||
response = &ComplaintReplyResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package pay
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ComplaintUploadRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
MchId string `position:"Body" field:"mch_id" default:"" `
|
|
||||||
ImageUrl string `position:"Body" field:"image_url" default:"" `
|
|
||||||
ComplaintId string `position:"Body" field:"complaint_id" default:" " `
|
|
||||||
}
|
|
||||||
|
|
||||||
type ComplaintUploadResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data map[string]string `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateComplaintUploadRequest() (req *ComplaintUploadRequest) {
|
|
||||||
req = &ComplaintUploadRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/complaint/imageUpload")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateComplaintUploadResponse() (response *ComplaintUploadResponse) {
|
|
||||||
response = &ComplaintUploadResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package pay
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetOrderStateRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
OrderId string `position:"Body" field:"orderid" default:"" `
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetOrderStateResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
Orderid string `json:"orderid"` // 订单号
|
|
||||||
Succ string `json:"succ"` // 是否成功
|
|
||||||
Money string `json:"money"` // 支付金额
|
|
||||||
UserName string `json:"user_name"` // 用户名
|
|
||||||
BNum string `json:"b_num"`
|
|
||||||
GameId string `json:"game_id"` // 游戏id
|
|
||||||
PayDate string `json:"pay_date"` // 付费日期
|
|
||||||
SyncDate string `json:"sync_date"` // 回调时间
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetOrderStateRequest(orderId string) (req *GetOrderStateRequest) {
|
|
||||||
req = &GetOrderStateRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
OrderId: orderId,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/user/getOrderState")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetOrderStateResponse() (response *GetOrderStateResponse) {
|
|
||||||
response = &GetOrderStateResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package pay
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type merchantConfigDebugRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
MchId string `position:"Body" field:"mch_id" default:"" `
|
|
||||||
}
|
|
||||||
|
|
||||||
type merchantConfigDebugResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateMerchantConfigDebugRequest() (req *merchantConfigDebugRequest) {
|
|
||||||
req = &merchantConfigDebugRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/complaint/configDebug")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateMerchantConfigDebugResponse() (response *merchantConfigDebugResponse) {
|
|
||||||
response = &merchantConfigDebugResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package script
|
|
||||||
|
|
||||||
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: "script",
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.Init()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenGame 同步到游戏中心
|
|
||||||
func (c *Client) OpenGame(req *OpenGameReq) (resp *OpenGameResp, err error) {
|
|
||||||
resp = CreateOpenGameResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewPayRedisData 设置支付redis相关数据
|
|
||||||
func (c *Client) NewPayRedisData(req *NewPayRedisDataReq) (resp *NewPayRedisDataResp, err error) {
|
|
||||||
resp = CreateNewPayRedisDataResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package script
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestOpenGame(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
req := CreateOpenGameReq(7275)
|
|
||||||
|
|
||||||
resp, err := client.OpenGame(req)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(resp.Code, resp.Msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewPayRedisData(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
req := CreateNewPayRedisDataReq()
|
|
||||||
|
|
||||||
resp, err := client.NewPayRedisData(req)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(resp.Code, resp.Msg)
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
package script
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type OpenGameReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
GameID int `position:"Query" field:"game_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type OpenGameResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
type NewPayRedisDataReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type NewPayRedisDataResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetHttpContentBytes 因为http://script.gaore.com/open_game.php?game_id=这个接口返回的不是json,反序列化会报错,所以返回一个固定的json
|
|
||||||
func (baseResponse *OpenGameResp) GetHttpContentBytes() []byte {
|
|
||||||
b, _ := json.Marshal(map[string]interface{}{"code": 200, "msg": "success"})
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateOpenGameReq 创建同步到游戏中心请求
|
|
||||||
func CreateOpenGameReq(gameId int) *OpenGameReq {
|
|
||||||
req := &OpenGameReq{
|
|
||||||
&requests.RpcRequest{},
|
|
||||||
gameId,
|
|
||||||
}
|
|
||||||
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "open_game.php")
|
|
||||||
req.Method = requests.GET
|
|
||||||
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateOpenGameResp 创建同步到游戏中心响应
|
|
||||||
func CreateOpenGameResp() *OpenGameResp {
|
|
||||||
return &OpenGameResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateNewPayRedisDataReq 设置支付redis相关数据
|
|
||||||
func CreateNewPayRedisDataReq() *NewPayRedisDataReq {
|
|
||||||
req := &NewPayRedisDataReq{
|
|
||||||
&requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "pay/new_pay_redis_data.php")
|
|
||||||
req.Method = requests.GET
|
|
||||||
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateNewPayRedisDataResp() *NewPayRedisDataResp {
|
|
||||||
return &NewPayRedisDataResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,99 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
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_SendSmsCode(t *testing.T) {
|
|
||||||
req := CreateSendSmsRequest(SendSmsParam{
|
|
||||||
Mobile: "18320021439",
|
|
||||||
Type: SmsTypeBindPhone,
|
|
||||||
Replaces: []Item{{
|
|
||||||
Key: ReplaceKeyCode,
|
|
||||||
Value: "6379",
|
|
||||||
}, {
|
|
||||||
Key: ReplaceKeySecond,
|
|
||||||
Value: "120",
|
|
||||||
}},
|
|
||||||
})
|
|
||||||
|
|
||||||
req.Domain = requests.Host{
|
|
||||||
Default: "127.0.0.1:8804",
|
|
||||||
}
|
|
||||||
|
|
||||||
sms, err := client.SendSms(req)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(sms)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestClient_SendSmsUrl(t *testing.T) {
|
|
||||||
req := CreateSendSmsRequest(SendSmsParam{
|
|
||||||
Mobile: "18320021439",
|
|
||||||
Type: TemplateTypeOrderComplete,
|
|
||||||
Replaces: []Item{{
|
|
||||||
Key: ReplaceKeyUrl,
|
|
||||||
Value: "http://www.baidu.com",
|
|
||||||
}},
|
|
||||||
})
|
|
||||||
|
|
||||||
req.Domain = requests.Host{
|
|
||||||
Default: "127.0.0.1:8804",
|
|
||||||
}
|
|
||||||
|
|
||||||
sms, err := client.SendSms(req)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(sms)
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
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, "/v1/email/send")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateSendEmailResponse() (resp *SendEmailResponse) {
|
|
||||||
resp = &SendEmailResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
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, "/v1/feishu/webhook_send")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateSendFeiShuWebHookResponse() (resp *SendFeiShuWebHookResponse) {
|
|
||||||
resp = &SendFeiShuWebHookResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
package sms
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ReplaceKey = string
|
|
||||||
|
|
||||||
const (
|
|
||||||
ReplaceKeyCode ReplaceKey = "${code}" // 验证码
|
|
||||||
ReplaceKeySecond ReplaceKey = "${second}" // 秒数
|
|
||||||
ReplaceKeyUrl ReplaceKey = "${url}" // 链接
|
|
||||||
)
|
|
||||||
|
|
||||||
type Item struct {
|
|
||||||
Key ReplaceKey // 要替换的key
|
|
||||||
Value string // 要替换的值
|
|
||||||
}
|
|
||||||
|
|
||||||
type SendSmsRequest struct {
|
|
||||||
*requests.JsonRequest
|
|
||||||
Mobile string `position:"Json" field:"mobile"`
|
|
||||||
Type string `position:"Json" field:"type"`
|
|
||||||
Replaces []Item `position:"Json" field:"replaces"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SendSmsResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
type SmsType = string
|
|
||||||
|
|
||||||
const (
|
|
||||||
SmsTypeRegister SmsType = "reg" // 注册
|
|
||||||
SmsTypeBindPhone SmsType = "bind_phone" // 绑定手机号
|
|
||||||
TemplateTypeOrderComplete SmsType = "kf_order_complete" // 客服工单完成
|
|
||||||
TemplateTypeKFOrderAdditional SmsType = "kf_order_additional" // 客服工单完成
|
|
||||||
)
|
|
||||||
|
|
||||||
type SendSmsParam struct {
|
|
||||||
Mobile string // 手机号
|
|
||||||
Type SmsType // 验证码类型
|
|
||||||
Replaces []Item
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
|
||||||
req = &SendSmsRequest{
|
|
||||||
JsonRequest: &requests.JsonRequest{},
|
|
||||||
Mobile: param.Mobile,
|
|
||||||
Type: param.Type,
|
|
||||||
Replaces: param.Replaces,
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/v1/sms/send")
|
|
||||||
req.Method = requests.POST
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateSendSmsResponse() (resp *SendSmsResponse) {
|
|
||||||
resp = &SendSmsResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,18 +1,12 @@
|
|||||||
package sso
|
package sso
|
||||||
|
|
||||||
import (
|
import "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
HOST = "sso"
|
||||||
VERSION = "2020-08-07"
|
VERSION = "2020-08-07"
|
||||||
)
|
)
|
||||||
|
|
||||||
var HOST = requests.Host{
|
|
||||||
Default: "sso",
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
sdk.Client
|
sdk.Client
|
||||||
}
|
}
|
||||||
|
@ -1,77 +0,0 @@
|
|||||||
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{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
package stat
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2020-11-16"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HOST = requests.Host{
|
|
||||||
Default: "stat",
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient() (client *Client, err error) {
|
|
||||||
client = new(Client)
|
|
||||||
err = client.Init()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// SyncGameServerList 同步开服数据
|
|
||||||
func (c *Client) SyncGameServerList(req *SyncGameServerListReq) (resp *SyncGameServerListResp, err error) {
|
|
||||||
resp = CreateSyncGameServerListResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) SetUserNewGameAuth(req *SetUserNewGameAuthReq) (resp *SetUserNewGameAuthResp, err error) {
|
|
||||||
resp = CreateSetUserNewGameAuthResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetAgentList 获取推广渠道列表
|
|
||||||
func (c *Client) GetAgentList(req *GetAgentListReq) (resp *GetAgentListResp, err error) {
|
|
||||||
resp = CreateGetAgentListResp()
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUserRoleRegPage 获取用户角色注册分页列表
|
|
||||||
func (c *Client) GetUserRoleRegPage(req *UserRoleRegReq) (resp *UserRoleRegResp, err error) {
|
|
||||||
resp = CreateUserRoleRegPageResp()
|
|
||||||
// 设置超时时间
|
|
||||||
req.SetConnectTimeout(10 * time.Second)
|
|
||||||
// 设置读取超时时间
|
|
||||||
req.SetReadTimeout(20 * time.Second)
|
|
||||||
err = c.DoAction(req, resp)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,100 +0,0 @@
|
|||||||
package stat
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSyncGameServerList(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
req := CreateSyncGameServerListReq("insertOrUpdate", []map[string]interface{}{
|
|
||||||
{
|
|
||||||
"id": 123564,
|
|
||||||
"channel_id": 12456,
|
|
||||||
"version_id": 1,
|
|
||||||
"game_id": 1,
|
|
||||||
"server_id": 1,
|
|
||||||
"game_sign": "test",
|
|
||||||
"name": "test",
|
|
||||||
"open_date": "2099-03-01",
|
|
||||||
"open_time": "12:00:00",
|
|
||||||
"remark": "",
|
|
||||||
"status": 1,
|
|
||||||
"if_tj": 1,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
resp, err := client.SyncGameServerList(req)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(resp.Code, resp.Msg, resp.Count)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestClient_SetUserNewGameAuth(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
req := CreateSetUserNewGameAuthReq(map[string]string{
|
|
||||||
"game_sign": "qwldy",
|
|
||||||
"game_id": "7275",
|
|
||||||
})
|
|
||||||
|
|
||||||
resp, err := client.SetUserNewGameAuth(req)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestClient_GetUserRoleRegPage 查询用户角色注册分页
|
|
||||||
func TestClient_GetUserRoleRegPage(t *testing.T) {
|
|
||||||
client, err := NewClient()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
req := CreateUserRoleRegPageReq(UserRoleRegParam{
|
|
||||||
Page: 1,
|
|
||||||
PageSize: 10,
|
|
||||||
RoleId: "",
|
|
||||||
RoleName: "温文波箐魔灵",
|
|
||||||
})
|
|
||||||
|
|
||||||
resp, err := client.GetUserRoleRegPage(req)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
fmt.Println(resp.Code, resp.Msg, resp.Data)
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
package stat
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type SyncGameServerListReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type SyncGameServerListResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Count int `json:"count"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSyncGameServerListReq 创建同步开服数据请求
|
|
||||||
// opt: 更新 insertOrUpdate, 删除 del
|
|
||||||
//
|
|
||||||
// data: []map[string]interface{}{
|
|
||||||
// {
|
|
||||||
// "id": data.ID,
|
|
||||||
// "channel_id": data.ChannelID,
|
|
||||||
// "version_id": data.VersionID,
|
|
||||||
// "game_id": data.GameID,
|
|
||||||
// "server_id": data.ServerID,
|
|
||||||
// "game_sign": data.GameSign,
|
|
||||||
// "name": data.Name,
|
|
||||||
// "open_date": data.OpenDate.Format(constants.DateFormat),
|
|
||||||
// "open_time": data.OpenTime,
|
|
||||||
// "remark": data.Remark,
|
|
||||||
// "status": data.Status,
|
|
||||||
// "if_tj": data.IfTj,
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
func CreateSyncGameServerListReq(opt string, data []map[string]interface{}) *SyncGameServerListReq {
|
|
||||||
req := &SyncGameServerListReq{
|
|
||||||
&requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/game/syncGameServerList")
|
|
||||||
req.Method = requests.POST
|
|
||||||
|
|
||||||
marshal, _ := json.Marshal(data)
|
|
||||||
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"opt": opt,
|
|
||||||
"data": string(marshal),
|
|
||||||
}
|
|
||||||
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSyncGameServerListResp 创建同步开服数据响应
|
|
||||||
func CreateSyncGameServerListResp() *SyncGameServerListResp {
|
|
||||||
return &SyncGameServerListResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,115 +0,0 @@
|
|||||||
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 SetUserNewGameAuthReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetUserNewGameAuthResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data Data `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Data struct {
|
|
||||||
Result string `json:"result"`
|
|
||||||
}
|
|
||||||
|
|
||||||
const key = "gr_new_game"
|
|
||||||
|
|
||||||
// CreateSetUserNewGameAuthReq 设置用户新游戏授权
|
|
||||||
func CreateSetUserNewGameAuthReq(data map[string]string) *SetUserNewGameAuthReq {
|
|
||||||
req := &SetUserNewGameAuthReq{
|
|
||||||
&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, "/user/setUserNewGameAuth")
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSetUserNewGameAuthResp 创建设置用户新游戏授权响应
|
|
||||||
func CreateSetUserNewGameAuthResp() *SetUserNewGameAuthResp {
|
|
||||||
return &SetUserNewGameAuthResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------
|
|
||||||
|
|
||||||
// UserRoleReg 玩家汇总角色创建记录
|
|
||||||
type UserRoleReg struct {
|
|
||||||
UserName string `json:"user_name"`
|
|
||||||
Uid string `json:"uid"`
|
|
||||||
RoleId string `json:"role_id"`
|
|
||||||
RoleName string `json:"role_name"`
|
|
||||||
GameSign string `json:"game_sign"`
|
|
||||||
Id string `json:"id"`
|
|
||||||
CreatedAt string `json:"created_at"`
|
|
||||||
}
|
|
||||||
type UserRoleRegPage struct {
|
|
||||||
Page int `json:"page"`
|
|
||||||
TotalCount int `json:"total_count"`
|
|
||||||
PageSize int `json:"page_size"`
|
|
||||||
Data []UserRoleReg `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserRoleRegParam struct {
|
|
||||||
Page int `json:"page"`
|
|
||||||
PageSize int `json:"page_size"`
|
|
||||||
RoleId string `json:"role_id"`
|
|
||||||
RoleName string `json:"role_name"`
|
|
||||||
}
|
|
||||||
type UserRoleRegReq struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
}
|
|
||||||
type UserRoleRegResp struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data UserRoleRegPage `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateUserRoleRegPageReq(param UserRoleRegParam) *UserRoleRegReq {
|
|
||||||
req := &UserRoleRegReq{
|
|
||||||
&requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/user/getRoleRegPage")
|
|
||||||
req.Method = requests.POST
|
|
||||||
req.FormParams = map[string]string{
|
|
||||||
"page": fmt.Sprintf("%v", param.Page),
|
|
||||||
"page_size": fmt.Sprintf("%v", param.PageSize),
|
|
||||||
"role_id": param.RoleId,
|
|
||||||
"role_name": param.RoleName,
|
|
||||||
}
|
|
||||||
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
func CreateUserRoleRegPageResp() *UserRoleRegResp {
|
|
||||||
return &UserRoleRegResp{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package www
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VERSION = "2020-09-24"
|
|
||||||
)
|
|
||||||
|
|
||||||
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",
|
|
||||||
}
|
|
||||||
return a[s]
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
sdk.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) {
|
|
||||||
client = &Client{}
|
|
||||||
err = client.InitWithAccessKey(accesskey, secrect, source)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClientWithAliAppcode(accesskey, secrect string, env ...string) (client *Client, err error) {
|
|
||||||
client = &Client{}
|
|
||||||
err = client.InitWithAliAppcode(accesskey, secrect, env...)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GetUserInfo(req *GetPwdRequest) (response *GetPwdResponse, err error) {
|
|
||||||
response = CreateGetPwdResponse()
|
|
||||||
err = c.DoAction(req, response)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package www
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestClient_GetUserInfo(t *testing.T) {
|
|
||||||
|
|
||||||
c, err := NewClientWithAliAppcode("203874304", "9e5489a82dd641729186cdad166d81a3")
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
req := CreateGetPwdRequest()
|
|
||||||
req.UserName = "ttom666"
|
|
||||||
|
|
||||||
resp, err := c.GetUserInfo(req)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
|
||||||
}
|
|
||||||
fmt.Println(resp.GetHttpContentString())
|
|
||||||
fmt.Println(resp.GetHttpHeaders())
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
package www
|
|
||||||
|
|
||||||
import (
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetPwdRequest struct {
|
|
||||||
*requests.RpcRequest
|
|
||||||
UserName string `position:"Query" field:"user_name" default:"-" `
|
|
||||||
Uid int64 `position:"Query" field:"uid" default:"0"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetPwdResponse struct {
|
|
||||||
*responses.BaseResponse
|
|
||||||
Ret int `json:"ret"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data struct {
|
|
||||||
UserName string `json:"user_name"`
|
|
||||||
UserPwd string `json:"user_pwd"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetPwdRequest() (req *GetPwdRequest) {
|
|
||||||
req = &GetPwdRequest{
|
|
||||||
RpcRequest: &requests.RpcRequest{},
|
|
||||||
}
|
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/limit/getPwd.php")
|
|
||||||
req.Method = requests.GET
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGetPwdResponse() (response *GetPwdResponse) {
|
|
||||||
response = &GetPwdResponse{
|
|
||||||
BaseResponse: &responses.BaseResponse{},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
package www
|
|
Loading…
Reference in New Issue
Block a user