160 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			160 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package userlive
 | 
						||
 | 
						||
import (
 | 
						||
	"encoding/json"
 | 
						||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
 | 
						||
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
 | 
						||
)
 | 
						||
 | 
						||
const (
 | 
						||
	triggerTypeHeartbeat = "heartbeat" // 心跳上报触发
 | 
						||
	triggerTypeLogin     = "login"     // 用户登录、注册
 | 
						||
)
 | 
						||
 | 
						||
// BanReq
 | 
						||
// 上报用户设备信息,判断是否要踢用户下线
 | 
						||
type BanReq struct {
 | 
						||
	*requests.JsonRequest
 | 
						||
}
 | 
						||
 | 
						||
type BanResp struct {
 | 
						||
	*responses.BaseResponse
 | 
						||
	Code int    `json:"code"`
 | 
						||
	Msg  string `json:"msg"`
 | 
						||
	Data struct {
 | 
						||
		Ban       bool  `json:"ban"`         // 是否要禁止
 | 
						||
		BanRuleId int64 `json:"ban_rule_id"` // 命中的封禁规则id
 | 
						||
	} `json:"data"`
 | 
						||
}
 | 
						||
type BanReqParam struct {
 | 
						||
	ActionTime  int64  `json:"action_time"  form:"action_time"`  // 上报时间
 | 
						||
	TriggerType string `json:"trigger_type" form:"trigger_type"` // 触发类型
 | 
						||
	Ip          string `json:"ip" form:"ip"`                     // ip
 | 
						||
	GameId      int64  `json:"game_id" form:"game_id"`           // 游戏id
 | 
						||
	UserName    string `json:"user_name" form:"user_name"`       // 用户名
 | 
						||
	Uid         int64  `json:"uid" form:"uid"`                   // 用户id
 | 
						||
	ServerId    string `json:"server_id" form:"server_id"`       // 区服id
 | 
						||
	RoleId      string `json:"role_id" form:"role_id"`           // 角色id
 | 
						||
	BundleId    string `json:"bundle_id" form:"bundle_id"`       // ios 包名
 | 
						||
	GameName    string `json:"game_name" from:"game_name"`       // 应用名
 | 
						||
	GameVersion string `json:"game_version" from:"game_version"` // 游戏版本
 | 
						||
	SdkVersion  string `json:"sdk_version" from:"sdk_version"`   // sdk版本
 | 
						||
	Os          string `json:"os" from:"os"`                     // 系统
 | 
						||
	OsVersion   string `json:"os_version" from:"os_version"`     // 系统版本
 | 
						||
	InApp       string `json:"in_app" from:"in_app"`             // 壳包系统,壳包传 如:ios、android
 | 
						||
	Ua          string `json:"ua" from:"ua"`                     // ua
 | 
						||
	NetworkType string `json:"network_type" from:"network_type"` // 网络类型
 | 
						||
	IsVirtual   string `json:"is_virtual" from:"is_virtual"`     // 是否是模拟器,字符串0,1,空字符串表示未知
 | 
						||
	Cpu         string `json:"cpu" from:"cpu"`                   // cpu型号
 | 
						||
	DeviceModel string `json:"device_model" from:"device_model"` // 设备型号
 | 
						||
	Baseband    string `json:"baseband" from:"baseband"`         // 基带信息
 | 
						||
	Resolution  string `json:"resolution" from:"resolution"`     // 分辨率
 | 
						||
	Battery     string `json:"battery" from:"battery"`           // 电量
 | 
						||
	LongId      string `json:"long_id" form:"long_id"`           // 逻辑设备号
 | 
						||
	OriginImei  string `json:"origin_imei" form:"origin_imei"`   // imei原值
 | 
						||
	Imei        string `json:"imei" form:"imei"`                 // 老sdk采集的imei
 | 
						||
	OriginOaid  string `json:"origin_oaid" form:"origin_oaid"`   // oaid原值
 | 
						||
	Oaid        string `json:"oaid" form:"oaid"`                 // 老sdk采集的oaid
 | 
						||
	AndroidId   string `json:"android_id" form:"android_id"`     // 安卓id
 | 
						||
	Idfa        string `json:"idfa" form:"idfa"`                 // idfa
 | 
						||
	Idfv        string `json:"idfv" form:"idfv"`                 // idfv
 | 
						||
	DeviceId    string `json:"device_id" form:"device_id"`       // device_id
 | 
						||
}
 | 
						||
 | 
						||
func CreateBanReq(data BanReqParam) *BanReq {
 | 
						||
	req := &BanReq{
 | 
						||
		&requests.JsonRequest{},
 | 
						||
	}
 | 
						||
 | 
						||
	req.InitWithApiInfo(HOST, VERSION, "/api/user_ban/ban")
 | 
						||
	req.Method = requests.POST
 | 
						||
 | 
						||
	marshal, _ := json.Marshal(data)
 | 
						||
	_ = json.Unmarshal(marshal, &req.JsonParams)
 | 
						||
	return req
 | 
						||
}
 | 
						||
 | 
						||
// CreateBanResp 创建同步开服数据响应
 | 
						||
func CreateBanResp() *BanResp {
 | 
						||
	return &BanResp{
 | 
						||
		BaseResponse: &responses.BaseResponse{},
 | 
						||
	}
 | 
						||
}
 | 
						||
 | 
						||
// AddBanRuleCacheReq
 | 
						||
// 添加封禁规则缓存
 | 
						||
type AddBanRuleCacheReq struct {
 | 
						||
	*requests.JsonRequest
 | 
						||
}
 | 
						||
 | 
						||
type AddBanRuleCacheResp struct {
 | 
						||
	*responses.BaseResponse
 | 
						||
	Code int      `json:"code"`
 | 
						||
	Msg  string   `json:"msg"`
 | 
						||
	Data struct{} `json:"data"`
 | 
						||
}
 | 
						||
 | 
						||
type RuleInfo struct {
 | 
						||
	Id        int64  `json:"id"`
 | 
						||
	Phone     string `json:"phone"`
 | 
						||
	UserName  string `json:"user_name"`
 | 
						||
	IdCard    string `json:"id_card"`
 | 
						||
	DeviceId  string `json:"device_id"`
 | 
						||
	LongId    string `json:"long_id"`
 | 
						||
	IsVirtual int64  `json:"is_virtual"`
 | 
						||
	EndTime   string `json:"end_time"`
 | 
						||
}
 | 
						||
 | 
						||
func CreateAddBanRuleCacheReq(data RuleInfo) *AddBanRuleCacheReq {
 | 
						||
	req := &AddBanRuleCacheReq{
 | 
						||
		&requests.JsonRequest{},
 | 
						||
	}
 | 
						||
	req.InitWithApiInfo(HOST, VERSION, "/api/user_ban/add_cache")
 | 
						||
	req.Method = requests.POST
 | 
						||
 | 
						||
	marshal, _ := json.Marshal(data)
 | 
						||
	_ = json.Unmarshal(marshal, &req.JsonParams)
 | 
						||
	return req
 | 
						||
}
 | 
						||
 | 
						||
func CreateAddBanRuleCacheResp() *AddBanRuleCacheResp {
 | 
						||
	return &AddBanRuleCacheResp{
 | 
						||
		BaseResponse: &responses.BaseResponse{},
 | 
						||
	}
 | 
						||
}
 | 
						||
 | 
						||
// RemoveBanRuleCacheReq
 | 
						||
// 删除封禁规则缓存
 | 
						||
type RemoveBanRuleCacheReq struct {
 | 
						||
	*requests.JsonRequest
 | 
						||
}
 | 
						||
 | 
						||
type RemoveBanRuleCacheReqParam struct {
 | 
						||
	Rules []RuleInfo `json:"rules"`
 | 
						||
}
 | 
						||
 | 
						||
type RemoveBanRuleCacheResp struct {
 | 
						||
	*responses.BaseResponse
 | 
						||
	Code int      `json:"code"`
 | 
						||
	Msg  string   `json:"msg"`
 | 
						||
	Data struct{} `json:"data"`
 | 
						||
}
 | 
						||
 | 
						||
func CreateRemoveBanRuleCacheReq(param RemoveBanRuleCacheReqParam) *RemoveBanRuleCacheReq {
 | 
						||
	req := &RemoveBanRuleCacheReq{
 | 
						||
		&requests.JsonRequest{},
 | 
						||
	}
 | 
						||
	req.InitWithApiInfo(HOST, VERSION, "/api/user_ban/remove_cache")
 | 
						||
	req.Method = requests.POST
 | 
						||
 | 
						||
	marshal, _ := json.Marshal(param)
 | 
						||
	_ = json.Unmarshal(marshal, &req.JsonParams)
 | 
						||
	return req
 | 
						||
}
 | 
						||
 | 
						||
func CreateRemoveBanRuleCacheResp() *RemoveBanRuleCacheResp {
 | 
						||
	return &RemoveBanRuleCacheResp{
 | 
						||
		BaseResponse: &responses.BaseResponse{},
 | 
						||
	}
 | 
						||
}
 |