From 9ab51b1f24c142e31aae851fbb73db089530f883 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 26 Jun 2024 13:44:44 +0800 Subject: [PATCH] 1 --- server/marketserver/api/v1/market/market.go | 7 +++++++ server/marketserver/router/market/market.go | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/marketserver/api/v1/market/market.go b/server/marketserver/api/v1/market/market.go index 27a7d74c..156fc848 100644 --- a/server/marketserver/api/v1/market/market.go +++ b/server/marketserver/api/v1/market/market.go @@ -18,6 +18,7 @@ import ( type goodsDto struct { Event interface{} `json:"event"` Nft interface{} `json:"nft"` + InShopCart int32 `json:"in_shopcart"` } type MarketApi struct { @@ -410,6 +411,9 @@ WHERE idx in (%s) } func (this *MarketApi) Goods(c *gin.Context) { + openId := c.MustGet("open_id").(string) + cartDb := service.GetShopCartByOpenId(openId) + netId := q5.ToInt64(c.Param("net_id")) contractAddress := c.Param("contract_address") tokenId := c.Param("token_id") @@ -473,6 +477,9 @@ WHERE net_id=? AND contract_address=? AND token_id=? AND status=? p = new(goodsDto) p.Event = val.Payload p.Nft = val.NftCache.GetJsonData() + if cartDb != nil && cartDb.GetGoods(val.NetId, val.ContractAddress, val.TokenId) != nil{ + p.InShopCart = 1 + } rspObj.Data = p } } diff --git a/server/marketserver/router/market/market.go b/server/marketserver/router/market/market.go index cb0c03ee..5f3e78e3 100644 --- a/server/marketserver/router/market/market.go +++ b/server/marketserver/router/market/market.go @@ -17,5 +17,7 @@ func (this *MarketRouter) InitRouter() { api.MarketApi.TransactionHistory) f5.GetApp().GetGinEngine().GET("/api/market/product/category/:net_id", api.MarketApi.CategoryGoodsNum) f5.GetApp().GetGinEngine().GET("/api/market/product/query_price", api.MarketApi.QueryPrice) - f5.GetApp().GetGinEngine().GET("/api/market/product/goods/:net_id/:contract_address/:token_id", api.MarketApi.Goods) + f5.GetApp().GetGinEngine().GET("/api/market/product/goods/:net_id/:contract_address/:token_id", + middleware.MaybeJwtAuth, + api.MarketApi.Goods) }