Parcourir la source

QueryPresaleGoodsEx 增加 goodsids 请求参数

Zhou Xiaoning il y a 5 ans
Parent
commit
c5bc590796
4 fichiers modifiés avec 27 ajouts et 3 suppressions
  1. 11 3
      controllers/cptrade/cpTrade.go
  2. 6 0
      docs/docs.go
  3. 6 0
      docs/swagger.json
  4. 4 0
      docs/swagger.yaml

+ 11 - 3
controllers/cptrade/cpTrade.go

@@ -8,6 +8,7 @@ import (
 	"mtp2_if/global/e"
 	"mtp2_if/logger"
 	"net/http"
+	"strings"
 	"time"
 
 	"github.com/gin-gonic/gin"
@@ -324,9 +325,10 @@ func QueryPositionCancel(c *gin.Context) {
 
 // QueryPresaleGoodsExReq 查询产能预售商品扩展请求参数
 type QueryPresaleGoodsExReq struct {
-	GoodsID     int `form:"goodsid"`
-	MarketID    int `form:"marketid"`
-	PresaleMode int `form:"presalemode"`
+	GoodsID     int    `form:"goodsid"`
+	MarketID    int    `form:"marketid"`
+	PresaleMode int    `form:"presalemode"`
+	GoodsIDs    string `form:"goodsids"`
 }
 
 // Cptradepresalegoodsex 产能预售商品扩展表
@@ -362,6 +364,7 @@ func (Cptradepresalegoodsex) TableName() string {
 // @Param goodsid query int false "预售商品ID"
 // @Param marketid query int false "预售市场ID"
 // @Param presalemode query int false "预售模式 - 1:一口价 2:大宗式竞拍"
+// @Param goodsids query string false "预售商品ID列表 - 格式:1,2,3"
 // @Success 200 {object} Cptradepresalegoodsex
 // @Failure 500 {object} app.Response
 // @Router /CPTrade/QueryPresaleGoodsEx [get]
@@ -369,6 +372,7 @@ func (Cptradepresalegoodsex) TableName() string {
 func QueryPresaleGoodsEx(c *gin.Context) {
 	appG := app.Gin{C: c}
 
+	// FIXME: 由于数据中包括[]int类型,会造成校验报错,故暂时不使用
 	// 获取请求参数
 	var req QueryPresaleGoodsExReq
 	if err := appG.C.ShouldBindQuery(&req); err != nil {
@@ -390,6 +394,10 @@ func QueryPresaleGoodsEx(c *gin.Context) {
 	if req.PresaleMode > 0 {
 		s = s.And("PresaleMode=?", req.PresaleMode)
 	}
+	if len(req.GoodsIDs) > 0 {
+		// s = s.And("GoodsID in (?)", req.GoodsIDs)
+		s = s.In("GOODSID", strings.Split(req.GoodsIDs, ","))
+	}
 	if err := s.Find(&datas); err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("QueryPresaleGoodsEx failed: %s", err.Error())

+ 6 - 0
docs/docs.go

@@ -160,6 +160,12 @@ var doc = `{
                         "description": "预售模式 - 1:一口价 2:大宗式竞拍",
                         "name": "presalemode",
                         "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "预售商品ID列表 - 格式:1,2,3",
+                        "name": "goodsids",
+                        "in": "query"
                     }
                 ],
                 "responses": {

+ 6 - 0
docs/swagger.json

@@ -144,6 +144,12 @@
                         "description": "预售模式 - 1:一口价 2:大宗式竞拍",
                         "name": "presalemode",
                         "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "预售商品ID列表 - 格式:1,2,3",
+                        "name": "goodsids",
+                        "in": "query"
                     }
                 ],
                 "responses": {

+ 4 - 0
docs/swagger.yaml

@@ -429,6 +429,10 @@ paths:
         in: query
         name: presalemode
         type: integer
+      - description: 预售商品ID列表 - 格式:1,2,3
+        in: query
+        name: goodsids
+        type: string
       produces:
       - application/json
       responses: