Преглед изворни кода

查询轮播图配置信息增加市场信息

zhou.xiaoning пре 4 година
родитељ
комит
b277671f61
4 измењених фајлова са 240 додато и 168 уклоњено
  1. 51 1
      controllers/common/common.go
  2. 69 61
      docs/docs.go
  3. 69 61
      docs/swagger.json
  4. 51 45
      docs/swagger.yaml

+ 51 - 1
controllers/common/common.go

@@ -6,6 +6,8 @@ import (
 	"mtp2_if/logger"
 	"mtp2_if/models"
 	"net/http"
+	"strconv"
+	"time"
 
 	"github.com/gin-gonic/gin"
 )
@@ -105,11 +107,31 @@ type QueryImageConfigsReq struct {
 	ImageType int `form:"imageType"`
 }
 
+// QueryImageConfigsRsp 查询轮播图配置信息返回模型
+type QueryImageConfigsRsp struct {
+	Configid   int64     `json:"configid"  xorm:"'CONFIGID'" binding:"required"` // 配置ID(SEQ_SZDZ2_IMAGECONFIG)
+	Imagetype  int32     `json:"imagetype"  xorm:"'IMAGETYPE'"`                  // 类型 - 1:首页轮播(移动) 2:我的(移动)
+	Title      string    `json:"title"  xorm:"'TITLE'"`                          // 标题
+	Imagepath  string    `json:"imagepath"  xorm:"'IMAGEPATH'"`                  // 图片
+	URL        string    `json:"url"  xorm:"'URL'"`                              // 链接(地址或商品ID)
+	Sort       int64     `json:"sort"  xorm:"'SORT'"`                            // 排序
+	Isshow     int32     `json:"isshow"  xorm:"'ISSHOW'"`                        // 是否展示 - 0:不展示 1:展示
+	Createdate time.Time `json:"createdate"  xorm:"'CREATEDATE'"`                // 创建时间
+	Creatorid  int64     `json:"creatorid"  xorm:"'CREATORID'"`                  // 创建人
+	Updatedate time.Time `json:"updatedate"  xorm:"'UPDATEDATE'"`                // 修改时间
+	Modifierid int64     `json:"modifierid"  xorm:"'MODIFIERID'"`                // 操作人
+	Areauserid int64     `json:"areauserid"  xorm:"'AREAUSERID'"`                // 所属机构ID
+	Urltype    int32     `json:"urltype"  xorm:"'URLTYPE'"`                      // 链接类型 - 1:直接地址 2:商品ID
+
+	MarketID  int `json:"marketid"`  // 市场ID
+	TradeMode int `json:"trademode"` // 交易模式
+}
+
 // QueryImageConfigs 查询轮播图配置信息
 // @Summary 查询轮播图配置信息
 // @Produce json
 // @Param imageType query int false "类型 - 1:App首页轮播 2:我的"
-// @Success 200 {object} models.Szdz2imageconfig
+// @Success 200 {object} QueryImageConfigsRsp
 // @Failure 500 {object} app.Response
 // @Router /Common/QueryImageConfigs [get]
 // @Tags 通用服务
@@ -132,6 +154,34 @@ func QueryImageConfigs(c *gin.Context) {
 		return
 	}
 
+	for _, v := range imageConfigs {
+		item := QueryImageConfigsRsp{
+			Configid:   v.Configid,
+			Imagetype:  v.Imagetype,
+			Title:      v.Title,
+			Imagepath:  v.Imagepath,
+			URL:        v.URL,
+			Sort:       v.Sort,
+			Isshow:     v.Isshow,
+			Createdate: v.Createdate,
+			Creatorid:  v.Creatorid,
+			Updatedate: v.Updatedate,
+			Modifierid: v.Modifierid,
+			Areauserid: v.Areauserid,
+			Urltype:    v.Urltype,
+		}
+
+		if item.Urltype == 2 {
+			if i, err := strconv.Atoi(v.URL); err == nil {
+				if market, _ := models.GetMarketByGoodsID(i); market != nil {
+					item.MarketID = int(market.Marketid)
+					item.TradeMode = int(market.Trademode)
+				}
+			}
+
+		}
+	}
+
 	// 查询成功
 	logger.GetLogger().Debugln("QueryImageConfigs successed: %v", imageConfigs)
 	appG.Response(http.StatusOK, e.SUCCESS, imageConfigs)

+ 69 - 61
docs/docs.go

@@ -553,7 +553,7 @@ var doc = `{
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/models.Szdz2imageconfig"
+                            "$ref": "#/definitions/common.QueryImageConfigsRsp"
                         }
                     },
                     "500": {
@@ -6213,6 +6213,74 @@ var doc = `{
                 }
             }
         },
+        "common.QueryImageConfigsRsp": {
+            "type": "object",
+            "required": [
+                "configid"
+            ],
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构ID",
+                    "type": "integer"
+                },
+                "configid": {
+                    "description": "配置ID(SEQ_SZDZ2_IMAGECONFIG)",
+                    "type": "integer"
+                },
+                "createdate": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "imagepath": {
+                    "description": "图片",
+                    "type": "string"
+                },
+                "imagetype": {
+                    "description": "类型 - 1:首页轮播(移动) 2:我的(移动)",
+                    "type": "integer"
+                },
+                "isshow": {
+                    "description": "是否展示 - 0:不展示 1:展示",
+                    "type": "integer"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "modifierid": {
+                    "description": "操作人",
+                    "type": "integer"
+                },
+                "sort": {
+                    "description": "排序",
+                    "type": "integer"
+                },
+                "title": {
+                    "description": "标题",
+                    "type": "string"
+                },
+                "trademode": {
+                    "description": "交易模式",
+                    "type": "integer"
+                },
+                "updatedate": {
+                    "description": "修改时间",
+                    "type": "string"
+                },
+                "url": {
+                    "description": "链接(地址或商品ID)",
+                    "type": "string"
+                },
+                "urltype": {
+                    "description": "链接类型 - 1:直接地址 2:商品ID",
+                    "type": "integer"
+                }
+            }
+        },
         "common.QueryNoticeRsp": {
             "type": "object",
             "required": [
@@ -14738,66 +14806,6 @@ var doc = `{
                 }
             }
         },
-        "models.Szdz2imageconfig": {
-            "type": "object",
-            "required": [
-                "configid"
-            ],
-            "properties": {
-                "areauserid": {
-                    "description": "所属机构ID",
-                    "type": "integer"
-                },
-                "configid": {
-                    "description": "配置ID(SEQ_SZDZ2_IMAGECONFIG)",
-                    "type": "integer"
-                },
-                "createdate": {
-                    "description": "创建时间",
-                    "type": "string"
-                },
-                "creatorid": {
-                    "description": "创建人",
-                    "type": "integer"
-                },
-                "imagepath": {
-                    "description": "图片",
-                    "type": "string"
-                },
-                "imagetype": {
-                    "description": "类型 - 1:首页轮播(移动) 2:我的(移动)",
-                    "type": "integer"
-                },
-                "isshow": {
-                    "description": "是否展示 - 0:不展示 1:展示",
-                    "type": "integer"
-                },
-                "modifierid": {
-                    "description": "操作人",
-                    "type": "integer"
-                },
-                "sort": {
-                    "description": "排序",
-                    "type": "integer"
-                },
-                "title": {
-                    "description": "标题",
-                    "type": "string"
-                },
-                "updatedate": {
-                    "description": "修改时间",
-                    "type": "string"
-                },
-                "url": {
-                    "description": "链接(地址或商品ID)",
-                    "type": "string"
-                },
-                "urltype": {
-                    "description": "链接类型 - 1:直接地址 2:商品ID",
-                    "type": "integer"
-                }
-            }
-        },
         "models.Szdz3convertconfig": {
             "type": "object",
             "required": [

+ 69 - 61
docs/swagger.json

@@ -537,7 +537,7 @@
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/models.Szdz2imageconfig"
+                            "$ref": "#/definitions/common.QueryImageConfigsRsp"
                         }
                     },
                     "500": {
@@ -6197,6 +6197,74 @@
                 }
             }
         },
+        "common.QueryImageConfigsRsp": {
+            "type": "object",
+            "required": [
+                "configid"
+            ],
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构ID",
+                    "type": "integer"
+                },
+                "configid": {
+                    "description": "配置ID(SEQ_SZDZ2_IMAGECONFIG)",
+                    "type": "integer"
+                },
+                "createdate": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "imagepath": {
+                    "description": "图片",
+                    "type": "string"
+                },
+                "imagetype": {
+                    "description": "类型 - 1:首页轮播(移动) 2:我的(移动)",
+                    "type": "integer"
+                },
+                "isshow": {
+                    "description": "是否展示 - 0:不展示 1:展示",
+                    "type": "integer"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "modifierid": {
+                    "description": "操作人",
+                    "type": "integer"
+                },
+                "sort": {
+                    "description": "排序",
+                    "type": "integer"
+                },
+                "title": {
+                    "description": "标题",
+                    "type": "string"
+                },
+                "trademode": {
+                    "description": "交易模式",
+                    "type": "integer"
+                },
+                "updatedate": {
+                    "description": "修改时间",
+                    "type": "string"
+                },
+                "url": {
+                    "description": "链接(地址或商品ID)",
+                    "type": "string"
+                },
+                "urltype": {
+                    "description": "链接类型 - 1:直接地址 2:商品ID",
+                    "type": "integer"
+                }
+            }
+        },
         "common.QueryNoticeRsp": {
             "type": "object",
             "required": [
@@ -14722,66 +14790,6 @@
                 }
             }
         },
-        "models.Szdz2imageconfig": {
-            "type": "object",
-            "required": [
-                "configid"
-            ],
-            "properties": {
-                "areauserid": {
-                    "description": "所属机构ID",
-                    "type": "integer"
-                },
-                "configid": {
-                    "description": "配置ID(SEQ_SZDZ2_IMAGECONFIG)",
-                    "type": "integer"
-                },
-                "createdate": {
-                    "description": "创建时间",
-                    "type": "string"
-                },
-                "creatorid": {
-                    "description": "创建人",
-                    "type": "integer"
-                },
-                "imagepath": {
-                    "description": "图片",
-                    "type": "string"
-                },
-                "imagetype": {
-                    "description": "类型 - 1:首页轮播(移动) 2:我的(移动)",
-                    "type": "integer"
-                },
-                "isshow": {
-                    "description": "是否展示 - 0:不展示 1:展示",
-                    "type": "integer"
-                },
-                "modifierid": {
-                    "description": "操作人",
-                    "type": "integer"
-                },
-                "sort": {
-                    "description": "排序",
-                    "type": "integer"
-                },
-                "title": {
-                    "description": "标题",
-                    "type": "string"
-                },
-                "updatedate": {
-                    "description": "修改时间",
-                    "type": "string"
-                },
-                "url": {
-                    "description": "链接(地址或商品ID)",
-                    "type": "string"
-                },
-                "urltype": {
-                    "description": "链接类型 - 1:直接地址 2:商品ID",
-                    "type": "integer"
-                }
-            }
-        },
         "models.Szdz3convertconfig": {
             "type": "object",
             "required": [

+ 51 - 45
docs/swagger.yaml

@@ -18,6 +18,56 @@ definitions:
         description: 总条数
         type: integer
     type: object
+  common.QueryImageConfigsRsp:
+    properties:
+      areauserid:
+        description: 所属机构ID
+        type: integer
+      configid:
+        description: 配置ID(SEQ_SZDZ2_IMAGECONFIG)
+        type: integer
+      createdate:
+        description: 创建时间
+        type: string
+      creatorid:
+        description: 创建人
+        type: integer
+      imagepath:
+        description: 图片
+        type: string
+      imagetype:
+        description: 类型 - 1:首页轮播(移动) 2:我的(移动)
+        type: integer
+      isshow:
+        description: 是否展示 - 0:不展示 1:展示
+        type: integer
+      marketid:
+        description: 市场ID
+        type: integer
+      modifierid:
+        description: 操作人
+        type: integer
+      sort:
+        description: 排序
+        type: integer
+      title:
+        description: 标题
+        type: string
+      trademode:
+        description: 交易模式
+        type: integer
+      updatedate:
+        description: 修改时间
+        type: string
+      url:
+        description: 链接(地址或商品ID)
+        type: string
+      urltype:
+        description: 链接类型 - 1:直接地址 2:商品ID
+        type: integer
+    required:
+    - configid
+    type: object
   common.QueryNoticeRsp:
     properties:
       auditoruserid:
@@ -6390,50 +6440,6 @@ definitions:
     - marketid
     - trademode
     type: object
-  models.Szdz2imageconfig:
-    properties:
-      areauserid:
-        description: 所属机构ID
-        type: integer
-      configid:
-        description: 配置ID(SEQ_SZDZ2_IMAGECONFIG)
-        type: integer
-      createdate:
-        description: 创建时间
-        type: string
-      creatorid:
-        description: 创建人
-        type: integer
-      imagepath:
-        description: 图片
-        type: string
-      imagetype:
-        description: 类型 - 1:首页轮播(移动) 2:我的(移动)
-        type: integer
-      isshow:
-        description: 是否展示 - 0:不展示 1:展示
-        type: integer
-      modifierid:
-        description: 操作人
-        type: integer
-      sort:
-        description: 排序
-        type: integer
-      title:
-        description: 标题
-        type: string
-      updatedate:
-        description: 修改时间
-        type: string
-      url:
-        description: 链接(地址或商品ID)
-        type: string
-      urltype:
-        description: 链接类型 - 1:直接地址 2:商品ID
-        type: integer
-    required:
-    - configid
-    type: object
   models.Szdz3convertconfig:
     properties:
       canin:
@@ -9225,7 +9231,7 @@ paths:
         "200":
           description: OK
           schema:
-            $ref: '#/definitions/models.Szdz2imageconfig'
+            $ref: '#/definitions/common.QueryImageConfigsRsp'
         "500":
           description: Internal Server Error
           schema: