Browse Source

fix: 图库接口

hsun 3 years ago
parent
commit
d881c76363
6 changed files with 180 additions and 232 deletions
  1. 2 2
      controller/chart/chart_info.go
  2. 3 3
      controller/chart/my_chart.go
  3. 59 79
      docs/docs.go
  4. 59 79
      docs/swagger.json
  5. 52 65
      docs/swagger.yaml
  6. 5 4
      models/tables/chart_info/query.go

+ 2 - 2
controller/chart/chart_info.go

@@ -34,7 +34,7 @@ import (
 // @Param ClassifyId query string false "图表分类ID"
 // @Success 200 {object} chart_info.ChartInfoDetailResp
 // @failure 400 {string} string "图表详情获取失败"
-// @Router /chart/getChartInfoDetail [get]
+// @Router /my_chart/getChartInfoDetail [get]
 func GetChartInfoDetail(c *gin.Context)  {
 	// 图表ID
 	reqChartInfoId := c.DefaultQuery("ChartInfoId", "")
@@ -380,7 +380,7 @@ func RefreshChartInfo(c *gin.Context)  {
 // @Param data body chartInfoModel.SaveChartInfoReq true "请求参数"
 // @Success 200 {string} string "操作成功"
 // @failure 400 {string} string "操作失败"
-// @Router /chart/editChartInfo [post]
+// @Router /my_chart/editChartInfo [post]
 func EditChartInfo(c *gin.Context)  {
 	// 参数校验
 	var req chartInfoModel.SaveChartInfoReq

+ 3 - 3
controller/chart/my_chart.go

@@ -46,10 +46,10 @@ func GetMyChartChassify(c *gin.Context) {
 }
 
 
-// GetMyChartChassify 获取图表分类列表
+// GetMyChartList 获取图表列表
 // @Tags 图库模块
-// @Summary  获取图表分类
-// @Description 获取图表分类列表
+// @Summary  获取图表列表
+// @Description 获取图表列表
 // @Security ApiKeyAuth
 // @Param Authorization	header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
 // @Accept  json

+ 59 - 79
docs/docs.go

@@ -455,21 +455,21 @@ var doc = `{
                 }
             }
         },
-        "/chart/editChartInfo": {
-            "post": {
+        "/chart/getChartChassify": {
+            "get": {
                 "security": [
                     {
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "编辑图表信息",
+                "description": "获取图表分类列表",
                 "consumes": [
                     "application/json"
                 ],
                 "tags": [
                     "图库模块"
                 ],
-                "summary": "编辑图表信息",
+                "summary": "获取图表分类",
                 "parameters": [
                     {
                         "type": "string",
@@ -479,24 +479,21 @@ var doc = `{
                         "required": true
                     },
                     {
-                        "description": "请求参数",
-                        "name": "data",
-                        "in": "body",
-                        "required": true,
-                        "schema": {
-                            "$ref": "#/definitions/chart_info.SaveChartInfoReq"
-                        }
+                        "type": "string",
+                        "description": "分类名称关键词",
+                        "name": "Keywords",
+                        "in": "query"
                     }
                 ],
                 "responses": {
                     "200": {
-                        "description": "操作成功",
+                        "description": "OK",
                         "schema": {
-                            "type": "string"
+                            "$ref": "#/definitions/my_chart.MyChartClassifyListResp"
                         }
                     },
                     "400": {
-                        "description": "操作失败",
+                        "description": "分类列表获取失败",
                         "schema": {
                             "type": "string"
                         }
@@ -504,21 +501,21 @@ var doc = `{
                 }
             }
         },
-        "/chart/getChartChassify": {
+        "/chart/getChartList": {
             "get": {
                 "security": [
                     {
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "获取图表分类列表",
+                "description": "获取图表列表",
                 "consumes": [
                     "application/json"
                 ],
                 "tags": [
                     "图库模块"
                 ],
-                "summary": "获取图表分类",
+                "summary": "获取图表列表",
                 "parameters": [
                     {
                         "type": "string",
@@ -529,20 +526,41 @@ var doc = `{
                     },
                     {
                         "type": "string",
-                        "description": "分类名称关键词",
+                        "description": "图表名称关键词",
                         "name": "Keywords",
                         "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "图表分类ID",
+                        "name": "ClassifyId",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "当前页页码,从1开始",
+                        "name": "Page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页数据量",
+                        "name": "Limit",
+                        "in": "query"
                     }
                 ],
                 "responses": {
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/my_chart.MyChartClassifyListResp"
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/my_chart.MyChartList"
+                            }
                         }
                     },
                     "400": {
-                        "description": "分类列表获取失败",
+                        "description": "图库列表获取失败",
                         "schema": {
                             "type": "string"
                         }
@@ -550,21 +568,21 @@ var doc = `{
                 }
             }
         },
-        "/chart/getChartInfoDetail": {
-            "get": {
+        "/my_chart/editChartInfo": {
+            "post": {
                 "security": [
                     {
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "获取图表详情",
+                "description": "编辑图表信息",
                 "consumes": [
                     "application/json"
                 ],
                 "tags": [
                     "图库模块"
                 ],
-                "summary": "获取图表详情",
+                "summary": "编辑图表信息",
                 "parameters": [
                     {
                         "type": "string",
@@ -574,27 +592,24 @@ var doc = `{
                         "required": true
                     },
                     {
-                        "type": "string",
-                        "description": "时间段:1-00年至今; 2-10年至今; 3-15年至今; 4-21年至今; 5-指定区间; 6-指定年月至今; 7-18年至今; 8-19年至今; 9-20年至今",
-                        "name": "DateType",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "description": "图表分类ID",
-                        "name": "ClassifyId",
-                        "in": "query"
+                        "description": "请求参数",
+                        "name": "data",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/chart_info.SaveChartInfoReq"
+                        }
                     }
                 ],
                 "responses": {
                     "200": {
-                        "description": "OK",
+                        "description": "操作成功",
                         "schema": {
-                            "$ref": "#/definitions/chart_info.ChartInfoDetailResp"
+                            "type": "string"
                         }
                     },
                     "400": {
-                        "description": "图表详情获取失败",
+                        "description": "操作失败",
                         "schema": {
                             "type": "string"
                         }
@@ -602,21 +617,21 @@ var doc = `{
                 }
             }
         },
-        "/chart/getChartList": {
+        "/my_chart/getChartInfoDetail": {
             "get": {
                 "security": [
                     {
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "获取图表分类列表",
+                "description": "获取图表详情",
                 "consumes": [
                     "application/json"
                 ],
                 "tags": [
                     "图库模块"
                 ],
-                "summary": "获取图表分类",
+                "summary": "获取图表详情",
                 "parameters": [
                     {
                         "type": "string",
@@ -627,8 +642,8 @@ var doc = `{
                     },
                     {
                         "type": "string",
-                        "description": "图表名称关键词",
-                        "name": "Keywords",
+                        "description": "时间段:1-00年至今; 2-10年至今; 3-15年至今; 4-21年至今; 5-指定区间; 6-指定年月至今; 7-18年至今; 8-19年至今; 9-20年至今",
+                        "name": "DateType",
                         "in": "query"
                     },
                     {
@@ -636,32 +651,17 @@ var doc = `{
                         "description": "图表分类ID",
                         "name": "ClassifyId",
                         "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "当前页页码,从1开始",
-                        "name": "Page",
-                        "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "每页数据量",
-                        "name": "Limit",
-                        "in": "query"
                     }
                 ],
                 "responses": {
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "type": "array",
-                            "items": {
-                                "$ref": "#/definitions/my_chart.MyChartList"
-                            }
+                            "$ref": "#/definitions/chart_info.ChartInfoDetailResp"
                         }
                     },
                     "400": {
-                        "description": "图库列表获取失败",
+                        "description": "图表详情获取失败",
                         "schema": {
                             "type": "string"
                         }
@@ -1372,20 +1372,6 @@ var doc = `{
                 }
             }
         },
-        "chart_classify.ChartClassifyView": {
-            "type": "object",
-            "properties": {
-                "chartClassifyId": {
-                    "type": "integer"
-                },
-                "chartClassifyName": {
-                    "type": "string"
-                },
-                "parentId": {
-                    "type": "integer"
-                }
-            }
-        },
         "chart_edb_mapping.ChartEdbInfoMapping": {
             "type": "object",
             "properties": {
@@ -1490,12 +1476,6 @@ var doc = `{
                 "calendar": {
                     "type": "string"
                 },
-                "chartClassify": {
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/chart_classify.ChartClassifyView"
-                    }
-                },
                 "chartClassifyId": {
                     "type": "integer"
                 },

+ 59 - 79
docs/swagger.json

@@ -441,21 +441,21 @@
                 }
             }
         },
-        "/chart/editChartInfo": {
-            "post": {
+        "/chart/getChartChassify": {
+            "get": {
                 "security": [
                     {
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "编辑图表信息",
+                "description": "获取图表分类列表",
                 "consumes": [
                     "application/json"
                 ],
                 "tags": [
                     "图库模块"
                 ],
-                "summary": "编辑图表信息",
+                "summary": "获取图表分类",
                 "parameters": [
                     {
                         "type": "string",
@@ -465,24 +465,21 @@
                         "required": true
                     },
                     {
-                        "description": "请求参数",
-                        "name": "data",
-                        "in": "body",
-                        "required": true,
-                        "schema": {
-                            "$ref": "#/definitions/chart_info.SaveChartInfoReq"
-                        }
+                        "type": "string",
+                        "description": "分类名称关键词",
+                        "name": "Keywords",
+                        "in": "query"
                     }
                 ],
                 "responses": {
                     "200": {
-                        "description": "操作成功",
+                        "description": "OK",
                         "schema": {
-                            "type": "string"
+                            "$ref": "#/definitions/my_chart.MyChartClassifyListResp"
                         }
                     },
                     "400": {
-                        "description": "操作失败",
+                        "description": "分类列表获取失败",
                         "schema": {
                             "type": "string"
                         }
@@ -490,21 +487,21 @@
                 }
             }
         },
-        "/chart/getChartChassify": {
+        "/chart/getChartList": {
             "get": {
                 "security": [
                     {
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "获取图表分类列表",
+                "description": "获取图表列表",
                 "consumes": [
                     "application/json"
                 ],
                 "tags": [
                     "图库模块"
                 ],
-                "summary": "获取图表分类",
+                "summary": "获取图表列表",
                 "parameters": [
                     {
                         "type": "string",
@@ -515,20 +512,41 @@
                     },
                     {
                         "type": "string",
-                        "description": "分类名称关键词",
+                        "description": "图表名称关键词",
                         "name": "Keywords",
                         "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "图表分类ID",
+                        "name": "ClassifyId",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "当前页页码,从1开始",
+                        "name": "Page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页数据量",
+                        "name": "Limit",
+                        "in": "query"
                     }
                 ],
                 "responses": {
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/my_chart.MyChartClassifyListResp"
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/my_chart.MyChartList"
+                            }
                         }
                     },
                     "400": {
-                        "description": "分类列表获取失败",
+                        "description": "图库列表获取失败",
                         "schema": {
                             "type": "string"
                         }
@@ -536,21 +554,21 @@
                 }
             }
         },
-        "/chart/getChartInfoDetail": {
-            "get": {
+        "/my_chart/editChartInfo": {
+            "post": {
                 "security": [
                     {
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "获取图表详情",
+                "description": "编辑图表信息",
                 "consumes": [
                     "application/json"
                 ],
                 "tags": [
                     "图库模块"
                 ],
-                "summary": "获取图表详情",
+                "summary": "编辑图表信息",
                 "parameters": [
                     {
                         "type": "string",
@@ -560,27 +578,24 @@
                         "required": true
                     },
                     {
-                        "type": "string",
-                        "description": "时间段:1-00年至今; 2-10年至今; 3-15年至今; 4-21年至今; 5-指定区间; 6-指定年月至今; 7-18年至今; 8-19年至今; 9-20年至今",
-                        "name": "DateType",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "description": "图表分类ID",
-                        "name": "ClassifyId",
-                        "in": "query"
+                        "description": "请求参数",
+                        "name": "data",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/chart_info.SaveChartInfoReq"
+                        }
                     }
                 ],
                 "responses": {
                     "200": {
-                        "description": "OK",
+                        "description": "操作成功",
                         "schema": {
-                            "$ref": "#/definitions/chart_info.ChartInfoDetailResp"
+                            "type": "string"
                         }
                     },
                     "400": {
-                        "description": "图表详情获取失败",
+                        "description": "操作失败",
                         "schema": {
                             "type": "string"
                         }
@@ -588,21 +603,21 @@
                 }
             }
         },
-        "/chart/getChartList": {
+        "/my_chart/getChartInfoDetail": {
             "get": {
                 "security": [
                     {
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "获取图表分类列表",
+                "description": "获取图表详情",
                 "consumes": [
                     "application/json"
                 ],
                 "tags": [
                     "图库模块"
                 ],
-                "summary": "获取图表分类",
+                "summary": "获取图表详情",
                 "parameters": [
                     {
                         "type": "string",
@@ -613,8 +628,8 @@
                     },
                     {
                         "type": "string",
-                        "description": "图表名称关键词",
-                        "name": "Keywords",
+                        "description": "时间段:1-00年至今; 2-10年至今; 3-15年至今; 4-21年至今; 5-指定区间; 6-指定年月至今; 7-18年至今; 8-19年至今; 9-20年至今",
+                        "name": "DateType",
                         "in": "query"
                     },
                     {
@@ -622,32 +637,17 @@
                         "description": "图表分类ID",
                         "name": "ClassifyId",
                         "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "当前页页码,从1开始",
-                        "name": "Page",
-                        "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "每页数据量",
-                        "name": "Limit",
-                        "in": "query"
                     }
                 ],
                 "responses": {
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "type": "array",
-                            "items": {
-                                "$ref": "#/definitions/my_chart.MyChartList"
-                            }
+                            "$ref": "#/definitions/chart_info.ChartInfoDetailResp"
                         }
                     },
                     "400": {
-                        "description": "图库列表获取失败",
+                        "description": "图表详情获取失败",
                         "schema": {
                             "type": "string"
                         }
@@ -1358,20 +1358,6 @@
                 }
             }
         },
-        "chart_classify.ChartClassifyView": {
-            "type": "object",
-            "properties": {
-                "chartClassifyId": {
-                    "type": "integer"
-                },
-                "chartClassifyName": {
-                    "type": "string"
-                },
-                "parentId": {
-                    "type": "integer"
-                }
-            }
-        },
         "chart_edb_mapping.ChartEdbInfoMapping": {
             "type": "object",
             "properties": {
@@ -1476,12 +1462,6 @@
                 "calendar": {
                     "type": "string"
                 },
-                "chartClassify": {
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/chart_classify.ChartClassifyView"
-                    }
-                },
                 "chartClassifyId": {
                     "type": "integer"
                 },

+ 52 - 65
docs/swagger.yaml

@@ -136,15 +136,6 @@ definitions:
         description: 角色编码
         type: string
     type: object
-  chart_classify.ChartClassifyView:
-    properties:
-      chartClassifyId:
-        type: integer
-      chartClassifyName:
-        type: string
-      parentId:
-        type: integer
-    type: object
   chart_edb_mapping.ChartEdbInfoMapping:
     properties:
       chartColor:
@@ -214,10 +205,6 @@ definitions:
     properties:
       calendar:
         type: string
-      chartClassify:
-        items:
-          $ref: '#/definitions/chart_classify.ChartClassifyView'
-        type: array
       chartClassifyId:
         type: integer
       chartClassifyName:
@@ -924,141 +911,141 @@ paths:
       summary: 报名活动
       tags:
       - 活动模块
-  /chart/editChartInfo:
-    post:
+  /chart/getChartChassify:
+    get:
       consumes:
       - application/json
-      description: 编辑图表信息
+      description: 获取图表分类列表
       parameters:
       - description: Bearer 31a165baebe6dec616b1f8f3207b4273
         in: header
         name: Authorization
         required: true
         type: string
-      - description: 请求参数
-        in: body
-        name: data
-        required: true
-        schema:
-          $ref: '#/definitions/chart_info.SaveChartInfoReq'
+      - description: 分类名称关键词
+        in: query
+        name: Keywords
+        type: string
       responses:
         "200":
-          description: 操作成功
+          description: OK
           schema:
-            type: string
+            $ref: '#/definitions/my_chart.MyChartClassifyListResp'
         "400":
-          description: 操作失败
+          description: 分类列表获取失败
           schema:
             type: string
       security:
       - ApiKeyAuth: []
-      summary: 编辑图表信息
+      summary: 获取图表分类
       tags:
       - 图库模块
-  /chart/getChartChassify:
+  /chart/getChartList:
     get:
       consumes:
       - application/json
-      description: 获取图表分类列表
+      description: 获取图表列表
       parameters:
       - description: Bearer 31a165baebe6dec616b1f8f3207b4273
         in: header
         name: Authorization
         required: true
         type: string
-      - description: 分类名称关键词
+      - description: 图表名称关键词
         in: query
         name: Keywords
         type: string
+      - description: 图表分类ID
+        in: query
+        name: ClassifyId
+        type: string
+      - description: 当前页页码,从1开始
+        in: query
+        name: Page
+        type: integer
+      - description: 每页数据量
+        in: query
+        name: Limit
+        type: integer
       responses:
         "200":
           description: OK
           schema:
-            $ref: '#/definitions/my_chart.MyChartClassifyListResp'
+            items:
+              $ref: '#/definitions/my_chart.MyChartList'
+            type: array
         "400":
-          description: 分类列表获取失败
+          description: 图库列表获取失败
           schema:
             type: string
       security:
       - ApiKeyAuth: []
-      summary: 获取图表分类
+      summary: 获取图表列表
       tags:
       - 图库模块
-  /chart/getChartInfoDetail:
-    get:
+  /my_chart/editChartInfo:
+    post:
       consumes:
       - application/json
-      description: 获取图表详情
+      description: 编辑图表信息
       parameters:
       - description: Bearer 31a165baebe6dec616b1f8f3207b4273
         in: header
         name: Authorization
         required: true
         type: string
-      - description: 时间段:1-00年至今; 2-10年至今; 3-15年至今; 4-21年至今; 5-指定区间; 6-指定年月至今; 7-18年至今;
-          8-19年至今; 9-20年至今
-        in: query
-        name: DateType
-        type: string
-      - description: 图表分类ID
-        in: query
-        name: ClassifyId
-        type: string
+      - description: 请求参数
+        in: body
+        name: data
+        required: true
+        schema:
+          $ref: '#/definitions/chart_info.SaveChartInfoReq'
       responses:
         "200":
-          description: OK
+          description: 操作成功
           schema:
-            $ref: '#/definitions/chart_info.ChartInfoDetailResp'
+            type: string
         "400":
-          description: 图表详情获取失败
+          description: 操作失败
           schema:
             type: string
       security:
       - ApiKeyAuth: []
-      summary: 获取图表详情
+      summary: 编辑图表信息
       tags:
       - 图库模块
-  /chart/getChartList:
+  /my_chart/getChartInfoDetail:
     get:
       consumes:
       - application/json
-      description: 获取图表分类列表
+      description: 获取图表详情
       parameters:
       - description: Bearer 31a165baebe6dec616b1f8f3207b4273
         in: header
         name: Authorization
         required: true
         type: string
-      - description: 图表名称关键词
+      - description: 时间段:1-00年至今; 2-10年至今; 3-15年至今; 4-21年至今; 5-指定区间; 6-指定年月至今; 7-18年至今;
+          8-19年至今; 9-20年至今
         in: query
-        name: Keywords
+        name: DateType
         type: string
       - description: 图表分类ID
         in: query
         name: ClassifyId
         type: string
-      - description: 当前页页码,从1开始
-        in: query
-        name: Page
-        type: integer
-      - description: 每页数据量
-        in: query
-        name: Limit
-        type: integer
       responses:
         "200":
           description: OK
           schema:
-            items:
-              $ref: '#/definitions/my_chart.MyChartList'
-            type: array
+            $ref: '#/definitions/chart_info.ChartInfoDetailResp'
         "400":
-          description: 图库列表获取失败
+          description: 图表详情获取失败
           schema:
             type: string
       security:
       - ApiKeyAuth: []
-      summary: 获取图表分类
+      summary: 获取图表详情
       tags:
       - 图库模块
   /public/get_apply_variety_list:

+ 5 - 4
models/tables/chart_info/query.go

@@ -2,7 +2,6 @@ package chart_info
 
 import (
 	"hongze/hongze_yb/global"
-	"hongze/hongze_yb/models/tables/chart_classify"
 	"time"
 )
 
@@ -35,7 +34,7 @@ type ChartInfoView struct {
 	LeftMax           string `description:"图表左侧最大值"`
 	RightMin          string `description:"图表右侧最小值"`
 	RightMax          string `description:"图表右侧最大值"`
-	ChartClassify     []*chart_classify.ChartClassifyView
+	//ChartClassify     []*chart_classify.ChartClassifyView
 }
 
 type SaveChartInfoReq struct {
@@ -69,12 +68,14 @@ type ChartSaveItem struct {
 
 // GetChartInfoViewById 通过Id获取图表展示信息
 func GetChartInfoViewById(chartInfoId int) (item *ChartInfoView, err error) {
-	err = global.MYSQL["data"].Where("chart_info_id = ?", chartInfoId).First(&item).Error
+	sql := `SELECT * FROM chart_info WHERE chart_info_id = ? `
+	err = global.MYSQL["data"].Raw(sql, chartInfoId).Scan(&item).Error
+	//err = global.MYSQL["data"].Model(ChartInfo{}).Where("chart_info_id = ?", chartInfoId).First(&item).Error
 	return
 }
 
 // GetChartInfoViewById 通过ID获取图表数据库信息
 func GetChartInfoById(chartInfoId int) (item *ChartInfo, err error) {
-	err = global.MYSQL["data"].Where("chart_info_id = ?", chartInfoId).First(&item).Error
+	err = global.MYSQL["data"].Model(ChartInfo{}).Where("chart_info_id = ?", chartInfoId).First(&item).Error
 	return
 }