78 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package stat
 | 
						||
 | 
						||
import (
 | 
						||
	"crypto/md5"
 | 
						||
	"encoding/hex"
 | 
						||
	"fmt"
 | 
						||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
 | 
						||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
 | 
						||
	"time"
 | 
						||
)
 | 
						||
 | 
						||
type GetAgentListReq struct {
 | 
						||
	*requests.RpcRequest
 | 
						||
}
 | 
						||
 | 
						||
/**
 | 
						||
返回json格式如下:
 | 
						||
{
 | 
						||
	“code": 0,
 | 
						||
	"msg": "success",
 | 
						||
	"data": {
 | 
						||
			"list": []
 | 
						||
	}
 | 
						||
}
 | 
						||
*/
 | 
						||
 | 
						||
type GetAgentListResp struct {
 | 
						||
	*responses.BaseResponse
 | 
						||
	Code int       `json:"code"`
 | 
						||
	Msg  string    `json:"msg"`
 | 
						||
	Data AgentList `json:"data"`
 | 
						||
}
 | 
						||
type AgentList struct {
 | 
						||
	List []Agent `json:"list"`
 | 
						||
}
 | 
						||
type Agent struct {
 | 
						||
	AgentId     string `json:"agent_id"`
 | 
						||
	AgentName   string `json:"agent_name"`
 | 
						||
	Media       string `json:"media"`
 | 
						||
	Channel     string `json:"channel"`
 | 
						||
	MediaName   string `json:"media_name"`
 | 
						||
	ChannelName string `json:"channel_name"`
 | 
						||
}
 | 
						||
 | 
						||
//const key = "gr_new_game"
 | 
						||
 | 
						||
// CreateGetAgentListReq 获取推广渠道列表请求
 | 
						||
func CreateGetAgentListReq(data map[string]string) *GetAgentListReq {
 | 
						||
	req := &GetAgentListReq{
 | 
						||
		&requests.RpcRequest{},
 | 
						||
	}
 | 
						||
 | 
						||
	ts := time.Now().Unix()
 | 
						||
	hash := md5.New()
 | 
						||
	hash.Write([]byte(fmt.Sprintf("%v%v", ts, key)))
 | 
						||
	hashBytes := hash.Sum(nil)
 | 
						||
 | 
						||
	token := hex.EncodeToString(hashBytes)
 | 
						||
 | 
						||
	req.InitWithApiInfo(HOST, VERSION, "/agent/getAgentList")
 | 
						||
	req.Method = requests.POST
 | 
						||
 | 
						||
	req.FormParams = data
 | 
						||
	if req.FormParams == nil {
 | 
						||
		req.FormParams = make(map[string]string)
 | 
						||
	}
 | 
						||
	req.FormParams["sign"] = token
 | 
						||
	req.FormParams["time"] = fmt.Sprintf("%v", ts)
 | 
						||
	return req
 | 
						||
}
 | 
						||
 | 
						||
// CreateGetAgentListResp 获取推广渠道列表响应
 | 
						||
func CreateGetAgentListResp() *GetAgentListResp {
 | 
						||
	return &GetAgentListResp{
 | 
						||
		BaseResponse: &responses.BaseResponse{},
 | 
						||
	}
 | 
						||
}
 |