1
This commit is contained in:
parent
40dc2565db
commit
be78cc942e
@ -1,4 +1,4 @@
|
||||
package asset
|
||||
package asset
|
||||
|
||||
import (
|
||||
"q5"
|
||||
@ -19,12 +19,7 @@ type AssetApi struct {
|
||||
filterType: 0:全部 1:已上架 2:未上架
|
||||
*/
|
||||
func (this *AssetApi) AccountAsset(c *gin.Context) {
|
||||
pageSize := q5.ToInt32(c.DefaultQuery("page_size", ""))
|
||||
if pageSize < 0 {
|
||||
pageSize = 1
|
||||
} else if pageSize > 100 {
|
||||
pageSize = 100
|
||||
}
|
||||
pageSize := q5.AdjustRangeValue(q5.ToInt32(c.DefaultQuery("page_size", "")), 1, 20)
|
||||
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
|
||||
netId := q5.ToInt64(c.Param("net_id"))
|
||||
accountAddress := strings.ToLower(c.Param("account_address"))
|
||||
@ -34,11 +29,13 @@ SELECT A.idx, A.net_id, A.token_type, A.token_id, A.contract_address, B.status F
|
||||
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=? `,
|
||||
cursor, netId)
|
||||
params := []string{accountAddress}
|
||||
if filterType == 1 {
|
||||
sql += "B.status = '" + constant.ORDER_STATUS_ACTIVE + "'"
|
||||
} else if filterType == 2 {
|
||||
sql += "B.status <> '" + constant.ORDER_STATUS_ACTIVE + "'"
|
||||
}
|
||||
orderBy := ""
|
||||
rspObj := struct {
|
||||
ErrCode int32 `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
@ -53,12 +50,10 @@ WHERE A.idx > %d AND A.net_id = %d AND A.owner_address=? `,
|
||||
pageSize,
|
||||
cursor,
|
||||
sql,
|
||||
[]string{
|
||||
accountAddress,
|
||||
},
|
||||
params,
|
||||
f5.GetDbFilter().Comp(
|
||||
),
|
||||
"",
|
||||
orderBy,
|
||||
func (err error, pagination *f5.StreamPagination) {
|
||||
rspObj.Page.FillPage(pagination)
|
||||
},
|
||||
|
@ -46,12 +46,7 @@ func (this *MarketApi) ProductList(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
pageSize := q5.SafeToInt32(reqJson.PageSize)
|
||||
if pageSize < 0 {
|
||||
pageSize = 1
|
||||
} else if pageSize > 20 {
|
||||
pageSize = 20
|
||||
}
|
||||
pageSize := q5.AdjustRangeValue(q5.SafeToInt32(reqJson.PageSize), 1, 20)
|
||||
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
|
||||
sql := fmt.Sprintf(`
|
||||
SELECT * FROM t_order A WHERE idx > %d AND net_id = %d AND status="%s"
|
||||
@ -170,12 +165,7 @@ SELECT * FROM t_order A WHERE idx > %d AND net_id = %d
|
||||
}
|
||||
|
||||
func (this *MarketApi) TransactionHistory(c *gin.Context) {
|
||||
pageSize := q5.ToInt32(c.DefaultQuery("page_size", ""))
|
||||
if pageSize < 0 {
|
||||
pageSize = 1
|
||||
} else if pageSize > 20 {
|
||||
pageSize = 20
|
||||
}
|
||||
pageSize := q5.AdjustRangeValue(q5.ToInt32(c.DefaultQuery("page_size", "")), 1, 20)
|
||||
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
|
||||
netId := q5.ToInt64(c.Param("net_id"))
|
||||
accountAddress := strings.ToLower(c.Param("account_address"))
|
||||
@ -183,12 +173,14 @@ func (this *MarketApi) TransactionHistory(c *gin.Context) {
|
||||
sql := fmt.Sprintf(`
|
||||
SELECT * FROM t_sale WHERE idx > %d AND net_id = %d `,
|
||||
cursor, netId)
|
||||
params := []string{}
|
||||
subFilters := []f5.DbQueryFilter{}
|
||||
{
|
||||
if filterType == 1 {
|
||||
q5.AppendSlice(&subFilters, f5.GetDbFilter().EQ("buyer", accountAddress).And())
|
||||
sql += "AND buyer = ? "
|
||||
q5.AppendSlice(¶ms, accountAddress)
|
||||
} else if filterType == 2 {
|
||||
q5.AppendSlice(&subFilters, f5.GetDbFilter().EQ("seller", accountAddress).And())
|
||||
sql += "AND seller = ? "
|
||||
}
|
||||
}
|
||||
rspObj := struct {
|
||||
@ -199,17 +191,16 @@ SELECT * FROM t_sale WHERE idx > %d AND net_id = %d `,
|
||||
}{
|
||||
Rows : []interface{}{},
|
||||
}
|
||||
orderBy := ""
|
||||
nfts := []*common.NftDto{}
|
||||
f5.GetGoStyleDb().StreamPageQuery(
|
||||
constant.BCNFT_DB,
|
||||
pageSize,
|
||||
cursor,
|
||||
sql,
|
||||
[]string{
|
||||
//accountAddress,
|
||||
},
|
||||
params,
|
||||
f5.GetDbFilter().Comp(subFilters...),
|
||||
"",
|
||||
orderBy,
|
||||
func (err error, pagination *f5.StreamPagination) {
|
||||
rspObj.Page.FillPage(pagination)
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user