From 83eaf03d750efeb6f8f39cf6d73f56ba44bbc300 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 16 Jun 2024 10:33:54 +0800 Subject: [PATCH] 1 --- server/marketserver/api/v1/market/market.go | 42 ++++++++++++--------- server/marketserver/router/market/market.go | 2 +- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/server/marketserver/api/v1/market/market.go b/server/marketserver/api/v1/market/market.go index 37c5cb5a..ce3533fc 100644 --- a/server/marketserver/api/v1/market/market.go +++ b/server/marketserver/api/v1/market/market.go @@ -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) { diff --git a/server/marketserver/router/market/market.go b/server/marketserver/router/market/market.go index 544dec21..8d1392cf 100644 --- a/server/marketserver/router/market/market.go +++ b/server/marketserver/router/market/market.go @@ -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) }