Compare commits
	
		
			21 Commits
		
	
	
		
			561eb1416a
			...
			7e664f3f29
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					7e664f3f29 | ||
| 
						 | 
					abca5f01ed | ||
| 
						 | 
					34de4b0401 | ||
| 
						 | 
					71b93169e2 | ||
| 
						 | 
					7dc4a177f9 | ||
| 
						 | 
					9591e794f0 | ||
| 
						 | 
					055fb8abb9 | ||
| 3652d43f34 | |||
| 
						 | 
					7c96d7163b | ||
| 
						 | 
					b9a481e71b | ||
| 5a8de98af3 | |||
| 6c3dfae18b | |||
| b29010cac6 | |||
| 792d13fa32 | |||
| ce30ff4ef9 | |||
| 78d60083f7 | |||
| bee78a0b12 | |||
| c582fbf8ed | |||
| 
						 | 
					14551a66b4 | ||
| d8528ecbe8 | |||
| b7bf3c7585 | 
							
								
								
									
										9
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								go.mod
									
									
									
									
									
								
							@ -1,3 +1,10 @@
 | 
			
		||||
module golib.gaore.com/GaoreGo/gaore-common-sdk-go
 | 
			
		||||
 | 
			
		||||
go 1.19
 | 
			
		||||
go 1.19
 | 
			
		||||
 | 
			
		||||
require github.com/json-iterator/go v1.1.12
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
 | 
			
		||||
	github.com/modern-go/reflect2 v1.0.2 // indirect
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								go.sum
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								go.sum
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
			
		||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 | 
			
		||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
			
		||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 | 
			
		||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
 | 
			
		||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
 | 
			
		||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
 | 
			
		||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 | 
			
		||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
 | 
			
		||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
 | 
			
		||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 | 
			
		||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 | 
			
		||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 | 
			
		||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
 | 
			
		||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 | 
			
		||||
@ -5,6 +5,7 @@ import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"crypto/tls"
 | 
			
		||||
	"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/credentials"
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
 | 
			
		||||
@ -18,6 +19,7 @@ import (
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -359,3 +361,10 @@ func (client *Client) getNoProxy(scheme string) []string {
 | 
			
		||||
func hookDo(fn func(req *http.Request) (*http.Response, error)) func(req *http.Request) (*http.Response, error) {
 | 
			
		||||
	return fn
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	once := sync.Once{}
 | 
			
		||||
	once.Do(func() {
 | 
			
		||||
		extra.RegisterFuzzyDecoders()
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
package responses
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/json-iterator/go"
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"net/http"
 | 
			
		||||
@ -97,7 +97,10 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
 | 
			
		||||
		if contentType, ok := response.GetHttpHeaders()["Content-Type"]; ok {
 | 
			
		||||
			for _, v := range contentType {
 | 
			
		||||
				if strings.Contains(v, requests.Json) {
 | 
			
		||||
					json.Unmarshal(response.GetHttpContentBytes(), response)
 | 
			
		||||
					err = jsoniter.Unmarshal(response.GetHttpContentBytes(), response)
 | 
			
		||||
					if err != nil {
 | 
			
		||||
						return errors.New("json Unmarshal:" + err.Error())
 | 
			
		||||
					}
 | 
			
		||||
					break
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
@ -108,7 +111,7 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if format != "xml" {
 | 
			
		||||
		err = json.Unmarshal(response.GetHttpContentBytes(), response)
 | 
			
		||||
		err = jsoniter.Unmarshal(response.GetHttpContentBytes(), response)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return errors.New("json Unmarshal:" + err.Error())
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										43
									
								
								services/game/channel.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								services/game/channel.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,43 @@
 | 
			
		||||
package game
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type ChannelInfoReq struct {
 | 
			
		||||
	*requests.RpcRequest
 | 
			
		||||
	ChannelId  int64  `position:"Body" field:"channelId"`
 | 
			
		||||
	ChannelKey string `position:"Body" field:"channelKey"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ChannelInfoResp struct {
 | 
			
		||||
	*responses.BaseResponse
 | 
			
		||||
	Code int    `json:"code"`
 | 
			
		||||
	Msg  string `json:"msg"`
 | 
			
		||||
	Data map[int64]struct {
 | 
			
		||||
		Id             int64  `json:"id"`
 | 
			
		||||
		PlatKey        string `json:"plat_key"`
 | 
			
		||||
		PlatName       string `json:"plat_name"`
 | 
			
		||||
		PlatCompany    string `json:"plat_company"`
 | 
			
		||||
		PlatUrl        string `json:"plat_url"`
 | 
			
		||||
		Company        string `json:"company"`
 | 
			
		||||
		PlatCategoryId int64  `json:"plat_category_id"`
 | 
			
		||||
		CategoryName   string `json:"category_name"`
 | 
			
		||||
	} `json:"data"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateChannelInfoReq() *ChannelInfoReq {
 | 
			
		||||
	req := &ChannelInfoReq{
 | 
			
		||||
		RpcRequest: &requests.RpcRequest{},
 | 
			
		||||
	}
 | 
			
		||||
	req.InitWithApiInfo(HOST, VERSION, "/api/channel/getChannelInfo")
 | 
			
		||||
	return req
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateChannelInfoResp() *ChannelInfoResp {
 | 
			
		||||
	resp := &ChannelInfoResp{
 | 
			
		||||
		BaseResponse: &responses.BaseResponse{},
 | 
			
		||||
	}
 | 
			
		||||
	return resp
 | 
			
		||||
}
 | 
			
		||||
@ -6,7 +6,7 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	VERSION = "2020-11-16"
 | 
			
		||||
	VERSION = "2025-05-28"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var HOST = requests.Host{
 | 
			
		||||
@ -29,3 +29,49 @@ func (c *Client) GetGameOsInfo(req *GetGameOsInfoReq) (resp *GetGameOsInfoResp,
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -20,3 +20,103 @@ func TestGetGameOsInfo(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
package game
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
 | 
			
		||||
)
 | 
			
		||||
@ -47,3 +48,210 @@ func CreateGetGameOsInfoResp() *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            int    `json:"download_id"`
 | 
			
		||||
	ExchangeRate          int    `json:"exchange_rate"`
 | 
			
		||||
	ExtData               string `json:"ext_data"`
 | 
			
		||||
	Fcmathod              int    `json:"fcmathod"`
 | 
			
		||||
	FirstLetter           string `json:"first_letter"`
 | 
			
		||||
	FlashAuthId           string `json:"flash_auth_id"`
 | 
			
		||||
	FlashAuthKey          string `json:"flash_auth_key"`
 | 
			
		||||
	FlashAuthLogo         string `json:"flash_auth_logo"`
 | 
			
		||||
	FlashAuthName         string `json:"flash_auth_name"`
 | 
			
		||||
	FlashAuthStatus       int    `json:"flash_auth_status"`
 | 
			
		||||
	GameByname            string `json:"game_byname"`
 | 
			
		||||
	GameIconImg           string `json:"game_icon_img"`
 | 
			
		||||
	GameSign              string `json:"game_sign"`
 | 
			
		||||
	GameTsUrl             string `json:"game_ts_url"`
 | 
			
		||||
	GameVersion           string `json:"game_version"`
 | 
			
		||||
	GameZsUrl             string `json:"game_zs_url"`
 | 
			
		||||
	GetRoleUrl            string `json:"get_role_url"`
 | 
			
		||||
	HideRedButton         int    `json:"hide_red_button"`
 | 
			
		||||
	Icon                  string `json:"icon"`
 | 
			
		||||
	Icp                   string `json:"icp"`
 | 
			
		||||
	IcpUrl                string `json:"icp_url"`
 | 
			
		||||
	Id                    int    `json:"id"`
 | 
			
		||||
	IsAugment             int    `json:"is_augment"`
 | 
			
		||||
	IsOpen                int    `json:"is_open"`
 | 
			
		||||
	IsSync                int    `json:"is_sync"`
 | 
			
		||||
	MarketName            string `json:"market_name"`
 | 
			
		||||
	MediaAbbr             string `json:"media_abbr"`
 | 
			
		||||
	MobileLoginState      int    `json:"mobile_login_state"`
 | 
			
		||||
	MobileRegState        int    `json:"mobile_reg_state"`
 | 
			
		||||
	Name                  string `json:"name"`
 | 
			
		||||
	ObjectiveId           int    `json:"objective_id"`
 | 
			
		||||
	OpenGame              int    `json:"open_game"`
 | 
			
		||||
	Os                    int    `json:"os"`
 | 
			
		||||
	OsTwo                 int    `json:"os_two"`
 | 
			
		||||
	Owner                 int    `json:"owner"`
 | 
			
		||||
	PackageNameId         int    `json:"package_name_id"`
 | 
			
		||||
	PayUrl                string `json:"pay_url"`
 | 
			
		||||
	PlatId                int    `json:"plat_id"`
 | 
			
		||||
	Platform              int    `json:"platform"`
 | 
			
		||||
	ProtocolPreState      int    `json:"protocol_pre_state"`
 | 
			
		||||
	Rank                  int    `json:"rank"`
 | 
			
		||||
	RegisterProtocolState int    `json:"register_protocol_state"`
 | 
			
		||||
	RelateGame            string `json:"relate_game"`
 | 
			
		||||
	ReleaseState          int    `json:"release_state"`
 | 
			
		||||
	Remark                string `json:"remark"`
 | 
			
		||||
	RequestDomain         string `json:"request_domain"`
 | 
			
		||||
	ResultCode            string `json:"result_code"`
 | 
			
		||||
	ScreenType            int    `json:"screen_type"`
 | 
			
		||||
	ServerGroupId         int    `json:"server_group_id"`
 | 
			
		||||
	ServerSign            int    `json:"server_sign"`
 | 
			
		||||
	SimId                 int    `json:"sim_id"`
 | 
			
		||||
	SpareRequestDomain    string `json:"spare_request_domain"`
 | 
			
		||||
	TwOs                  int    `json:"tw_os"`
 | 
			
		||||
	TwPlatId              int    `json:"tw_plat_id"`
 | 
			
		||||
	UpdatedAt             string `json:"updated_at"`
 | 
			
		||||
	UpdatedRealname       string `json:"updated_realname"`
 | 
			
		||||
	UpdatedUsername       string `json:"updated_username"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateGetGameInfoByIdReq(gameId, noCache int) *GetGameInfoReq {
 | 
			
		||||
	req := &GetGameInfoReq{
 | 
			
		||||
		RpcRequest: &requests.RpcRequest{},
 | 
			
		||||
	}
 | 
			
		||||
	req.InitWithApiInfo(HOST, VERSION, fmt.Sprintf("/api/game/getGameById/%d?no_cache=%d", gameId, noCache))
 | 
			
		||||
	req.Method = requests.GET
 | 
			
		||||
	return req
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateGetGameInfoByIdResp() *GetGameInfoResp {
 | 
			
		||||
	return &GetGameInfoResp{
 | 
			
		||||
		BaseResponse: &responses.BaseResponse{},
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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{},
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										107
									
								
								services/game/game_server.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								services/game/game_server.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,107 @@
 | 
			
		||||
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
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										73
									
								
								services/game/login.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								services/game/login.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,73 @@
 | 
			
		||||
package game
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GetLoginInfoByIdReq struct {
 | 
			
		||||
	*requests.RpcRequest
 | 
			
		||||
	GameId      int    `position:"Body" field:"game_id"`
 | 
			
		||||
	GameVersion string `position:"Body" field:"game_version"`
 | 
			
		||||
	Uid         int    `position:"Body" field:"uid"`
 | 
			
		||||
	UserName    string `position:"Body" field:"uname"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type PayInfo struct {
 | 
			
		||||
	HiddenAlipay   int `json:"hide_alipay"`
 | 
			
		||||
	HiddenWx       int `json:"hide_wx"`
 | 
			
		||||
	HiddenUnionPay int `json:"hide_union_pay"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GameVersionInfo struct {
 | 
			
		||||
	AppName        string         `json:"app_name"`
 | 
			
		||||
	AppID          string         `json:"app_id"`
 | 
			
		||||
	LoginURL       string         `json:"login_url"`
 | 
			
		||||
	PayURL         string         `json:"pay_url"`
 | 
			
		||||
	GameURL        string         `json:"game_url"`
 | 
			
		||||
	PayCallbackURL string         `json:"pay_callback_url"`
 | 
			
		||||
	IsH5Logout     int            `json:"is_h5_logout"`
 | 
			
		||||
	HideWindow     int            `json:"hidewindow"`
 | 
			
		||||
	GameVersion    string         `json:"version"`
 | 
			
		||||
	GameSign       string         `json:"game_sign"`
 | 
			
		||||
	GameSignName   string         `json:"game_sign_name"`
 | 
			
		||||
	GameSignID     int            `json:"game_sign_id"`
 | 
			
		||||
	IsYsdk         int            `json:"is_ysdk"`
 | 
			
		||||
	Company        string         `json:"company"`
 | 
			
		||||
	CompanyKf      string         `json:"company_kf"`
 | 
			
		||||
	CompanyProto   string         `json:"company_proto"`
 | 
			
		||||
	CompanySms     string         `json:"company_sms"`
 | 
			
		||||
	KfStatus       int            `json:"kf_status"`
 | 
			
		||||
	PopupTime      int            `json:"popup_time"`
 | 
			
		||||
	GameId         int            `json:"game_id"`
 | 
			
		||||
	ScreenType     int            `json:"screen_type"`
 | 
			
		||||
	GameSwitch     int            `json:"game_switch"` // 根据上下文,0 或 1 的整数表示布尔值
 | 
			
		||||
	ExtData        map[string]any `json:"ext_data"`
 | 
			
		||||
	OsName         string         `json:"os_name"`
 | 
			
		||||
	PayInfo        PayInfo        `json:"pay_info"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetLoginInfoByIdResp struct {
 | 
			
		||||
	*responses.BaseResponse
 | 
			
		||||
	Code int             `json:"code"`
 | 
			
		||||
	Msg  string          `json:"msg"`
 | 
			
		||||
	Data GameVersionInfo `json:"data"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateGetLoginInfoByIdReq(gameId int, gameVersion string) *GetLoginInfoByIdReq {
 | 
			
		||||
	req := &GetLoginInfoByIdReq{
 | 
			
		||||
		RpcRequest: &requests.RpcRequest{},
 | 
			
		||||
	}
 | 
			
		||||
	req.GameId = gameId
 | 
			
		||||
	req.GameVersion = gameVersion
 | 
			
		||||
	req.InitWithApiInfo(HOST, VERSION, "/api/login/getInfoById")
 | 
			
		||||
	req.Method = requests.POST
 | 
			
		||||
	return req
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateGetLoginInfoByIdResp() *GetLoginInfoByIdResp {
 | 
			
		||||
	resp := &GetLoginInfoByIdResp{
 | 
			
		||||
		BaseResponse: &responses.BaseResponse{},
 | 
			
		||||
	}
 | 
			
		||||
	return resp
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										37
									
								
								services/game/news.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								services/game/news.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
			
		||||
package game
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GetProtocolByGameIdRep struct {
 | 
			
		||||
	*requests.RpcRequest
 | 
			
		||||
	GameId      int    `position:"Query" field:"game_id"`
 | 
			
		||||
	GameVersion string `position:"Query" field:"game_version"`
 | 
			
		||||
	Type        int    `position:"Query" field:"type"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetProtocolByGameIdResp struct {
 | 
			
		||||
	*responses.BaseResponse
 | 
			
		||||
	Code int    `json:"code"`
 | 
			
		||||
	Msg  string `json:"msg"`
 | 
			
		||||
	Data struct {
 | 
			
		||||
		Content string `json:"content"`
 | 
			
		||||
	} `json:"data"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateGetProtocolByGameIdRep() *GetProtocolByGameIdRep {
 | 
			
		||||
	req := &GetProtocolByGameIdRep{
 | 
			
		||||
		RpcRequest: &requests.RpcRequest{},
 | 
			
		||||
	}
 | 
			
		||||
	req.InitWithApiInfo(HOST, VERSION, "/api/news/getProtocolByGameId")
 | 
			
		||||
	req.Method = requests.GET
 | 
			
		||||
	return req
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateGetProtocolByGameIdResp() *GetProtocolByGameIdResp {
 | 
			
		||||
	return &GetProtocolByGameIdResp{
 | 
			
		||||
		BaseResponse: &responses.BaseResponse{},
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -31,7 +31,7 @@ func NewClientWithSts() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Client) PutOss(req *PutOssRequest) (resp *PutOssResponse, err error) {
 | 
			
		||||
	if req.BucketName == "" {
 | 
			
		||||
	if req.Bucket == "" {
 | 
			
		||||
		err = errors.New("bucket name is empty")
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,8 @@ import (
 | 
			
		||||
 | 
			
		||||
func TestUpload_Put(t *testing.T) {
 | 
			
		||||
	req := CreatePutOssRequest()
 | 
			
		||||
	req.BucketName = "image"
 | 
			
		||||
	req.Bucket = "image"
 | 
			
		||||
	//req.Bucket = "web"
 | 
			
		||||
	file, err := os.ReadFile("test.jpg")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Error(err)
 | 
			
		||||
@ -26,7 +27,7 @@ func TestUpload_Put(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
func TestUpload_Del(t *testing.T) {
 | 
			
		||||
	req := CreateDelOssRequest()
 | 
			
		||||
	req.BucketName = "image"
 | 
			
		||||
	req.Bucket = "image"
 | 
			
		||||
	req.MediaUrl = "https://image.89yoo.com/uploads/549/549e887460a72333c361661683023018.jpeg"
 | 
			
		||||
	client, err := NewClient()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
 | 
			
		||||
@ -7,8 +7,8 @@ import (
 | 
			
		||||
 | 
			
		||||
type DelOssRequest struct {
 | 
			
		||||
	*requests.JsonRequest
 | 
			
		||||
	BucketName string `position:"Json" field:"bucket_name" default:"image"`
 | 
			
		||||
	MediaUrl   string `position:"Json" field:"url" default:"-"`
 | 
			
		||||
	Bucket   string `position:"Json" field:"bucket" default:"image"`
 | 
			
		||||
	MediaUrl string `position:"Json" field:"url" default:"-"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type DelOssResponse struct {
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,7 @@ import (
 | 
			
		||||
 | 
			
		||||
type PutOssRequest struct {
 | 
			
		||||
	*requests.StreamRequest
 | 
			
		||||
	BucketName string `position:"Query" field:"bucket_name" default:"image"`
 | 
			
		||||
	Bucket     string `position:"Query" field:"bucket" default:"image"`
 | 
			
		||||
	FileStream []byte
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										42
									
								
								services/passport/client.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								services/passport/client.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,42 @@
 | 
			
		||||
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
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										33
									
								
								services/passport/client_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								services/passport/client_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
			
		||||
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)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										114
									
								
								services/passport/userinfo.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								services/passport/userinfo.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,114 @@
 | 
			
		||||
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
 | 
			
		||||
}
 | 
			
		||||
@ -54,3 +54,11 @@ func (c *Client) MerchantConfigDebug(req *merchantConfigDebugRequest) (response
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -24,3 +24,18 @@ func TestClient_GetUserInfo(t *testing.T) {
 | 
			
		||||
	//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())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -9,6 +9,7 @@ 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 {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										44
									
								
								services/pay/get_order_state.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								services/pay/get_order_state.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
			
		||||
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
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										99
									
								
								services/sms/client.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								services/sms/client.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,99 @@
 | 
			
		||||
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
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										142
									
								
								services/sms/client_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								services/sms/client_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,142 @@
 | 
			
		||||
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)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										45
									
								
								services/sms/email.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								services/sms/email.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
package sms
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type SendEmailRequest struct {
 | 
			
		||||
	*requests.JsonRequest
 | 
			
		||||
	Addresses []string `position:"Json" field:"addresses"`
 | 
			
		||||
	Subject   string   `position:"Json" field:"subject"`
 | 
			
		||||
	Body      string   `position:"Json" field:"body"`
 | 
			
		||||
	FromName  string   `position:"Json" field:"from_name"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type SendEmailResponse struct {
 | 
			
		||||
	*responses.BaseResponse
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type SendEmailParam struct {
 | 
			
		||||
	Addresses []string
 | 
			
		||||
	Subject   string
 | 
			
		||||
	Body      string
 | 
			
		||||
	FromName  string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateSendEmailRequest(param SendEmailParam) (req *SendEmailRequest) {
 | 
			
		||||
	req = &SendEmailRequest{
 | 
			
		||||
		JsonRequest: &requests.JsonRequest{},
 | 
			
		||||
		Addresses:   param.Addresses,
 | 
			
		||||
		Subject:     param.Subject,
 | 
			
		||||
		Body:        param.Body,
 | 
			
		||||
		FromName:    param.FromName,
 | 
			
		||||
	}
 | 
			
		||||
	req.InitWithApiInfo(HOST, VERSION, "/v1/email/send")
 | 
			
		||||
	req.Method = requests.POST
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateSendEmailResponse() (resp *SendEmailResponse) {
 | 
			
		||||
	resp = &SendEmailResponse{
 | 
			
		||||
		BaseResponse: &responses.BaseResponse{},
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										57
									
								
								services/sms/feishu.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								services/sms/feishu.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,57 @@
 | 
			
		||||
package sms
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
 | 
			
		||||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type SendFeiShuWebHookRequest struct {
 | 
			
		||||
	*requests.JsonRequest
 | 
			
		||||
	Do         string `position:"Json" field:"do"`
 | 
			
		||||
	Token      string `position:"Json" field:"token"`
 | 
			
		||||
	Content    string `position:"Json" field:"content"`
 | 
			
		||||
	Title      string `position:"Json" field:"title"`
 | 
			
		||||
	TitleColor string `position:"Json" field:"title_color"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type SendFeiShuWebHookResponse struct {
 | 
			
		||||
	*responses.BaseResponse
 | 
			
		||||
	FeishuData string `json:"feishu_data"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type FeiShuWebHookDoType = string
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	FeiShuWebHookDoTypeSendSimpleText FeiShuWebHookDoType = "sendSimpleText"
 | 
			
		||||
	FeiShuWebHookDoTypeSendRichText   FeiShuWebHookDoType = "sendRichText"
 | 
			
		||||
	FeiShuWebHookDoTypeSendCardText   FeiShuWebHookDoType = "sendCardText"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type SendFeiShuWebHookParam struct {
 | 
			
		||||
	Do         FeiShuWebHookDoType
 | 
			
		||||
	Token      string
 | 
			
		||||
	Content    string
 | 
			
		||||
	Title      string
 | 
			
		||||
	TitleColor string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateSendFeiShuWebHookRequest(param SendFeiShuWebHookParam) (req *SendFeiShuWebHookRequest) {
 | 
			
		||||
	req = &SendFeiShuWebHookRequest{
 | 
			
		||||
		JsonRequest: &requests.JsonRequest{},
 | 
			
		||||
		Do:          param.Do,
 | 
			
		||||
		Token:       param.Token,
 | 
			
		||||
		Content:     param.Content,
 | 
			
		||||
		Title:       param.Title,
 | 
			
		||||
		TitleColor:  param.TitleColor,
 | 
			
		||||
	}
 | 
			
		||||
	req.InitWithApiInfo(HOST, VERSION, "/v1/feishu/webhook_send")
 | 
			
		||||
	req.Method = requests.POST
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateSendFeiShuWebHookResponse() (resp *SendFeiShuWebHookResponse) {
 | 
			
		||||
	resp = &SendFeiShuWebHookResponse{
 | 
			
		||||
		BaseResponse: &responses.BaseResponse{},
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										64
									
								
								services/sms/sms.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								services/sms/sms.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,64 @@
 | 
			
		||||
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
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user