Jelajahi Sumber

接口 /api/sbyj/GetTouristGoods 增加出参和入参

zhouxnsz 1 tahun lalu
induk
melakukan
9a838e9317
6 mengubah file dengan 100 tambahan dan 12 penghapusan
  1. 7 7
      config/config.xml
  2. 38 3
      controllers/sbyj/goods.go
  3. 18 0
      docs/docs.go
  4. 18 0
      docs/swagger.json
  5. 12 0
      docs/swagger.yaml
  6. 7 2
      models/sbyj.go

+ 7 - 7
config/config.xml

@@ -16,11 +16,11 @@
     <DbName value="orcl"/>
     <DbPort value="1521"/>
     <!-- DbUser DbPwd 支持明文密文 -->
-    <DbUser value="mtp2_test136"/>
+    <DbUser value="mtp2_test204"/>
     <DbPwd value="muchinfo"/>
   </DbSetting>
   <RedisSetting>
-    <Address value="192.168.31.136"/>
+    <Address value="192.168.31.204"/>
     <Port value="5007"/>
     <Timeout value="3"/>
     <ConnNum value="1"/>
@@ -30,11 +30,11 @@
   </RedisSetting>
   <MqSetting>
     <!-- Url 支持明文密文 -->
-    <Url value="amqp://guest:guest@192.168.31.136:5020/test"/>
+    <Url value="amqp://guest:guest@192.168.31.204:5020/test"/>
     <Exchange value="entry"/>
   </MqSetting>
   <MongoDBSetting>
-    <HostName value="192.168.31.136"/>
+    <HostName value="192.168.31.204"/>
     <Port value="5025"/>
     <DBName value="HistoryQuote"/>
     <!-- Username Password 支持明文密文 -->
@@ -44,9 +44,9 @@
   <MySQLSetting>
     <Host value="192.168.30.72"/>
     <Port value="3306"/>
-    <DBName value="historyquote_test136"/>
+    <DBName value="historyquote_test204"/>
     <!-- Username Password 支持明文密文 -->
-    <Username value="quote_test136"/>
+    <Username value="quote_test204"/>
     <Password value="123456"/>
   </MySQLSetting>
   <Tencent>
@@ -66,6 +66,6 @@
     <AppId value="896210645"/>
     <PrivateKey value="MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCqmByEbXbqqq+FYxD1+mJzqrVxG/7xNF3iZJV9q0PqOVwWPEtND8nNuB2FeAwHc5+W7dZwXheV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6pqMJuqxwpeeloJgztS5saoUYBd62nnpGreMolbGG94KnkLP9mmkH1SOCpdAoGAbheD3ljKilx/cLVxvIRy1vZe8EyNGBPoxMuvhlPVFBloae5RLH3/PfHd4TsnUhdqNOM1op0axlJhxI+iMpR2NKjOrg6m8diBpwvlRrgsvM2KWe0ouAm3e0GCZkd1KQTI2UuVRmaCdtkpF7GeU/BPAlnFpy6zON+61k/Z+wDC++8CgYEA54xmJqIr19BpKkcHAxE2pzDrj6ssu2qObKLfsS27o4RevBnrhoY9kPwn8kUKpngoCTd7tM42y9fcpAdUDv+lENAcIF/kz4u+zkyRGR+SpirgAsCYzxZN3GfRNDHBaFEiTkyL6NFdPGV2GTPcd0b6JGf82Thb0JJCxB/J3hVnDIs="/>
     <NotifyUrl value="http://218.17.158.45:15105/api/Asign/HandleASignCompleted"/>
-    <OpenApiUrl value="http://192.168.31.136:5015/mtp2-onlineopen"/>
+    <OpenApiUrl value="http://192.168.31.204:5015/mtp2-onlineopen"/>
   </Asign>
 </Configuration>

+ 38 - 3
controllers/sbyj/goods.go

@@ -14,22 +14,57 @@ import (
 	"mtp2_if/logger"
 	"mtp2_if/models"
 	"net/http"
+	"strconv"
+	"strings"
 
 	"github.com/gin-gonic/gin"
 )
 
+type GetTouristGoodsReq struct {
+	TradeModes string `form:"trademodes"` // 交易模式筛选, 逗号隔开, 默认为 52,97,99
+	MarketIds  string `form:"marketids"`  // 市场ID筛选, 逗号隔开
+}
+
 // GetTouristGoods 获取水贝亿爵游客商品列表
 // @Summary 获取水贝亿爵游客商品列表
 // @Produce json
-// @Success 200 {array}  models.TouristGoods
-// @Failure 500 {object} app.Response
+// @Param   trademodes query    string false "交易模式筛选, 逗号隔开, 默认为 52,97,99"
+// @Param   marketids  query    string false "市场ID筛选, 逗号隔开"
+// @Success 200        {array}  models.TouristGoods
+// @Failure 500        {object} app.Response
 // @Router  /sbyj/GetTouristGoods [get]
 // @Tags    水贝亿爵
 func GetTouristGoods(c *gin.Context) {
 	appG := app.Gin{C: c}
 
+	// 获取请求参数
+	var req GetTouristGoodsReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("GetTouristGoods failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
 	// 获取数据
-	goodses, err := models.GetTouristGoods([]int{52, 97, 99})
+	var tradeModes []int
+	if req.TradeModes != "" {
+		arr := strings.Split(req.TradeModes, ",")
+		for _, item := range arr {
+			a, _ := strconv.Atoi(item)
+			tradeModes = append(tradeModes, a)
+		}
+	} else {
+		tradeModes = []int{52, 97, 99}
+	}
+	marketIds := make([]int, 0)
+	if req.MarketIds != "" {
+		arr := strings.Split(req.MarketIds, ",")
+		for _, item := range arr {
+			a, _ := strconv.Atoi(item)
+			marketIds = append(marketIds, a)
+		}
+	}
+	goodses, err := models.GetTouristGoods(tradeModes, marketIds)
 	if err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("GetTouristGoods failed: %s", err.Error())

+ 18 - 0
docs/docs.go

@@ -23395,6 +23395,20 @@ const docTemplate = `{
                     "水贝亿爵"
                 ],
                 "summary": "获取水贝亿爵游客商品列表",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "交易模式筛选, 逗号隔开, 默认为 52,97,99",
+                        "name": "trademodes",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场ID筛选, 逗号隔开",
+                        "name": "marketids",
+                        "in": "query"
+                    }
+                ],
                 "responses": {
                     "200": {
                         "description": "OK",
@@ -56992,6 +57006,10 @@ const docTemplate = `{
                     "description": "备注",
                     "type": "string"
                 },
+                "thumurls": {
+                    "description": "缩略图片(1:1)(逗号分隔)",
+                    "type": "string"
+                },
                 "trademode": {
                     "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
                     "type": "integer"

+ 18 - 0
docs/swagger.json

@@ -23386,6 +23386,20 @@
                     "水贝亿爵"
                 ],
                 "summary": "获取水贝亿爵游客商品列表",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "交易模式筛选, 逗号隔开, 默认为 52,97,99",
+                        "name": "trademodes",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场ID筛选, 逗号隔开",
+                        "name": "marketids",
+                        "in": "query"
+                    }
+                ],
                 "responses": {
                     "200": {
                         "description": "OK",
@@ -56983,6 +56997,10 @@
                     "description": "备注",
                     "type": "string"
                 },
+                "thumurls": {
+                    "description": "缩略图片(1:1)(逗号分隔)",
+                    "type": "string"
+                },
                 "trademode": {
                     "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
                     "type": "integer"

+ 12 - 0
docs/swagger.yaml

@@ -24677,6 +24677,9 @@ definitions:
       remark:
         description: 备注
         type: string
+      thumurls:
+        description: 缩略图片(1:1)(逗号分隔)
+        type: string
       trademode:
         description: 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式
           21:竞拍-大宗式 22:受托竞价
@@ -46397,6 +46400,15 @@ paths:
       - 水贝亿爵
   /sbyj/GetTouristGoods:
     get:
+      parameters:
+      - description: 交易模式筛选, 逗号隔开, 默认为 52,97,99
+        in: query
+        name: trademodes
+        type: string
+      - description: 市场ID筛选, 逗号隔开
+        in: query
+        name: marketids
+        type: string
       produces:
       - application/json
       responses:

+ 7 - 2
models/sbyj.go

@@ -63,19 +63,24 @@ type TouristGoods struct {
 	Isvisible             int32     `json:"isvisible"  xorm:"ISVISIBLE"`                           // 游客是否可见 - 0:不可见 1:可见
 	Areauserid            int64     `json:"areauserid"  xorm:"AREAUSERID"`                         // 所属机构
 	Pictureurl            string    `json:"pictureurl"  xorm:"PICTUREURL"`                         // 商品图片
+	THUMURLS              string    `json:"thumurls" xorm:"THUMURLS"`                              // 缩略图片(1:1)(逗号分隔)
 
 	Trademode int32 `json:"trademode"  xorm:"'TRADEMODE'"` // 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价
 
 	GOODSORDER string `json:"goodsorder" xorm:"GOODSORDER"` // 商品显示顺序(99)
 }
 
-func GetTouristGoods(tradeModes []int) (goods []TouristGoods, err error) {
+func GetTouristGoods(tradeModes []int, marketIds []int) (goods []TouristGoods, err error) {
 	goods = make([]TouristGoods, 0)
 	session := db.GetEngine().Table("GOODS G").
 		Select("G.*, M.TRADEMODE, E.GOODSORDER").
 		Join("LEFT", "MARKET M", "M.MARKETID = G.MARKETID").
 		Join("LEFT", "GOODSEX E", "E.GOODSID = G.GOODSID").
-		Where("G.GOODSSTATUS in (3, 7)").In("M.TRADEMODE", tradeModes).OrderBy("G.GOODSCODE")
+		Where("G.GOODSSTATUS in (3, 7)").In("M.TRADEMODE", tradeModes)
+	if len(marketIds) > 0 {
+		session = session.In("M.MARKETID", marketIds)
+	}
+	session = session.OrderBy("G.GOODSCODE")
 
 	err = session.Find(&goods)