From 4dd828b1978f4834d9f0ab04047dfa6498161971 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 13 Jun 2024 17:51:25 +0800 Subject: [PATCH] 1 --- .../config/marketserver.cluster.json | 2 +- server/marketserver/api/v1/asset/asset.go | 51 ++++++++++++++----- server/marketserver/app/app.go | 11 +++- server/marketserver/constant/constant.go | 9 ++++ third_party/f5 | 2 +- 5 files changed, 59 insertions(+), 16 deletions(-) diff --git a/bin/marketserver/config/marketserver.cluster.json b/bin/marketserver/config/marketserver.cluster.json index 8116614c..eb297487 100644 --- a/bin/marketserver/config/marketserver.cluster.json +++ b/bin/marketserver/config/marketserver.cluster.json @@ -1,6 +1,6 @@ [ { "instance_id": 1, - "http_listen_port": 9993 + "http_listen_port": 9996 } ] diff --git a/server/marketserver/api/v1/asset/asset.go b/server/marketserver/api/v1/asset/asset.go index 618f0e08..9a15f72d 100644 --- a/server/marketserver/api/v1/asset/asset.go +++ b/server/marketserver/api/v1/asset/asset.go @@ -1,8 +1,11 @@ package asset import ( + "q5" "f5" - "mt" + "main/constant" + "fmt" + "strings" "github.com/gin-gonic/gin" ) @@ -10,19 +13,41 @@ type AssetApi struct { } +/* + filterType: 0:全部 1:已上架 2:未上架 + */ func (this *AssetApi) AccountAsset(c *gin.Context) { - netId := c.Param("netId") - tokenId := c.Param("tokenId") - f5.GetHttpCliMgr().SendGoStyleRequest( - mt.Table.Config.GetGameApiUrl() + "/webapp/index.php", - map[string]string{ - "c": "OutAppNft", - "a": "nftMetaView", - "nft_type": "hero", - "net_id": netId, - "token_id": tokenId, + pageSize := q5.ToInt32(c.DefaultQuery("page_size", "")) + cursor := q5.ToInt64(c.DefaultQuery("cursor", "")) + netId := q5.ToInt64(c.Param("net_id")) + accountAddress := strings.ToLower(c.Param("account_address")) + //searchName := c.DefaultQuery("search_name", "") + filterType := q5.ToInt32(c.DefaultQuery("type", "")) + sql := fmt.Sprintf(` +SELECT A.idx, A.net_id, A.token_type, A.token_id, 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 + "'" + } + f5.GetGoStyleDb().StreamPageQuery( + constant.BCNFT_DB, + pageSize, + cursor, + sql, + []string{ + accountAddress, }, - func (rsp f5.HttpCliResponse) { - c.String(200, rsp.GetRawData()) + f5.GetDbFilter().Comp( + ), + "", + func (err error, pagination *f5.StreamPagination) { + + }, + func (ds *f5.DataSet) { + }) } diff --git a/server/marketserver/app/app.go b/server/marketserver/app/app.go index 24165b5e..8897ff91 100644 --- a/server/marketserver/app/app.go +++ b/server/marketserver/app/app.go @@ -3,6 +3,7 @@ package app import ( "f5" "mt" + "main/constant" ) type app struct { @@ -11,7 +12,7 @@ type app struct { } func (this *app) GetPkgName() string { - return "nftserver" + return "marketserver" } func (this *app) GetHttpListenPort() int32 { @@ -38,6 +39,14 @@ func (this *app) Update() { } func (this *app) registerDataSources() { + f5.GetGoStyleDb().RegisterDataSource( + constant.BCNFT_DB, + mt.Table.NftDb.GetById(0).GetHost(), + mt.Table.NftDb.GetById(0).GetPort(), + mt.Table.NftDb.GetById(0).GetUser(), + mt.Table.NftDb.GetById(0).GetPasswd(), + mt.Table.NftDb.GetById(0).GetDatabase(), + 3) } func (this *app) HasTask() bool { diff --git a/server/marketserver/constant/constant.go b/server/marketserver/constant/constant.go index 727f9f7b..6d16330d 100644 --- a/server/marketserver/constant/constant.go +++ b/server/marketserver/constant/constant.go @@ -9,3 +9,12 @@ const ( ROUTER_MGR_MODULE_IDX MAX_MODULE_IDX ) + +const ( + ORDER_STATUS_PENDING = "PENDING" + ORDER_STATUS_ACTIVE = "ACTIVE" + ORDER_STATUS_INACTIVE = "INACTIVE" + ORDER_STATUS_CANCELLED = "CANCELLED" + ORDER_STATUS_FILLED = "FILLED" + ORDER_STATUS_EXPIRED = "EXPIRED" +) diff --git a/third_party/f5 b/third_party/f5 index 684e5481..ee715d67 160000 --- a/third_party/f5 +++ b/third_party/f5 @@ -1 +1 @@ -Subproject commit 684e548134643975d38213c017ac4cdb5577a8c0 +Subproject commit ee715d672d83932a6a20f810cc490d737fad01e6