From 227e1bad17f3b6ba4e1bc65c2e60e0a7995c9cba Mon Sep 17 00:00:00 2001 From: yangduo Date: Thu, 4 Jul 2024 14:50:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/admin/common.js | 12 +++++++- doc/admin/nft.js | 35 +++++++++++++--------- doc/admin/player.js | 5 +++- server/adminserver/api/v1/system/common.go | 12 ++++---- server/adminserver/api/v1/system/nft.go | 10 +++---- server/adminserver/api/v1/system/player.go | 6 ++-- server/adminserver/model/system/bagitem.go | 4 +-- 7 files changed, 53 insertions(+), 31 deletions(-) diff --git a/doc/admin/common.js b/doc/admin/common.js index 2cd9588e..d927c8fa 100644 --- a/doc/admin/common.js +++ b/doc/admin/common.js @@ -30,6 +30,16 @@ exports.RspHead = class RspHead { }; +exports.StreamPagination = class StreamPagination { + constructor() { + this.fields = [ + ['next_cursor', '', '下一页游标'], + ['previous_cursor', '', '上一页游标'], + ['remaining', 0, '剩余条数'], + ]; + } +}; + exports.Attachment = class { constructor() { @@ -155,7 +165,7 @@ exports.BagItem = class { ['today_get_gold', 0, '今日获得金币'], ['last_get_gold_time', 0, '最后获得金币时间'], ['createtime', 0, '创建时间'], - ['modifiedtime', 0, '修改时间'], + ['modifytime', 0, '修改时间'], ['is_old', 0, '0:展示红点 1:不用展示'], ] } diff --git a/doc/admin/nft.js b/doc/admin/nft.js index 1e5e3de1..fac7524b 100644 --- a/doc/admin/nft.js +++ b/doc/admin/nft.js @@ -14,9 +14,9 @@ module.exports = class { ], 'is_json_params': true, 'params': [ - ['name', '', '用户名字'], - ['account_id', '', '账号id'], - ['address', '', '钱包地址'], + ['order_id', '', '订单id'], + ['contract_address', '', '合约地址'], + ['token_id', '', 'token_id'], ], 'uri_params': [ ['cursor', '', '游标'], @@ -24,20 +24,23 @@ module.exports = class { ], 'response': [ new common.RspHead(), - ['!data', common.Player()] + new common.StreamPagination(), + ['!data', common.Order()] ] }, { 'method': 'POST', - 'name': 'bagquery', - 'desc': '获取玩家背包信息', + 'name': 'salequery', + 'desc': '获取售卖信息', 'group': 'nft', - 'url': 'api/v1/nft/bagquery', + 'url': 'api/v1/nft/salequery', 'header': [ ], 'is_json_params': true, 'params': [ - ['account_id', '', '账号id'], + ['order_id', '', '订单id'], + ['buyer', '', '买家'], + ['seller', '', '卖家'], ], 'uri_params': [ ['cursor', '', '游标'], @@ -45,20 +48,23 @@ module.exports = class { ], 'response': [ new common.RspHead(), - ['!data', common.BagItem()] + new common.StreamPagination(), + ['!data', common.Sale()] ] }, { 'method': 'POST', - 'name': 'heroesquery', - 'desc': '获取玩家英雄信息', + 'name': 'nftquery', + 'desc': '获取NFT信息', 'group': 'nft', - 'url': 'api/v1/nft/heroesquery', + 'url': 'api/v1/nft/nftquery', 'header': [ ], 'is_json_params': true, 'params': [ - ['account_id', '', '账号id'], + ['owner_address', '', '所有者'], + ['last_owner_address', '', '上一个所有者'], + ['net_id', '', 'net_id'], ], 'uri_params': [ ['cursor', '', '游标'], @@ -66,7 +72,8 @@ module.exports = class { ], 'response': [ new common.RspHead(), - ['!data', common.he()] + new common.StreamPagination(), + ['!data', common.NFT()] ] } ]; diff --git a/doc/admin/player.js b/doc/admin/player.js index 264750bd..6bdba1e7 100644 --- a/doc/admin/player.js +++ b/doc/admin/player.js @@ -25,6 +25,7 @@ module.exports = class { ], 'response': [ new common.RspHead(), + new common.StreamPagination(), ['!data', common.Player()] ] }, @@ -46,6 +47,7 @@ module.exports = class { ], 'response': [ new common.RspHead(), + new common.StreamPagination(), ['!data', common.BagItem()] ] }, @@ -67,7 +69,8 @@ module.exports = class { ], 'response': [ new common.RspHead(), - ['!data', common.he()] + new common.StreamPagination(), + ['!data', common.Hero()] ] } ]; diff --git a/server/adminserver/api/v1/system/common.go b/server/adminserver/api/v1/system/common.go index 4ffaaed3..e28437f6 100644 --- a/server/adminserver/api/v1/system/common.go +++ b/server/adminserver/api/v1/system/common.go @@ -23,12 +23,14 @@ func checkparam(obj any, c *gin.Context) bool { func query(dbname string, cursor int64, sql string, c *gin.Context, loadcall func(ds *f5.DataSet) interface{}) { rspObj := struct { - ErrCode int32 `json:"errcode"` - ErrMsg string `json:"errmsg"` + Code int32 `json:"code"` + Message string `json:"message"` Page common.StreamPagination `json:"page"` - Rows []interface{} `json:"rows"` + Data []interface{} `json:"data"` }{ - Rows: []interface{}{}, + Code: 0, + Message: "success", + Data: []interface{}{}, } pageSize := q5.AdjustRangeValue(q5.ToInt32(c.DefaultQuery("page_size", "")), 1, 20) @@ -50,7 +52,7 @@ func query(dbname string, cursor int64, sql string, c *gin.Context, loadcall fun rspObj.Page.FillPage(pagination) }, func(ds *f5.DataSet) { - rspObj.Rows = append(rspObj.Rows, loadcall(ds)) + rspObj.Data = append(rspObj.Data, loadcall(ds)) }) c.JSON(200, rspObj) diff --git a/server/adminserver/api/v1/system/nft.go b/server/adminserver/api/v1/system/nft.go index de21c23c..a3ec2282 100644 --- a/server/adminserver/api/v1/system/nft.go +++ b/server/adminserver/api/v1/system/nft.go @@ -46,7 +46,7 @@ func (this *NFTApi) OrderQuery(c *gin.Context) { sql := fmt.Sprintf(`SELECT * FROM t_order WHERE idx > %d AND %s `, cursor, filterstr) query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} { - var p system.Order + p := new(system.Order) p.LoadFromDs(ds) return p }) @@ -83,20 +83,20 @@ func (this *NFTApi) SaleQuery(c *gin.Context) { sql := fmt.Sprintf(`SELECT * FROM t_sale WHERE idx > %d AND %s `, cursor, filterstr) query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} { - var p system.Sale + p := new(system.Sale) p.LoadFromDs(ds) return p }) } func (this *NFTApi) NFTQuery(c *gin.Context) { - type HeroesQueryForm struct { + type NFTQueryForm struct { Owner_address string `json:"owner_address"` Last_owner_address string `json:"last_owner_address"` Net_id int64 `json:"net_id"` } - reqJson := HeroesQueryForm{} + reqJson := NFTQueryForm{} if !checkparam(&reqJson, c) { return } @@ -120,7 +120,7 @@ func (this *NFTApi) NFTQuery(c *gin.Context) { sql := fmt.Sprintf(`SELECT * FROM t_nft WHERE idx > %d AND %s `, cursor, filterstr) query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} { - var p system.NFT + p := new(system.NFT) p.LoadFromDs(ds) return p }) diff --git a/server/adminserver/api/v1/system/player.go b/server/adminserver/api/v1/system/player.go index 56528866..4b46da7e 100644 --- a/server/adminserver/api/v1/system/player.go +++ b/server/adminserver/api/v1/system/player.go @@ -51,7 +51,7 @@ func (this *PlayerApi) Info(c *gin.Context) { sql := fmt.Sprintf(`SELECT * FROM t_user WHERE idx > %d AND %s `, cursor, filterstr) query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} { - var p system.Player + p := new(system.Player) p.LoadFromDs(ds) return p }) @@ -72,7 +72,7 @@ func (this *PlayerApi) BagQuery(c *gin.Context) { sql := fmt.Sprintf(`SELECT * FROM t_bag WHERE idx > %d AND %s `, cursor, filterstr) query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} { - var p system.BagItem + p := new(system.BagItem) p.LoadFromDs(ds) return p }) @@ -93,7 +93,7 @@ func (this *PlayerApi) HeroesQuery(c *gin.Context) { sql := fmt.Sprintf(`SELECT * FROM t_hero WHERE idx > %d AND %s `, cursor, filterstr) query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} { - var p system.Hero + p := new(system.Hero) p.LoadFromDs(ds) return p }) diff --git a/server/adminserver/model/system/bagitem.go b/server/adminserver/model/system/bagitem.go index 73ee4267..ee44e02e 100644 --- a/server/adminserver/model/system/bagitem.go +++ b/server/adminserver/model/system/bagitem.go @@ -16,7 +16,7 @@ type BagItem struct { 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"` + Modifytime int `gorm:"comment:修改时间" json:"modifytime"` Is_old int `gorm:"comment:0:展示红点 1:不用展示" json:"is_old"` } @@ -34,6 +34,6 @@ func (this *BagItem) LoadFromDs(ds *f5.DataSet) { 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.Modifytime = q5.ToInt(ds.GetByName("modifytime")) this.Is_old = q5.ToInt(ds.GetByName("is_old")) }