修改查询
This commit is contained in:
parent
b9066d9939
commit
227e1bad17
@ -30,6 +30,16 @@ exports.RspHead = class RspHead {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.StreamPagination = class StreamPagination {
|
||||||
|
constructor() {
|
||||||
|
this.fields = [
|
||||||
|
['next_cursor', '', '下一页游标'],
|
||||||
|
['previous_cursor', '', '上一页游标'],
|
||||||
|
['remaining', 0, '剩余条数'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
exports.Attachment = class {
|
exports.Attachment = class {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -155,7 +165,7 @@ exports.BagItem = class {
|
|||||||
['today_get_gold', 0, '今日获得金币'],
|
['today_get_gold', 0, '今日获得金币'],
|
||||||
['last_get_gold_time', 0, '最后获得金币时间'],
|
['last_get_gold_time', 0, '最后获得金币时间'],
|
||||||
['createtime', 0, '创建时间'],
|
['createtime', 0, '创建时间'],
|
||||||
['modifiedtime', 0, '修改时间'],
|
['modifytime', 0, '修改时间'],
|
||||||
['is_old', 0, '0:展示红点 1:不用展示'],
|
['is_old', 0, '0:展示红点 1:不用展示'],
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ module.exports = class {
|
|||||||
],
|
],
|
||||||
'is_json_params': true,
|
'is_json_params': true,
|
||||||
'params': [
|
'params': [
|
||||||
['name', '', '用户名字'],
|
['order_id', '', '订单id'],
|
||||||
['account_id', '', '账号id'],
|
['contract_address', '', '合约地址'],
|
||||||
['address', '', '钱包地址'],
|
['token_id', '', 'token_id'],
|
||||||
],
|
],
|
||||||
'uri_params': [
|
'uri_params': [
|
||||||
['cursor', '', '游标'],
|
['cursor', '', '游标'],
|
||||||
@ -24,20 +24,23 @@ module.exports = class {
|
|||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
new common.RspHead(),
|
new common.RspHead(),
|
||||||
['!data', common.Player()]
|
new common.StreamPagination(),
|
||||||
|
['!data', common.Order()]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'method': 'POST',
|
'method': 'POST',
|
||||||
'name': 'bagquery',
|
'name': 'salequery',
|
||||||
'desc': '获取玩家背包信息',
|
'desc': '获取售卖信息',
|
||||||
'group': 'nft',
|
'group': 'nft',
|
||||||
'url': 'api/v1/nft/bagquery',
|
'url': 'api/v1/nft/salequery',
|
||||||
'header': [
|
'header': [
|
||||||
],
|
],
|
||||||
'is_json_params': true,
|
'is_json_params': true,
|
||||||
'params': [
|
'params': [
|
||||||
['account_id', '', '账号id'],
|
['order_id', '', '订单id'],
|
||||||
|
['buyer', '', '买家'],
|
||||||
|
['seller', '', '卖家'],
|
||||||
],
|
],
|
||||||
'uri_params': [
|
'uri_params': [
|
||||||
['cursor', '', '游标'],
|
['cursor', '', '游标'],
|
||||||
@ -45,20 +48,23 @@ module.exports = class {
|
|||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
new common.RspHead(),
|
new common.RspHead(),
|
||||||
['!data', common.BagItem()]
|
new common.StreamPagination(),
|
||||||
|
['!data', common.Sale()]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'method': 'POST',
|
'method': 'POST',
|
||||||
'name': 'heroesquery',
|
'name': 'nftquery',
|
||||||
'desc': '获取玩家英雄信息',
|
'desc': '获取NFT信息',
|
||||||
'group': 'nft',
|
'group': 'nft',
|
||||||
'url': 'api/v1/nft/heroesquery',
|
'url': 'api/v1/nft/nftquery',
|
||||||
'header': [
|
'header': [
|
||||||
],
|
],
|
||||||
'is_json_params': true,
|
'is_json_params': true,
|
||||||
'params': [
|
'params': [
|
||||||
['account_id', '', '账号id'],
|
['owner_address', '', '所有者'],
|
||||||
|
['last_owner_address', '', '上一个所有者'],
|
||||||
|
['net_id', '', 'net_id'],
|
||||||
],
|
],
|
||||||
'uri_params': [
|
'uri_params': [
|
||||||
['cursor', '', '游标'],
|
['cursor', '', '游标'],
|
||||||
@ -66,7 +72,8 @@ module.exports = class {
|
|||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
new common.RspHead(),
|
new common.RspHead(),
|
||||||
['!data', common.he()]
|
new common.StreamPagination(),
|
||||||
|
['!data', common.NFT()]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -25,6 +25,7 @@ module.exports = class {
|
|||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
new common.RspHead(),
|
new common.RspHead(),
|
||||||
|
new common.StreamPagination(),
|
||||||
['!data', common.Player()]
|
['!data', common.Player()]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -46,6 +47,7 @@ module.exports = class {
|
|||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
new common.RspHead(),
|
new common.RspHead(),
|
||||||
|
new common.StreamPagination(),
|
||||||
['!data', common.BagItem()]
|
['!data', common.BagItem()]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -67,7 +69,8 @@ module.exports = class {
|
|||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
new common.RspHead(),
|
new common.RspHead(),
|
||||||
['!data', common.he()]
|
new common.StreamPagination(),
|
||||||
|
['!data', common.Hero()]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -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{}) {
|
func query(dbname string, cursor int64, sql string, c *gin.Context, loadcall func(ds *f5.DataSet) interface{}) {
|
||||||
rspObj := struct {
|
rspObj := struct {
|
||||||
ErrCode int32 `json:"errcode"`
|
Code int32 `json:"code"`
|
||||||
ErrMsg string `json:"errmsg"`
|
Message string `json:"message"`
|
||||||
Page common.StreamPagination `json:"page"`
|
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)
|
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)
|
rspObj.Page.FillPage(pagination)
|
||||||
},
|
},
|
||||||
func(ds *f5.DataSet) {
|
func(ds *f5.DataSet) {
|
||||||
rspObj.Rows = append(rspObj.Rows, loadcall(ds))
|
rspObj.Data = append(rspObj.Data, loadcall(ds))
|
||||||
})
|
})
|
||||||
|
|
||||||
c.JSON(200, rspObj)
|
c.JSON(200, rspObj)
|
||||||
|
@ -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)
|
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{} {
|
query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||||
var p system.Order
|
p := new(system.Order)
|
||||||
p.LoadFromDs(ds)
|
p.LoadFromDs(ds)
|
||||||
return p
|
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)
|
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{} {
|
query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||||
var p system.Sale
|
p := new(system.Sale)
|
||||||
p.LoadFromDs(ds)
|
p.LoadFromDs(ds)
|
||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *NFTApi) NFTQuery(c *gin.Context) {
|
func (this *NFTApi) NFTQuery(c *gin.Context) {
|
||||||
type HeroesQueryForm struct {
|
type NFTQueryForm struct {
|
||||||
Owner_address string `json:"owner_address"`
|
Owner_address string `json:"owner_address"`
|
||||||
Last_owner_address string `json:"last_owner_address"`
|
Last_owner_address string `json:"last_owner_address"`
|
||||||
Net_id int64 `json:"net_id"`
|
Net_id int64 `json:"net_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
reqJson := HeroesQueryForm{}
|
reqJson := NFTQueryForm{}
|
||||||
if !checkparam(&reqJson, c) {
|
if !checkparam(&reqJson, c) {
|
||||||
return
|
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)
|
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{} {
|
query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||||
var p system.NFT
|
p := new(system.NFT)
|
||||||
p.LoadFromDs(ds)
|
p.LoadFromDs(ds)
|
||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
|
@ -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)
|
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{} {
|
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||||
var p system.Player
|
p := new(system.Player)
|
||||||
p.LoadFromDs(ds)
|
p.LoadFromDs(ds)
|
||||||
return p
|
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)
|
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{} {
|
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||||
var p system.BagItem
|
p := new(system.BagItem)
|
||||||
p.LoadFromDs(ds)
|
p.LoadFromDs(ds)
|
||||||
return p
|
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)
|
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{} {
|
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||||
var p system.Hero
|
p := new(system.Hero)
|
||||||
p.LoadFromDs(ds)
|
p.LoadFromDs(ds)
|
||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
|
@ -16,7 +16,7 @@ type BagItem struct {
|
|||||||
Today_get_gold int64 `gorm:"comment:今日获得金币" json:"today_get_gold"`
|
Today_get_gold int64 `gorm:"comment:今日获得金币" json:"today_get_gold"`
|
||||||
Last_get_gold_time int `gorm:"comment:最后获得金币时间" json:"last_get_gold_time"`
|
Last_get_gold_time int `gorm:"comment:最后获得金币时间" json:"last_get_gold_time"`
|
||||||
Createtime int `gorm:"comment:创建时间" json:"createtime"`
|
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"`
|
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.Today_get_gold = q5.ToInt64(ds.GetByName("today_get_gold"))
|
||||||
this.Last_get_gold_time = q5.ToInt(ds.GetByName("last_get_gold_time"))
|
this.Last_get_gold_time = q5.ToInt(ds.GetByName("last_get_gold_time"))
|
||||||
this.Createtime = q5.ToInt(ds.GetByName("createtime"))
|
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"))
|
this.Is_old = q5.ToInt(ds.GetByName("is_old"))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user