添加获取渠道数据接口
This commit is contained in:
parent
14551a66b4
commit
c582fbf8ed
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
|
||||
)
|
||||
|
@ -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,7 @@ 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)
|
||||
jsoniter.Unmarshal(response.GetHttpContentBytes(), response)
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -108,7 +108,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_info.go
Normal file
43
services/game/channel_info.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
|
||||
}
|
@ -36,3 +36,9 @@ func (c *Client) GetGameInfo(req *GetGameInfoReq) (resp *GetGameInfoResp, err er
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) GetChannelInfo(req *ChannelInfoReq) (resp *ChannelInfoResp, err error) {
|
||||
resp = CreateChannelInfoResp()
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
@ -32,3 +32,17 @@ func TestGetGameInfo(t *testing.T) {
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user