This commit is contained in:
aozhiwei 2024-06-16 10:33:54 +08:00
parent fdec315fba
commit 83eaf03d75
2 changed files with 26 additions and 18 deletions

View File

@ -5,6 +5,8 @@ import (
"f5"
"mt"
"main/constant"
"main/common"
. "main/global"
"fmt"
//"strings"
"net/http"
@ -54,7 +56,7 @@ func (this *MarketApi) ProductList(c *gin.Context) {
sql := fmt.Sprintf(`
SELECT * FROM t_order A WHERE idx > %d AND net_id = %d AND status="%s"
`,
cursor, netId, constant.ORDER_STATUS_ACTIVE, pageSize + 1)
cursor, netId, constant.ORDER_STATUS_ACTIVE)
orderBy := ""
{
@ -124,13 +126,15 @@ SELECT * FROM t_order A WHERE idx > %d AND net_id = %d AND status="%s"
}
}
nfts := []struct{
idx int64
netId int32
tokenType int32
tokenId string
contractAddress string
}{}
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
Page common.StreamPagination `json:"page"`
Rows []interface{} `json:"rows"`
}{
Rows : []interface{}{},
}
nfts := []*common.NftDto{}
f5.GetGoStyleDb().StreamPageQuery(
constant.BCNFT_DB,
pageSize,
@ -141,18 +145,22 @@ SELECT * FROM t_order A WHERE idx > %d AND net_id = %d AND status="%s"
f5.GetDbFilter().Comp(subFilters...),
orderBy,
func (err error, pagination *f5.StreamPagination) {
rspObj.Page.FillPage(pagination)
},
func (ds *f5.DataSet) {
var p = q5.NewSliceElement(&nfts)
p.idx = q5.ToInt64(ds.GetByName("idx"))
p.netId = q5.ToInt32(ds.GetByName("net_id"))
p.tokenType = q5.ToInt32(ds.GetByName("token_type"))
p.tokenId = ds.GetByName("token_id")
p.contractAddress = ds.GetByName("contract_address")
f5.GetSysLog().Info("idx:%s", p.idx)
p := new(common.NftDto)
p.NetId = q5.ToInt32(ds.GetByName("net_id"))
p.ContractAddress = ds.GetByName("contract_address")
p.TokenId = ds.GetByName("token_id")
q5.AppendSlice(&nfts, p)
})
f5.GetSysLog().Info("dafdf")
GetCacheMgr().GetNfts(nfts)
{
for _, val := range nfts {
q5.AppendSlice(&rspObj.Rows, val.NftCache.GetJsonData())
}
}
c.JSON(200, rspObj)
}
func (this *MarketApi) TransactionHistory(c *gin.Context) {

View File

@ -9,7 +9,7 @@ type MarketRouter struct{}
func (this *MarketRouter) InitRouter() {
api := v1.ApiGroupApp.MarketApiGroup
f5.GetApp().GetGinEngine().GET("/api/market/product/list/:net_id", api.MarketApi.ProductList)
f5.GetApp().GetGinEngine().POST("/api/market/product/list/:net_id", api.MarketApi.ProductList)
f5.GetApp().GetGinEngine().GET("/api/market/transaction/history/:net_id/:account_address",
api.MarketApi.TransactionHistory)
}