From c0d7840cb91cbc7edfd0fc27e18ca7dabfb1506b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 20 Jun 2024 21:30:25 +0800 Subject: [PATCH] 1 --- server/marketserver/api/v1/market/market.go | 39 +++++++++++++++++++ .../router/gold_bullion/gold_bullion.go | 8 ++-- server/marketserver/router/hero/hero.go | 8 ++-- server/marketserver/router/market/market.go | 1 + 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/server/marketserver/api/v1/market/market.go b/server/marketserver/api/v1/market/market.go index 05af83bf..025e2b5a 100644 --- a/server/marketserver/api/v1/market/market.go +++ b/server/marketserver/api/v1/market/market.go @@ -226,3 +226,42 @@ SELECT * FROM t_sale WHERE idx > %d AND net_id = %d `, } c.JSON(200, rspObj) } + +func (this *MarketApi) CategoryGoodsNum(c *gin.Context) { + netId := q5.ToInt64(c.Param("net_id")) + + rspObj := &struct { + ErrCode int32 `json:"errcode"` + ErrMsg string `json:"errmsg"` + Data []struct{ + ItemId int32 `json:"item_id"` + Num int32 `json:"num"` + } `json:"data"` + }{} + q5.NewSlice(&rspObj.Data, 0, 10) + + sql := fmt.Sprintf(` +SELECT item_id, COUNT(idx) AS num FROM t_order WHEERE net_id = %d AND status="%s" AND item_id <> 0 GROUP BY item_id +`, + netId, + constant.ORDER_STATUS_ACTIVE) + params := []string{} + f5.GetGoStyleDb().RawQuery( + constant.BCNFT_DB, + sql, + params, + func (err error, ds *f5.DataSet) { + if err != nil { + rspObj.ErrCode = 500 + rspObj.ErrMsg = "server internal error" + c.JSON(200, rspObj) + return + } + for ds.Next() { + p := q5.NewSliceElement(&rspObj.Data) + p.ItemId = q5.ToInt32(ds.GetByName("item_id")) + p.Num = q5.ToInt32(ds.GetByName("num")) + } + c.JSON(200, rspObj) + }) +} diff --git a/server/marketserver/router/gold_bullion/gold_bullion.go b/server/marketserver/router/gold_bullion/gold_bullion.go index a11a6989..cad00f9b 100644 --- a/server/marketserver/router/gold_bullion/gold_bullion.go +++ b/server/marketserver/router/gold_bullion/gold_bullion.go @@ -1,13 +1,13 @@ package gold_bullion import ( - "f5" - "main/api/v1" + //"f5" + //"main/api/v1" ) type GoldBullionRouter struct{} func (this *GoldBullionRouter) InitRouter() { - api := v1.ApiGroupApp.GoldBullionApiGroup - f5.GetApp().GetGinEngine().POST("/api/gold_bullion/use/:net_id", api.GoldBullionApi.Use) + //api := v1.ApiGroupApp.GoldBullionApiGroup + // f5.GetApp().GetGinEngine().POST("/api/gold_bullion/use/:net_id", api.GoldBullionApi.Use) } diff --git a/server/marketserver/router/hero/hero.go b/server/marketserver/router/hero/hero.go index 89435be1..2b30a292 100644 --- a/server/marketserver/router/hero/hero.go +++ b/server/marketserver/router/hero/hero.go @@ -1,13 +1,13 @@ package hero import ( - "f5" - "main/api/v1" + //"f5" + //"main/api/v1" ) type HeroRouter struct{} func (this *HeroRouter) InitRouter() { - api := v1.ApiGroupApp.HeroApiGroup - f5.GetApp().GetGinEngine().POST("/api/hero/use/:net_id", api.HeroApi.Use) + //api := v1.ApiGroupApp.HeroApiGroup + //f5.GetApp().GetGinEngine().POST("/api/hero/use/:net_id", api.HeroApi.Use) } diff --git a/server/marketserver/router/market/market.go b/server/marketserver/router/market/market.go index 8d1392cf..7c297e26 100644 --- a/server/marketserver/router/market/market.go +++ b/server/marketserver/router/market/market.go @@ -12,4 +12,5 @@ func (this *MarketRouter) InitRouter() { 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) + f5.GetApp().GetGinEngine().GET("/api/market/product/category/:net_id", api.MarketApi.CategoryGoodsNum) }