查询玩家的英雄、背包

This commit is contained in:
yangduo 2024-06-28 11:22:18 +08:00
parent 284bad91b8
commit 177a6d35c9
6 changed files with 309 additions and 14 deletions

View File

@ -97,6 +97,7 @@ exports.Player = class {
constructor()
{
this.fields = [
['idx',0,''],
['account_id', '', '用户id'],
['channel', '', '渠道id'],
['name', '', '用户名'],
@ -122,8 +123,8 @@ exports.Player = class {
['already_guide', 0, '已引导'],
['pve_instance_id', 0, '已过pve副本id'],
['like_count', 0, '被点赞次数'],
['head_list', '', '拥有的头像列表'],
['head_frame_list', '', '拥有的头像框列表'],
['head_list', [], '拥有的头像列表'],
['head_frame_list', [], '拥有的头像框列表'],
['consume_gold', 0, '消费金币数'],
['score_modifytime', 0, '积分修改时间'],
['best_rank_modifytime', 0, 'bestrank修改时间'],
@ -140,3 +141,66 @@ exports.Player = class {
]
}
}
exports.BagItem = class {
constructor()
{
this.fields = [
['idx', 0, ''],
['token_id', '', 'token_id'],
['account_id', '', '用户id'],
['item_id', 0, '物品id'],
['item_num', 0, '物品数量'],
['rand_attr', '', '随机属性'],
['today_get_gold', 0, '今日获得金币'],
['last_get_gold_time', 0, '最后获得金币时间'],
['createtime', 0, '创建时间'],
['modifiedtime', 0, '修改时间'],
['is_old', 0, '0:展示红点 1:不用展示'],
]
}
}
exports.Hero = class {
constructor()
{
this.fields = [
['idx', 0, ''],
['token_id', '', 'token_id'],
['account_id', '', '用户id'],
['hero_id', 0, '英雄id'],
['hero_tili', '', '英雄体力'],
['state', 0, '0已购买 1体验中'],
['skin_id', 0, '皮肤id'],
['hero_lv', 0, '英雄等级'],
['quality', 0, '品阶'],
['skill_lv1', 0, '必杀技等级'],
['skill_lv2', 0, '躲避技能等级'],
['try_count', 0, '剩余体验次数 当state=1时才有意义'],
['advanced_count', 0, '进阶次数'],
['lock_type', 0, '0:无锁 1:升级 2:升阶 3:悬赏'],
['unlock_time', 0, '解锁时间'],
['unlock_trade_time', 0, '出售解锁时间'],
['rand_attr', '', '随机属性'],
['today_pve_get_ceg', 0, '今日获得金币'],
['last_pve_get_ceg_time', 0, '最后获得金币时间'],
['today_mission_get_ceg', 0, '悬赏任务获得金币'],
['last_mission_get_ceg_time', 0, '最后获得悬赏任务金币时间'],
['createtime', 0, '创建时间'],
['modifytime', 0, '修改时间'],
['chip_ids', '', '已镶嵌的芯片idx组'],
['skill_common', '', '通用技能'],
['skill_points', 0, '技能点'],
['labour', 0, '劳力值'],
['active_token_id', '', 'active_token_id'],
['active_count', 0, 'active_count'],
['active', 0, '是否激活 1已初始激活'],
['wealth_attr', 0, '财富值属性'],
['active_time', 0, '激活时间'],
['seal_type', 0, '0:未封存 1已封存'],
['unseal_time', 0, '解封时间'],
['is_old', 0, '0:展示红点 1:不用展示'],
['on_chain_time', 0, '上链时间'],
]
}
}

View File

@ -27,9 +27,51 @@ module.exports = class {
new common.RspHead(),
['!data', common.Player()]
]
}
},
{
'method': 'POST',
'name': 'bagquery',
'desc': '获取玩家背包信息',
'group': 'player',
'url': 'api/v1/player/bagquery',
'header': [
],
'is_json_params': true,
'params': [
['account_id', '', '账号id'],
],
'uri_params': [
['cursor', '', '游标'],
['page_size', '', '每页数量'],
],
'response': [
new common.RspHead(),
['!data', common.BagItem()]
]
},
{
'method': 'POST',
'name': 'heroesquery',
'desc': '获取玩家英雄信息',
'group': 'player',
'url': 'api/v1/player/heroesquery',
'header': [
],
'is_json_params': true,
'params': [
['account_id', '', '账号id'],
],
'uri_params': [
['cursor', '', '游标'],
['page_size', '', '每页数量'],
],
'response': [
new common.RspHead(),
['!data', common.he()]
]
}
];
}
// ...
}
}

View File

@ -25,11 +25,7 @@ func (this *PlayerApi) Info(c *gin.Context) {
}
reqJson := InfoForm{}
if err := c.ShouldBindJSON(&reqJson); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": err.Error(),
})
if !this.checkparam(&reqJson, c) {
return
}
@ -56,13 +52,75 @@ func (this *PlayerApi) Info(c *gin.Context) {
}
sql := fmt.Sprintf(`SELECT * FROM t_user WHERE idx > %d AND %s `, cursor, filterstr)
this.query(cursor, sql, c, func(ds *f5.DataSet) interface{} {
var p system.Player
p.LoadFromDs(ds)
return p
})
}
func (this *PlayerApi) BagQuery(c *gin.Context) {
type BagQueryForm struct {
Account_id string `binding:"required" json:"account_id"`
}
reqJson := BagQueryForm{}
if !this.checkparam(&reqJson, c) {
return
}
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
filterstr := " account_id = '" + reqJson.Account_id + "' "
sql := fmt.Sprintf(`SELECT * FROM t_bag WHERE idx > %d AND %s `, cursor, filterstr)
this.query(cursor, sql, c, func(ds *f5.DataSet) interface{} {
var p system.BagItem
p.LoadFromDs(ds)
return p
})
}
func (this *PlayerApi) HeroesQuery(c *gin.Context) {
type HeroesQueryForm struct {
Account_id string `binding:"required" json:"account_id"`
}
reqJson := HeroesQueryForm{}
if !this.checkparam(&reqJson, c) {
return
}
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
filterstr := " account_id = '" + reqJson.Account_id + "' "
sql := fmt.Sprintf(`SELECT * FROM t_hero WHERE idx > %d AND %s `, cursor, filterstr)
this.query(cursor, sql, c, func(ds *f5.DataSet) interface{} {
var p system.Hero
p.LoadFromDs(ds)
return p
})
}
func (this *PlayerApi) checkparam(obj any, c *gin.Context) bool {
if err := c.ShouldBindJSON(obj); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": err.Error(),
})
return false
}
return true
}
func (this *PlayerApi) query(cursor int64, sql string, c *gin.Context, loadcall func(ds *f5.DataSet) interface{}) {
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
Page common.StreamPagination `json:"page"`
Rows []system.Player `json:"rows"`
Rows []interface{} `json:"rows"`
}{
Rows: []system.Player{},
Rows: []interface{}{},
}
pageSize := q5.AdjustRangeValue(q5.ToInt32(c.DefaultQuery("page_size", "")), 1, 20)
@ -84,9 +142,7 @@ func (this *PlayerApi) Info(c *gin.Context) {
rspObj.Page.FillPage(pagination)
},
func(ds *f5.DataSet) {
p := new(system.Player)
p.LoadFromDs(ds)
rspObj.Rows = append(rspObj.Rows, *p)
rspObj.Rows = append(rspObj.Rows, loadcall(ds))
})
c.JSON(200, rspObj)

View File

@ -0,0 +1,39 @@
package system
import (
"f5"
"q5"
)
// 背包物品
type BagItem struct {
Idx int64 `json:"idx"`
Token_id string `gorm:"uniqueIndex;comment:token_id" json:"token_id"`
Account_id string `gorm:"uniqueIndex;comment:用户id" json:"account_id"`
Item_id int `gorm:"comment:物品id" json:"item_id"`
Item_num int `gorm:"comment:物品数量" json:"item_num"`
Rand_attr string `gorm:"comment:随机属性" json:"rand_attr"`
Today_get_gold int64 `gorm:"comment:今日获得金币" json:"today_get_gold"`
Last_get_gold_time int `gorm:"comment:最后获得金币时间" json:"last_get_gold_time"`
Createtime int `gorm:"comment:创建时间" json:"createtime"`
Modifiedtime int `gorm:"comment:修改时间" json:"modifiedtime"`
Is_old int `gorm:"comment:0:展示红点 1:不用展示" json:"is_old"`
}
func (this *BagItem) TableName() string {
return "t_bag"
}
func (this *BagItem) LoadFromDs(ds *f5.DataSet) {
this.Idx = q5.ToInt64(ds.GetByName("idx"))
this.Token_id = ds.GetByName("token_id")
this.Account_id = ds.GetByName("account_id")
this.Item_id = q5.ToInt(ds.GetByName("item_id"))
this.Item_num = q5.ToInt(ds.GetByName("item_num"))
this.Rand_attr = ds.GetByName("rand_attr")
this.Today_get_gold = q5.ToInt64(ds.GetByName("today_get_gold"))
this.Last_get_gold_time = q5.ToInt(ds.GetByName("last_get_gold_time"))
this.Createtime = q5.ToInt(ds.GetByName("createtime"))
this.Modifiedtime = q5.ToInt(ds.GetByName("modifiedtime"))
this.Is_old = q5.ToInt(ds.GetByName("is_old"))
}

View File

@ -0,0 +1,92 @@
package system
import (
"f5"
"q5"
)
type Hero struct {
Idx int64 `json:"idx"`
Token_id string `gorm:"uniqueIndex;comment:token_id" json:"token_id"`
Account_id string `gorm:"uniqueIndex;comment:用户id" json:"account_id"`
Hero_id int `gorm:"comment:英雄id" json:"hero_id"`
Hero_tili string `gorm:"comment:英雄体力" json:"hero_tili"`
State int `gorm:"comment:0已购买 1体验中" json:"state"`
Skin_id int `gorm:"comment:皮肤id" json:"skin_id"`
Hero_lv int `gorm:"comment:英雄等级" json:"hero_lv"`
Quality int `gorm:"comment:品阶" json:"quality"`
Skill_lv1 int `gorm:"comment:必杀技等级" json:"skill_lv1"`
Skill_lv2 int `gorm:"comment:躲避技能等级" json:"skill_lv2"`
Try_count int `gorm:"comment:剩余体验次数 当state=1时才有意义" json:"try_count"`
Advanced_count int `gorm:"comment:进阶次数" json:"advanced_count"`
Lock_type int `gorm:"comment:0:无锁 1:升级 2:升阶 3:悬赏" json:"lock_type"`
Unlock_time int `gorm:"comment:解锁时间" json:"unlock_time"`
Unlock_trade_time int `gorm:"comment:出售解锁时间" json:"unlock_trade_time"`
Rand_attr string `gorm:"comment:随机属性" json:"rand_attr"`
Today_get_gold int64 `gorm:"comment:今日获得金币" json:"today_get_gold"`
Last_get_gold_time int `gorm:"comment:最后获得金币时间" json:"last_get_gold_time"`
Today_pve_get_ceg int64 `gorm:"comment:pve金币" json:"today_pve_get_ceg"`
Last_pve_get_ceg_time int `gorm:"comment:最后获得pve金币时间" json:"last_pve_get_ceg_time"`
Today_mission_get_ceg int `gorm:"comment:悬赏任务获得金币" json:"today_mission_get_ceg"`
Last_mission_get_ceg_time int `gorm:"comment:最后获得悬赏任务金币时间" json:"last_mission_get_ceg_time"`
Createtime int `gorm:"comment:创建时间" json:"createtime"`
Modifytime int `gorm:"comment:修改时间" json:"modifytime"`
Chip_ids string `gorm:"comment:已镶嵌的芯片idx组" json:"chip_ids"`
Skill_common string `gorm:"comment:通用技能" json:"Skill_common"`
Skill_points int `gorm:"comment:技能点" json:"skill_points"`
Labour int `gorm:"comment:劳力值" json:"labour"`
Active_token_id string `gorm:"comment:active_token_id" json:"active_token_id"`
Active_count int `gorm:"comment:active_count" json:"active_count"`
Active int `gorm:"comment:是否激活 1已初始激活" json:"active"`
Wealth_attr string `gorm:"comment:财富值属性" json:"wealth_attr"`
Activate_time int `gorm:"comment:激活时间" json:"activate_time"`
Seal_type int `gorm:"comment:0:未封存 1已封存" json:"seal_type"`
Unseal_time int `gorm:"comment:解封时间" json:"unseal_time"`
Is_old int `gorm:"comment:0:展示红点 1:不用展示" json:"is_old"`
On_chain_time int `gorm:"comment:上链时间" json:"on_chain_time"`
}
func (this *Hero) TableName() string {
return "t_hero"
}
func (this *Hero) LoadFromDs(ds *f5.DataSet) {
this.Idx = q5.ToInt64(ds.GetByName("idx"))
this.Token_id = ds.GetByName("token_id")
this.Account_id = ds.GetByName("account_id")
this.Hero_id = q5.ToInt(ds.GetByName("hero_id"))
this.Hero_tili = ds.GetByName("hero_tili")
this.State = q5.ToInt(ds.GetByName("state"))
this.Skin_id = q5.ToInt(ds.GetByName("skin_id"))
this.Hero_lv = q5.ToInt(ds.GetByName("hero_lv"))
this.Quality = q5.ToInt(ds.GetByName("quality"))
this.Skill_lv1 = q5.ToInt(ds.GetByName("skill_lv1"))
this.Skill_lv2 = q5.ToInt(ds.GetByName("skill_lv2"))
this.Try_count = q5.ToInt(ds.GetByName("try_count"))
this.Advanced_count = q5.ToInt(ds.GetByName("advanced_count"))
this.Lock_type = q5.ToInt(ds.GetByName("lock_type"))
this.Unlock_time = q5.ToInt(ds.GetByName("unlock_time"))
this.Unlock_trade_time = q5.ToInt(ds.GetByName("unlock_trade_time"))
this.Rand_attr = ds.GetByName("rand_attr")
this.Today_get_gold = q5.ToInt64(ds.GetByName("today_get_gold"))
this.Last_get_gold_time = q5.ToInt(ds.GetByName("last_get_gold_time"))
this.Today_pve_get_ceg = q5.ToInt64(ds.GetByName("today_pve_get_ceg"))
this.Last_pve_get_ceg_time = q5.ToInt(ds.GetByName("last_pve_get_ceg_time"))
this.Today_mission_get_ceg = q5.ToInt(ds.GetByName("today_mission_get_ceg"))
this.Last_mission_get_ceg_time = q5.ToInt(ds.GetByName("last_mission_get_ceg_time"))
this.Createtime = q5.ToInt(ds.GetByName("createtime"))
this.Modifytime = q5.ToInt(ds.GetByName("modifytime"))
this.Chip_ids = ds.GetByName("chip_ids")
this.Skill_common = ds.GetByName("skill_common")
this.Skill_points = q5.ToInt(ds.GetByName("skill_points"))
this.Labour = q5.ToInt(ds.GetByName("labour"))
this.Active_token_id = ds.GetByName("active_token_id")
this.Active_count = q5.ToInt(ds.GetByName("active_count"))
this.Active = q5.ToInt(ds.GetByName("active"))
this.Wealth_attr = ds.GetByName("wealth_attr")
this.Activate_time = q5.ToInt(ds.GetByName("activate_time"))
this.Seal_type = q5.ToInt(ds.GetByName("seal_type"))
this.Unseal_time = q5.ToInt(ds.GetByName("unseal_time"))
this.Is_old = q5.ToInt(ds.GetByName("is_old"))
this.On_chain_time = q5.ToInt(ds.GetByName("on_chain_time"))
}

View File

@ -13,5 +13,7 @@ func (this *PlayerRouter) InitPlayerRouter(priRouter *gin.RouterGroup) {
api := v1.ApiGroupApp.SystemApiGroup.PlayerApi
{
group.POST("info", api.Info)
group.POST("bagquery", api.BagQuery)
group.POST("heroesquery", api.HeroesQuery)
}
}