Merge remote-tracking branch 'origin/master'
This commit is contained in:
		
						commit
						5d941b865b
					
				
							
								
								
									
										31
									
								
								services/game/client.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								services/game/client.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					package game
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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: "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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										22
									
								
								services/game/client_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								services/game/client_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					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)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										49
									
								
								services/game/game.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								services/game/game.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					package game
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"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{},
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -29,3 +29,15 @@ func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client,
 | 
				
			|||||||
	err = client.InitWithAccessKey(accesskey, secrect, source)
 | 
						err = client.InitWithAccessKey(accesskey, secrect, source)
 | 
				
			||||||
	return
 | 
						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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										22
									
								
								services/mkt/client_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								services/mkt/client_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					package mkt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"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)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fmt.Println(list.Status, list.Code, list.Msg, list.Data)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										68
									
								
								services/mkt/subject.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								services/mkt/subject.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					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"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -49,8 +49,8 @@ func (c *Client) ComplaintUpload(req *ComplaintUploadRequest) (response *Complai
 | 
				
			|||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *Client) ComplaintNotifyUrl(req *ComplaintNotifyUrlRequest) (response *ComplaintNotifyUrlResponse, err error) {
 | 
					func (c *Client) MerchantConfigDebug(req *merchantConfigDebugRequest) (response *merchantConfigDebugResponse, err error) {
 | 
				
			||||||
	response = CreateComplaintNotifyUrlResponse()
 | 
						response = CreateMerchantConfigDebugResponse()
 | 
				
			||||||
	err = c.DoAction(req, response)
 | 
						err = c.DoAction(req, response)
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,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 ComplaintNotifyUrlRequest struct {
 | 
					 | 
				
			||||||
	*requests.RpcRequest
 | 
					 | 
				
			||||||
	MchId     string `position:"Body" field:"mch_id" default:"" `
 | 
					 | 
				
			||||||
	NotifyUrl string `position:"Body" field:"notify_url" default:"" `
 | 
					 | 
				
			||||||
	Type      int    `position:"Body" field:"type" default:""`
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type ComplaintNotifyUrlResponse struct {
 | 
					 | 
				
			||||||
	*responses.BaseResponse
 | 
					 | 
				
			||||||
	Code int    `json:"code"`
 | 
					 | 
				
			||||||
	Msg  string `json:"msg"`
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func CreateComplaintNotifyUrlRequest() (req *ComplaintNotifyUrlRequest) {
 | 
					 | 
				
			||||||
	req = &ComplaintNotifyUrlRequest{
 | 
					 | 
				
			||||||
		RpcRequest: &requests.RpcRequest{},
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	req.InitWithApiInfo(HOST, VERSION, "/api/complaint/createWxNotifyUrl")
 | 
					 | 
				
			||||||
	req.Method = requests.POST
 | 
					 | 
				
			||||||
	return
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func CreateComplaintNotifyUrlResponse() (response *ComplaintNotifyUrlResponse) {
 | 
					 | 
				
			||||||
	response = &ComplaintNotifyUrlResponse{
 | 
					 | 
				
			||||||
		BaseResponse: &responses.BaseResponse{},
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										33
									
								
								services/pay/merchant_config_debug.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								services/pay/merchant_config_debug.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										35
									
								
								services/script/client.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								services/script/client.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										21
									
								
								services/script/client_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								services/script/client_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					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)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										41
									
								
								services/script/script.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								services/script/script.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					package script
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type OpenGameResp 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{},
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						req.InitWithApiInfo(HOST, VERSION, "open_game.php?game_id="+fmt.Sprintf("%v", gameId))
 | 
				
			||||||
 | 
						req.Method = requests.POST
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return req
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// CreateOpenGameResp 创建同步到游戏中心响应
 | 
				
			||||||
 | 
					func CreateOpenGameResp() *OpenGameResp {
 | 
				
			||||||
 | 
						return &OpenGameResp{
 | 
				
			||||||
 | 
							BaseResponse: &responses.BaseResponse{},
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										41
									
								
								services/stat/client.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								services/stat/client.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					package stat
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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: "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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										54
									
								
								services/stat/client_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								services/stat/client_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					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)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										62
									
								
								services/stat/game.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								services/stat/game.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,62 @@
 | 
				
			|||||||
 | 
					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{},
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										59
									
								
								services/stat/user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								services/stat/user.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,59 @@
 | 
				
			|||||||
 | 
					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{},
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user