Selaa lähdekoodia

增加“查询轮播图配置信息”接口

zhou.xiaoning 5 vuotta sitten
vanhempi
commit
56460f5461
6 muutettua tiedostoa jossa 250 lisäystä ja 0 poistoa
  1. 37 0
      controllers/common/common.go
  2. 65 0
      docs/docs.go
  3. 65 0
      docs/swagger.json
  4. 44 0
      docs/swagger.yaml
  5. 37 0
      models/common.go
  6. 2 0
      routers/router.go

+ 37 - 0
controllers/common/common.go

@@ -76,3 +76,40 @@ func QueryProvincesAndCities(c *gin.Context) {
 	logger.GetLogger().Debugln("QueryProvincesAndCities successed: %v", rst)
 	appG.Response(http.StatusOK, e.SUCCESS, rst)
 }
+
+// QueryImageConfigsReq 查询轮播图配置信息请求参数
+type QueryImageConfigsReq struct {
+	ImageType int `form:"imageType"`
+}
+
+// QueryImageConfigs 查询轮播图配置信息
+// @Summary 查询轮播图配置信息
+// @Produce json
+// @Param imageType query int false "类型 - 1:App首页轮播 2:我的"
+// @Success 200 {object} models.Szdz2imageconfig
+// @Failure 500 {object} app.Response
+// @Router /Common/QueryImageConfigs [get]
+// @Tags 通用服务
+func QueryImageConfigs(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QueryImageConfigsReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("QueryImageConfigs failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	imageConfigs, err := models.GetImageConfigs(req.ImageType)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QueryImageConfigs failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 查询成功
+	logger.GetLogger().Debugln("QueryImageConfigs successed: %v", imageConfigs)
+	appG.Response(http.StatusOK, e.SUCCESS, imageConfigs)
+}

+ 65 - 0
docs/docs.go

@@ -414,6 +414,39 @@ var doc = `{
                 }
             }
         },
+        "/Common/QueryImageConfigs": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用服务"
+                ],
+                "summary": "查询轮播图配置信息",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "类型 - 1:App首页轮播 2:我的",
+                        "name": "imageType",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.Szdz2imageconfig"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Common/QueryNotice": {
             "get": {
                 "security": [
@@ -5122,6 +5155,38 @@ var doc = `{
                 }
             }
         },
+        "models.Szdz2imageconfig": {
+            "type": "object",
+            "required": [
+                "configid"
+            ],
+            "properties": {
+                "configid": {
+                    "description": "配置ID(SEQ_SZDZ2_IMAGECONFIG)",
+                    "type": "integer"
+                },
+                "imagepath": {
+                    "description": "图片",
+                    "type": "string"
+                },
+                "imagetype": {
+                    "description": "类型 - 1:App首页轮播 2:我的",
+                    "type": "integer"
+                },
+                "sort": {
+                    "description": "排序",
+                    "type": "integer"
+                },
+                "title": {
+                    "description": "标题",
+                    "type": "string"
+                },
+                "url": {
+                    "description": "链接",
+                    "type": "string"
+                }
+            }
+        },
         "models.Szdz3convertconfig": {
             "type": "object",
             "required": [

+ 65 - 0
docs/swagger.json

@@ -398,6 +398,39 @@
                 }
             }
         },
+        "/Common/QueryImageConfigs": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用服务"
+                ],
+                "summary": "查询轮播图配置信息",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "类型 - 1:App首页轮播 2:我的",
+                        "name": "imageType",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.Szdz2imageconfig"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Common/QueryNotice": {
             "get": {
                 "security": [
@@ -5106,6 +5139,38 @@
                 }
             }
         },
+        "models.Szdz2imageconfig": {
+            "type": "object",
+            "required": [
+                "configid"
+            ],
+            "properties": {
+                "configid": {
+                    "description": "配置ID(SEQ_SZDZ2_IMAGECONFIG)",
+                    "type": "integer"
+                },
+                "imagepath": {
+                    "description": "图片",
+                    "type": "string"
+                },
+                "imagetype": {
+                    "description": "类型 - 1:App首页轮播 2:我的",
+                    "type": "integer"
+                },
+                "sort": {
+                    "description": "排序",
+                    "type": "integer"
+                },
+                "title": {
+                    "description": "标题",
+                    "type": "string"
+                },
+                "url": {
+                    "description": "链接",
+                    "type": "string"
+                }
+            }
+        },
         "models.Szdz3convertconfig": {
             "type": "object",
             "required": [

+ 44 - 0
docs/swagger.yaml

@@ -1980,6 +1980,29 @@ definitions:
     - marketid
     - trademode
     type: object
+  models.Szdz2imageconfig:
+    properties:
+      configid:
+        description: 配置ID(SEQ_SZDZ2_IMAGECONFIG)
+        type: integer
+      imagepath:
+        description: 图片
+        type: string
+      imagetype:
+        description: 类型 - 1:App首页轮播 2:我的
+        type: integer
+      sort:
+        description: 排序
+        type: integer
+      title:
+        description: 标题
+        type: string
+      url:
+        description: 链接
+        type: string
+    required:
+    - configid
+    type: object
   models.Szdz3convertconfig:
     properties:
       canin:
@@ -3842,6 +3865,27 @@ paths:
       summary: 通知公告设置已读请求
       tags:
       - 通用服务
+  /Common/QueryImageConfigs:
+    get:
+      parameters:
+      - description: 类型 - 1:App首页轮播 2:我的
+        in: query
+        name: imageType
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.Szdz2imageconfig'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      summary: 查询轮播图配置信息
+      tags:
+      - 通用服务
   /Common/QueryNotice:
     get:
       parameters:

+ 37 - 0
models/common.go

@@ -165,6 +165,26 @@ func (Division) TableName() string {
 	return "DIVISION"
 }
 
+// Szdz2imageconfig 广告配置表
+type Szdz2imageconfig struct {
+	Configid   int64     `json:"configid"  xorm:"'CONFIGID'" binding:"required"` // 配置ID(SEQ_SZDZ2_IMAGECONFIG)
+	Imagetype  int32     `json:"imagetype"  xorm:"'IMAGETYPE'"`                  // 类型 - 1:App首页轮播 2:我的
+	Title      string    `json:"title"  xorm:"'TITLE'"`                          // 标题
+	Imagepath  string    `json:"imagepath"  xorm:"'IMAGEPATH'"`                  // 图片
+	URL        string    `json:"url"  xorm:"'URL'"`                              // 链接
+	Sort       int64     `json:"sort"  xorm:"'SORT'"`                            // 排序
+	Isshow     int32     `json:"-"  xorm:"'ISSHOW'"`                             // 是否展示 - 0:不展示 1:展示
+	Createdate time.Time `json:"-"  xorm:"'CREATEDATE'"`                         // 创建时间
+	Creatorid  int64     `json:"-"  xorm:"'CREATORID'"`                          // 创建人
+	Updatedate time.Time `json:"-"  xorm:"'UPDATEDATE'"`                         // 修改时间
+	Modifierid int64     `json:"-"  xorm:"'MODIFIERID'"`                         // 操作人
+}
+
+// TableName is SZDZ2_IMAGECONFIG
+func (Szdz2imageconfig) TableName() string {
+	return "SZDZ2_IMAGECONFIG"
+}
+
 // QuotePrimaryMenu 报价牌一级分类菜单
 type QuotePrimaryMenu struct {
 	Index        int                  `json:"Index"`        // 序号
@@ -571,3 +591,20 @@ func GetProvincesAndCities(provinceID int) ([]Division, error) {
 
 	return divisions, nil
 }
+
+// GetImageConfigs 获取轮播图配置信息
+func GetImageConfigs(imageType int) ([]Szdz2imageconfig, error) {
+	engine := db.GetEngine()
+
+	imageConfigs := make([]Szdz2imageconfig, 0)
+	session := engine.Where("ISSHOW = 1")
+	if imageType > 0 {
+		session = session.And("IMAGETYPE = ?", imageType)
+	}
+	session = session.Asc("SORT")
+	if err := session.Find(&imageConfigs); err != nil {
+		return nil, err
+	}
+
+	return imageConfigs, nil
+}

+ 2 - 0
routers/router.go

@@ -91,6 +91,8 @@ func InitRouter() *gin.Engine {
 		commonR.GET("/QueryTableDefine", common.QueryTableDefine)
 		// 查询省市信息(不包括区)
 		commonR.GET("/QueryProvincesAndCities", common.QueryProvincesAndCities)
+		// 查询轮播图配置信息
+		commonR.GET("/QueryImageConfigs", common.QueryImageConfigs)
 		// 通知公告系统消息查询
 		commonR.Use(token.Auth()).GET("/QueryNotice", common.QueryNotice)
 		// 通知公告设置已读请求