feat(stat): 为用户统计服务添加json标签支持
This commit is contained in:
parent
1cab5442a2
commit
642aefcd16
@ -1,6 +1,7 @@
|
||||
package stat
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
@ -138,51 +139,52 @@ func TestGetGameServerCountData(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserReg(t *testing.T) {
|
||||
req := CreateUserRegRequest()
|
||||
|
||||
param := &UserRegParam{}
|
||||
// DeviceInfo 字段
|
||||
req.Network = "WiFi"
|
||||
req.ScreenResolution = "1920x1080"
|
||||
req.System = "Android 11"
|
||||
req.Electric = "80"
|
||||
req.ProcessorModel = "Snapdragon 888"
|
||||
req.BaseBand = "qualcomm"
|
||||
req.Model = "Xiaomi Mi 11"
|
||||
req.Battery = "80"
|
||||
req.Package = "com.game.test"
|
||||
req.LongId = "device_long_id_123456"
|
||||
req.Imei = "123456789012345"
|
||||
req.Oaid = "oaid_1234567890"
|
||||
req.Idfa = "idfa_1234567890"
|
||||
req.Idfv = "idfv_1234567890"
|
||||
req.AdDevice = "ad_device_info"
|
||||
req.Os = "Android"
|
||||
req.IP = "192.168.1.100"
|
||||
req.Ua = "Mozilla/5.0..."
|
||||
req.WxPlatform = "WeChat MiniProgram"
|
||||
req.Adinfo = "ad_info_data"
|
||||
param.Network = "WiFi"
|
||||
param.ScreenResolution = "1920x1080"
|
||||
param.System = "Android 11"
|
||||
param.Electric = "80"
|
||||
param.ProcessorModel = "Snapdragon 888"
|
||||
param.BaseBand = "qualcomm"
|
||||
param.Model = "Xiaomi Mi 11"
|
||||
param.Battery = "80"
|
||||
param.Package = "com.game.test"
|
||||
param.LongId = "device_long_id_123456"
|
||||
param.Imei = "123456789012345"
|
||||
param.Oaid = "oaid_1234567890"
|
||||
param.Idfa = "idfa_1234567890"
|
||||
param.Idfv = "idfv_1234567890"
|
||||
param.AdDevice = "ad_device_info"
|
||||
param.Os = "Android"
|
||||
param.IP = "192.168.1.100"
|
||||
param.Ua = "Mozilla/5.0..."
|
||||
param.WxPlatform = "WeChat MiniProgram"
|
||||
param.Adinfo = "ad_info_data"
|
||||
|
||||
// UserRegRequest 特有字段
|
||||
req.ChannelId = 1
|
||||
req.GameId = 7275
|
||||
req.LoginGameId = 7275
|
||||
req.GameSign = "qwldy"
|
||||
req.Uid = 123456
|
||||
req.UserName = "test_user"
|
||||
req.Openid = 123456
|
||||
req.ComeBackUser = 1
|
||||
req.RegTime = time.Now().Unix()
|
||||
req.Logined = 1
|
||||
req.RegType = 1
|
||||
req.LpReg = 0
|
||||
req.MatchType = 1
|
||||
req.AgentId = 100
|
||||
req.SiteId = 1001
|
||||
req.PkgAgentId = 100
|
||||
req.PkgSiteId = 1001
|
||||
req.FromAd = 0
|
||||
req.FanCode = "FAN123456"
|
||||
req.InvalidUuid = 0
|
||||
// UserRegparamuest 特有字段
|
||||
param.ChannelId = 1
|
||||
param.GameId = 7275
|
||||
param.LoginGameId = 7275
|
||||
param.GameSign = "qwldy"
|
||||
param.Uid = 123456
|
||||
param.UserName = "test_user"
|
||||
param.Openid = "123456"
|
||||
param.ComeBackUser = 1
|
||||
param.RegTime = time.Now().Unix()
|
||||
param.Logined = 1
|
||||
param.RegType = 1
|
||||
param.LpReg = 0
|
||||
param.MatchType = 1
|
||||
param.AgentId = 100
|
||||
param.SiteId = 1001
|
||||
param.PkgAgentId = 100
|
||||
param.PkgSiteId = 1001
|
||||
param.FromAd = 0
|
||||
param.FanCode = "FAN123456"
|
||||
param.InvalidUuid = 0
|
||||
req := CreateUserRegRequest(param)
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -196,47 +198,54 @@ func TestUserReg(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserLogin(t *testing.T) {
|
||||
req := CreateUserLoginRequest()
|
||||
param := &UserLoginParam{}
|
||||
// DeviceInfo 字段
|
||||
req.Network = "WiFi"
|
||||
req.ScreenResolution = "1920x1080"
|
||||
req.System = "Android 11"
|
||||
req.Electric = "80"
|
||||
req.ProcessorModel = "Snapdragon 888"
|
||||
req.BaseBand = "qualcomm"
|
||||
req.Model = "Xiaomi Mi 11"
|
||||
req.Battery = "80"
|
||||
req.Package = "com.game.test"
|
||||
req.LongId = "device_long_id_123456"
|
||||
req.Imei = "123456789012345"
|
||||
req.Oaid = "oaid_1234567890"
|
||||
req.Idfa = "idfa_1234567890"
|
||||
req.Idfv = "idfv_1234567890"
|
||||
req.AdDevice = "ad_device_info"
|
||||
req.Os = "Android"
|
||||
req.IP = "192.168.1.100"
|
||||
req.Ua = "Mozilla/5.0..."
|
||||
req.WxPlatform = "WeChat MiniProgram"
|
||||
req.Adinfo = "ad_info_data"
|
||||
param.Network = "WiFi"
|
||||
param.ScreenResolution = "1920x1080"
|
||||
param.System = "Android 11"
|
||||
param.Electric = "80"
|
||||
param.ProcessorModel = "Snapdragon 888"
|
||||
param.BaseBand = "qualcomm"
|
||||
param.Model = "Xiaomi Mi 11"
|
||||
param.Battery = "80"
|
||||
param.Package = "com.game.test"
|
||||
param.LongId = "device_long_id_123456"
|
||||
param.Imei = "123456789012345"
|
||||
param.Oaid = "oaid_1234567890"
|
||||
param.Idfa = "idfa_1234567890"
|
||||
param.Idfv = "idfv_1234567890"
|
||||
param.AdDevice = "ad_device_info"
|
||||
param.Os = "Android"
|
||||
param.IP = "192.168.1.100"
|
||||
param.Ua = "Mozilla/5.0..."
|
||||
param.WxPlatform = "WeChat MiniProgram"
|
||||
param.Adinfo = "ad_info_data"
|
||||
|
||||
// UserRegRequest 特有字段
|
||||
req.ChannelId = 1
|
||||
req.GameId = 7275
|
||||
req.GameSign = "qwldy"
|
||||
req.Uid = 123456
|
||||
req.UserName = "test_user"
|
||||
req.RegTime = time.Now().Unix()
|
||||
req.OriginalImei = req.Imei
|
||||
req.LoginTime = time.Now().Unix()
|
||||
req.LoginAgentId = 100
|
||||
req.LoginSiteId = 1001
|
||||
req.PkgAgentId = 100
|
||||
req.PkgSiteId = 1001
|
||||
req.Version = "2.7.1"
|
||||
// UserRegparamuest 特有字段
|
||||
param.ChannelId = 1
|
||||
param.GameId = 7275
|
||||
param.GameSign = "qwldy"
|
||||
param.Uid = 123456
|
||||
param.UserName = "test_user"
|
||||
param.RegTime = time.Now().Unix()
|
||||
param.OriginalImei = param.Imei
|
||||
param.LoginTime = time.Now().Unix()
|
||||
param.LoginAgentId = 100
|
||||
param.LoginSiteId = 1001
|
||||
param.PkgAgentId = 100
|
||||
param.PkgSiteId = 1001
|
||||
param.Version = "2.7.1"
|
||||
b, err := json.Marshal(param)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(string(b))
|
||||
req := CreateUserLoginRequest(param)
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := client.UserLogin(req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@ -115,51 +115,56 @@ func CreateUserRoleRegPageResp() *UserRoleRegResp {
|
||||
}
|
||||
|
||||
type DeviceInfo struct {
|
||||
Network string `position:"Body" field:"network" default:""`
|
||||
ScreenResolution string `position:"Body" field:"screen_resolution" default:""`
|
||||
System string `position:"Body" field:"system" default:""`
|
||||
Electric string `position:"Body" field:"electric" default:""`
|
||||
ProcessorModel string `position:"Body" field:"processor_model" default:""`
|
||||
BaseBand string `position:"Body" field:"baseband" default:""`
|
||||
Model string `position:"Body" field:"model" default:""`
|
||||
Battery string `position:"Body" field:"battery" default:""`
|
||||
Package string `position:"Body" field:"package" default:""`
|
||||
LongId string `position:"Body" field:"long_id" default:""`
|
||||
Imei string `position:"Body" field:"imei" default:""`
|
||||
Oaid string `position:"Body" field:"oaid" default:""`
|
||||
Idfa string `position:"Body" field:"idfa" default:""`
|
||||
Idfv string `position:"Body" field:"idfv" default:""`
|
||||
AdDevice string `position:"Body" field:"ad_device" default:""`
|
||||
Os string `position:"Body" field:"os" default:""`
|
||||
IP string `position:"Body" field:"ip" default:""`
|
||||
Ua string `position:"Body" field:"ua" default:""`
|
||||
WxPlatform string `position:"Body" field:"wx_platform" default:""`
|
||||
Adinfo string `position:"Body" field:"adinfo" default:""`
|
||||
Network string `position:"Body" field:"network" default:"" json:"network"`
|
||||
ScreenResolution string `position:"Body" field:"screen_resolution" default:"" json:"screen_resolution"`
|
||||
System string `position:"Body" field:"system" default:"" json:"system"`
|
||||
Electric string `position:"Body" field:"electric" default:"" json:"electric"`
|
||||
ProcessorModel string `position:"Body" field:"processor_model" default:"" json:"processor_model"`
|
||||
BaseBand string `position:"Body" field:"baseband" default:"" json:"baseband"`
|
||||
Model string `position:"Body" field:"model" default:"" json:"model"`
|
||||
Battery string `position:"Body" field:"battery" default:"" json:"battery"`
|
||||
Package string `position:"Body" field:"package" default:"" json:"package"`
|
||||
LongId string `position:"Body" field:"long_id" default:"" json:"long_id"`
|
||||
Imei string `position:"Body" field:"imei" default:"" json:"imei"`
|
||||
Oaid string `position:"Body" field:"oaid" default:"" json:"oaid"`
|
||||
Idfa string `position:"Body" field:"idfa" default:"" json:"idfa"`
|
||||
Idfv string `position:"Body" field:"idfv" default:"" json:"idfv"`
|
||||
AdDevice string `position:"Body" field:"ad_device" default:"" json:"ad_device"`
|
||||
Os string `position:"Body" field:"os" default:"" json:"os"`
|
||||
IP string `position:"Body" field:"ip" default:"" json:"ip"`
|
||||
Ua string `position:"Body" field:"ua" default:"" json:"ua"`
|
||||
WxPlatform string `position:"Body" field:"wx_platform" default:"" json:"wx_platform"`
|
||||
Adinfo string `position:"Body" field:"adinfo" default:"" json:"adinfo"`
|
||||
}
|
||||
|
||||
type UserRegParam struct {
|
||||
DeviceInfo
|
||||
ChannelId int64 `position:"Body" field:"mtype" default:"1" json:"mtype"`
|
||||
GameId int64 `position:"Body" field:"game_id" default:"0" json:"game_id"`
|
||||
LoginGameId int64 `position:"Body" field:"login_game_id" default:"0" json:"login_game_id"`
|
||||
GameSign string `position:"Body" field:"game_sign" default:"" json:"game_sign"`
|
||||
Uid int64 `position:"Body" field:"uid" default:"0" json:"uid"`
|
||||
UserName string `position:"Body" field:"user_name" default:"" json:"user_name"`
|
||||
Openid string `position:"Body" field:"openid" default:"" json:"openid"`
|
||||
Phone string `position:"Body" field:"mobile_phone" default:"" json:"mobile_phone"`
|
||||
ComeBackUser int64 `position:"Body" field:"come_back_user" default:"0" json:"come_back_user"`
|
||||
RegTime int64 `position:"Body" field:"reg_time" default:"" json:"reg_time"`
|
||||
Logined int64 `position:"Body" field:"logined" default:"1" json:"logined"`
|
||||
RegType int64 `position:"Body" field:"reg_type" default:"" json:"reg_type"`
|
||||
LpReg int64 `position:"Body" field:"lp_reg" default:"0" json:"lp_reg"`
|
||||
MatchType int64 `position:"Body" field:"match_type" default:"0" json:"match_type"`
|
||||
AgentId int64 `position:"Body" field:"agent_id" default:"100" json:"agent_id"`
|
||||
SiteId int64 `position:"Body" field:"site_id" default:"1001" json:"site_id"`
|
||||
PkgAgentId int64 `position:"Body" field:"pkg_agent_id" default:"0" json:"pkg_agent_id"`
|
||||
PkgSiteId int64 `position:"Body" field:"pkg_site_id" default:"0" json:"pkg_site_id"`
|
||||
FromAd int64 `position:"Body" field:"from_ad" default:"0" json:"from_ad"`
|
||||
FanCode string `position:"Body" field:"fan_code" default:"" json:"fan_code"`
|
||||
InvalidUuid int64 `position:"Body" field:"invalid_uuid" default:"0" json:"invalid_uuid"`
|
||||
}
|
||||
|
||||
type UserRegRequest struct {
|
||||
*requests.RpcRequest
|
||||
DeviceInfo
|
||||
ChannelId int64 `position:"Body" field:"mtype" default:"1"`
|
||||
GameId int64 `position:"Body" field:"game_id" default:"0"`
|
||||
LoginGameId int64 `position:"Body" field:"login_game_id" default:"0"`
|
||||
GameSign string `position:"Body" field:"game_sign" default:""`
|
||||
Uid int64 `position:"Body" field:"uid" default:"0"`
|
||||
UserName string `position:"Body" field:"user_name" default:""`
|
||||
Openid int64 `position:"Body" field:"openid" default:"0"`
|
||||
ComeBackUser int64 `position:"Body" field:"come_back_user" default:"0"`
|
||||
RegTime int64 `position:"Body" field:"reg_time" default:""`
|
||||
Logined int64 `position:"Body" field:"logined" default:"1"`
|
||||
RegType int64 `position:"Body" field:"reg_type" default:""`
|
||||
LpReg int64 `position:"Body" field:"lp_reg" default:"0"`
|
||||
MatchType int64 `position:"Body" field:"match_type" default:"0"`
|
||||
AgentId int64 `position:"Body" field:"agent_id" default:"100"`
|
||||
SiteId int64 `position:"Body" field:"site_id" default:"1001"`
|
||||
PkgAgentId int64 `position:"Body" field:"pkg_agent_id" default:"0"`
|
||||
PkgSiteId int64 `position:"Body" field:"pkg_site_id" default:"0"`
|
||||
FromAd int64 `position:"Body" field:"from_ad" default:"0"`
|
||||
FanCode string `position:"Body" field:"fan_code" default:""`
|
||||
InvalidUuid int64 `position:"Body" field:"invalid_uuid" default:"0"`
|
||||
UserRegParam
|
||||
}
|
||||
|
||||
type UserRegResponse struct {
|
||||
@ -172,35 +177,40 @@ type UserRegResponse struct {
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
func CreateUserRegRequest() *UserRegRequest {
|
||||
func CreateUserRegRequest(param *UserRegParam) *UserRegRequest {
|
||||
req := &UserRegRequest{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
UserRegParam: *param,
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/user/reg")
|
||||
req.Method = requests.POST
|
||||
return req
|
||||
}
|
||||
|
||||
type UserLoginParam struct {
|
||||
DeviceInfo
|
||||
ChannelId int64 `position:"Body" field:"mtype" default:"0" json:"mtype"`
|
||||
GameId int64 `position:"Body" field:"game_id" default:"0" json:"game_id"`
|
||||
GameSign string `position:"Body" field:"game_sign" default:"" json:"game_sign"`
|
||||
Version string `position:"Body" field:"version" default:"" json:"version"`
|
||||
UserName string `position:"Body" field:"user_name" default:"" json:"user_name"`
|
||||
Uid int64 `position:"Body" field:"uid" default:"0" json:"uid"`
|
||||
RegTime int64 `position:"Body" field:"reg_time" default:"0" json:"reg_time"`
|
||||
LoginTime int64 `position:"Body" field:"login_time" default:"0" json:"login_time"`
|
||||
LoginAgentId int64 `position:"Body" field:"login_agent_id" default:"0" json:"login_agent_id"`
|
||||
LoginSiteId int64 `position:"Body" field:"login_site_id" default:"0" json:"login_site_id"`
|
||||
PkgAgentId int64 `position:"Body" field:"pkg_agent_id" default:"0" json:"pkg_agent_id"`
|
||||
PkgSiteId int64 `position:"Body" field:"pkg_site_id" default:"0" json:"pkg_site_id"`
|
||||
FromAd int64 `position:"Body" field:"from_ad" default:"0" json:"from_ad"`
|
||||
CpData string `position:"Body" field:"cp_data" default:"" json:"cp_data"`
|
||||
OriginalImei string `position:"Body" field:"originalimei" default:"" json:"originalimei"`
|
||||
InvalidUuid int64 `position:"Body" field:"invalid_uuid" default:"0" json:"invalid_uuid"`
|
||||
ServerId int64 `position:"Body" field:"server_id" default:"1" json:"server_id"`
|
||||
}
|
||||
|
||||
type UserLoginRequest struct {
|
||||
*requests.RpcRequest
|
||||
DeviceInfo
|
||||
ChannelId int64 `position:"Body" field:"mtype" default:"0"`
|
||||
GameId int64 `position:"Body" field:"game_id" default:"0"`
|
||||
GameSign string `position:"Body" field:"game_sign" default:""`
|
||||
Version string `position:"Body" field:"version" default:""`
|
||||
UserName string `position:"Body" field:"user_name" default:""`
|
||||
Uid int64 `position:"Body" field:"uid" default:"0"`
|
||||
RegTime int64 `position:"Body" field:"reg_time" default:"0"`
|
||||
LoginTime int64 `position:"Body" field:"login_time" default:"0"`
|
||||
LoginAgentId int64 `position:"Body" field:"login_agent_id" default:"0"`
|
||||
LoginSiteId int64 `position:"Body" field:"login_site_id" default:"0"`
|
||||
PkgAgentId int64 `position:"Body" field:"pkg_agent_id" default:"0"`
|
||||
PkgSiteId int64 `position:"Body" field:"pkg_site_id" default:"0"`
|
||||
FromAd int64 `position:"Body" field:"from_ad" default:"0"`
|
||||
CpData string `position:"Body" field:"cp_data" default:""`
|
||||
OriginalImei string `position:"Body" field:"originalimei" default:""`
|
||||
InvalidUuid int64 `position:"Body" field:"invalid_uuid" default:"0"`
|
||||
ServerId int64 `position:"Body" field:"server_id" default:"1"`
|
||||
UserLoginParam
|
||||
}
|
||||
|
||||
type UserLoginResponse struct {
|
||||
@ -212,9 +222,10 @@ type UserLoginResponse struct {
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
func CreateUserLoginRequest() *UserLoginRequest {
|
||||
func CreateUserLoginRequest(param *UserLoginParam) *UserLoginRequest {
|
||||
req := &UserLoginRequest{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
UserLoginParam: *param,
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/user/login")
|
||||
req.Method = requests.POST
|
||||
|
||||
Loading…
Reference in New Issue
Block a user