aozhiwei 6526651a65 1
2024-06-15 12:09:46 +08:00

64 lines
1.6 KiB
Go

package asset
import (
"q5"
"f5"
"main/constant"
"main/common"
"fmt"
"strings"
"github.com/gin-gonic/gin"
)
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
}
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=? LIMIT %d`,
cursor, netId, pageSize + 1)
if filterType == 1 {
sql += "B.status = '" + constant.ORDER_STATUS_ACTIVE + "'"
} else if filterType == 2 {
sql += "B.status <> '" + constant.ORDER_STATUS_ACTIVE + "'"
}
nfts := []common.NftDto{}
f5.GetGoStyleDb().StreamPageQuery(
constant.BCNFT_DB,
pageSize,
cursor,
sql,
[]string{
accountAddress,
},
f5.GetDbFilter().Comp(
),
"",
func (err error, pagination *f5.StreamPagination) {
},
func (ds *f5.DataSet) {
p := q5.NewSliceElement(&nfts)
p.NetId = q5.ToInt32(ds.GetByName("net_id"))
p.ContractAddress = ds.GetByName("contract_address")
p.TokenId = ds.GetByName("token_id")
})
f5.GetSysLog().Info("dafdf")
}