This commit is contained in:
aozhiwei 2024-06-16 12:08:36 +08:00
parent f75495f4fd
commit 163f1e0f65

View File

@ -173,22 +173,23 @@ func (this *MarketApi) TransactionHistory(c *gin.Context) {
pageSize := q5.ToInt32(c.DefaultQuery("page_size", ""))
if pageSize < 0 {
pageSize = 1
} else if pageSize > 100 {
pageSize = 100
} else if pageSize > 20 {
pageSize = 20
}
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
netId := q5.ToInt64(c.Param("net_id"))
accountAddress := strings.ToLower(c.Param("account_address"))
filterType := q5.ToInt32(c.DefaultQuery("type", ""))
sql := fmt.Sprintf(`
SELECT A.idx, A.net_id, A.token_type, A.token_id, A.contract_address, B.status FROM t_nft A LEFT JOIN t_order B
ON A.net_id = B.net_id AND A.contract_address = B.contract_address AND A.token_id = B.token_id
WHERE A.idx > %d AND A.net_id = %d AND A.owner_address=? `,
SELECT * FROM t_sale WHERE idx > %d AND net_id = %d `,
cursor, netId)
if filterType == 1 {
sql += "B.status = '" + constant.ORDER_STATUS_ACTIVE + "'"
} else if filterType == 2 {
sql += "B.status <> '" + constant.ORDER_STATUS_ACTIVE + "'"
subFilters := []f5.DbQueryFilter{}
{
if filterType == 1 {
q5.AppendSlice(&subFilters, f5.GetDbFilter().EQ("buyer", accountAddress).And())
} else if filterType == 2 {
q5.AppendSlice(&subFilters, f5.GetDbFilter().EQ("seller", accountAddress).And())
}
}
rspObj := struct {
ErrCode int32 `json:"errcode"`
@ -207,8 +208,7 @@ WHERE A.idx > %d AND A.net_id = %d AND A.owner_address=? `,
[]string{
accountAddress,
},
f5.GetDbFilter().Comp(
),
f5.GetDbFilter().Comp(subFilters...),
"",
func (err error, pagination *f5.StreamPagination) {
rspObj.Page.FillPage(pagination)