Selaa lähdekoodia

增加获取所有枚举的接口

zhou.xiaoning 5 vuotta sitten
vanhempi
commit
fa61c1e872
7 muutettua tiedostoa jossa 262 lisäystä ja 20 poistoa
  1. 23 0
      controllers/common/common.go
  2. 4 4
      controllers/erms3/business.go
  3. 80 4
      docs/docs.go
  4. 80 4
      docs/swagger.json
  5. 57 4
      docs/swagger.yaml
  6. 16 4
      models/common.go
  7. 2 0
      routers/router.go

+ 23 - 0
controllers/common/common.go

@@ -113,3 +113,26 @@ func QueryImageConfigs(c *gin.Context) {
 	logger.GetLogger().Debugln("QueryImageConfigs successed: %v", imageConfigs)
 	appG.Response(http.StatusOK, e.SUCCESS, imageConfigs)
 }
+
+// GetAllEnums 获取所有枚举信息
+// @Summary 获取所有枚举信息
+// @Produce json
+// @Success 200 {object} models.Enumdicitem
+// @Failure 500 {object} app.Response
+// @Router /Common/GetAllEnums [get]
+// @Tags 通用服务
+func GetAllEnums(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	enums, err := models.GetEnums()
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("GetAllEnums failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 查询成功
+	// logger.GetLogger().Debugln("GetAllEnums successed: %v", imageConfigs)
+	appG.Response(http.StatusOK, e.SUCCESS, enums)
+}

+ 4 - 4
controllers/erms3/business.go

@@ -101,7 +101,7 @@ func QueryBusinessInfo(c *gin.Context) {
 	}
 
 	// 转换格式.
-	id2enum := make(map[uint64]models.Enumdicitem)
+	id2enum := make(map[int64]models.Enumdicitem)
 	for i := range enuminfo {
 		id2enum[enuminfo[i].Enumitemname] = enuminfo[i]
 	}
@@ -149,7 +149,7 @@ func QueryBusinessInfo(c *gin.Context) {
 		}
 
 		goodsinfo := id2goods[int32(asainfo[i].Deliverygoodsid)]
-		goodsunit := id2enum[uint64(goodsinfo.Goodsunitid)]
+		goodsunit := id2enum[int64(goodsinfo.Goodsunitid)]
 		detail := tradeinfo[asainfo[i].Asapplyid]
 		business := QueryBusinessInfoRsp{
 			BusinessID:      asainfo[i].Asapplyid,
@@ -198,7 +198,7 @@ func QueryBusinessInfo(c *gin.Context) {
 
 	for i := range wrrcontracts {
 		goodsinfo := id2goods[int32(wrrcontracts[i].Deliverygoodsid)]
-		goodsunit := id2enum[uint64(goodsinfo.Goodsunitid)]
+		goodsunit := id2enum[int64(goodsinfo.Goodsunitid)]
 		detail := wrtradeinfo[wrrcontracts[i].Wrrcontractid]
 		business := QueryBusinessInfoRsp{
 			BusinessID:      wrrcontracts[i].Wrrcontractid,
@@ -247,7 +247,7 @@ func QueryBusinessInfo(c *gin.Context) {
 
 	for i := range spotTradeBiz {
 		goodsinfo := id2goods[int32(spotTradeBiz[i].Deliverygoodsid)]
-		goodsunit := id2enum[uint64(goodsinfo.Goodsunitid)]
+		goodsunit := id2enum[int64(goodsinfo.Goodsunitid)]
 		detail := spottradeinfo[spotTradeBiz[i].Spottradeid]
 		business := QueryBusinessInfoRsp{
 			BusinessID:      spotTradeBiz[i].Spottradeid,

+ 80 - 4
docs/docs.go

@@ -20,7 +20,6 @@ var doc = `{
         "title": "{{.Title}}",
         "termsOfService": "http://muchinfo.cn",
         "contact": {},
-        "license": {},
         "version": "{{.Version}}"
     },
     "host": "{{.Host}}",
@@ -369,6 +368,31 @@ var doc = `{
                 }
             }
         },
+        "/Common/GetAllEnums": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用服务"
+                ],
+                "summary": "获取所有枚举信息",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.Enumdicitem"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Common/NoticeReaded": {
             "post": {
                 "security": [
@@ -3265,7 +3289,6 @@ var doc = `{
                 },
                 "province": {
                     "description": "省",
-                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -5322,7 +5345,6 @@ var doc = `{
                 },
                 "ouruser": {
                     "description": "我方账号",
-                    "type": "object",
                     "$ref": "#/definitions/erms3.CustomerInfo"
                 },
                 "warehouseinfos": {
@@ -5650,7 +5672,6 @@ var doc = `{
                 },
                 "province": {
                     "description": "省",
-                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -5708,6 +5729,61 @@ var doc = `{
                 }
             }
         },
+        "models.Enumdicitem": {
+            "type": "object",
+            "required": [
+                "autoid",
+                "enumdiccode",
+                "enumdicid",
+                "enumitemname"
+            ],
+            "properties": {
+                "autoid": {
+                    "description": "自增ID",
+                    "type": "integer"
+                },
+                "bankmappedvalue": {
+                    "description": "银行服务对应值",
+                    "type": "string"
+                },
+                "enumdiccode": {
+                    "description": "所属枚举代码",
+                    "type": "string"
+                },
+                "enumdicid": {
+                    "description": "所属枚举ID",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "枚举项名称",
+                    "type": "string"
+                },
+                "enumitemname": {
+                    "description": "枚举项值",
+                    "type": "integer"
+                },
+                "enumitemstatus": {
+                    "description": "枚举项状态 - 1.启用 2.不启用",
+                    "type": "integer"
+                },
+                "enumitemvalue": {
+                    "description": "通用值 - [币种通用简写]",
+                    "type": "string"
+                },
+                "param1": {
+                    "description": "参数1[币种:币种小数位]",
+                    "type": "string"
+                },
+                "param2": {
+                    "description": "参数1[币种:币种显示单位]",
+                    "type": "string"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                }
+            }
+        },
         "models.GoodsIDAndName": {
             "type": "object",
             "required": [

+ 80 - 4
docs/swagger.json

@@ -5,7 +5,6 @@
         "title": "MTP2.0 查询服务 API",
         "termsOfService": "http://muchinfo.cn",
         "contact": {},
-        "license": {},
         "version": "1.0"
     },
     "basePath": "/api",
@@ -353,6 +352,31 @@
                 }
             }
         },
+        "/Common/GetAllEnums": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用服务"
+                ],
+                "summary": "获取所有枚举信息",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.Enumdicitem"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Common/NoticeReaded": {
             "post": {
                 "security": [
@@ -3249,7 +3273,6 @@
                 },
                 "province": {
                     "description": "省",
-                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -5306,7 +5329,6 @@
                 },
                 "ouruser": {
                     "description": "我方账号",
-                    "type": "object",
                     "$ref": "#/definitions/erms3.CustomerInfo"
                 },
                 "warehouseinfos": {
@@ -5634,7 +5656,6 @@
                 },
                 "province": {
                     "description": "省",
-                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -5692,6 +5713,61 @@
                 }
             }
         },
+        "models.Enumdicitem": {
+            "type": "object",
+            "required": [
+                "autoid",
+                "enumdiccode",
+                "enumdicid",
+                "enumitemname"
+            ],
+            "properties": {
+                "autoid": {
+                    "description": "自增ID",
+                    "type": "integer"
+                },
+                "bankmappedvalue": {
+                    "description": "银行服务对应值",
+                    "type": "string"
+                },
+                "enumdiccode": {
+                    "description": "所属枚举代码",
+                    "type": "string"
+                },
+                "enumdicid": {
+                    "description": "所属枚举ID",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "枚举项名称",
+                    "type": "string"
+                },
+                "enumitemname": {
+                    "description": "枚举项值",
+                    "type": "integer"
+                },
+                "enumitemstatus": {
+                    "description": "枚举项状态 - 1.启用 2.不启用",
+                    "type": "integer"
+                },
+                "enumitemvalue": {
+                    "description": "通用值 - [币种通用简写]",
+                    "type": "string"
+                },
+                "param1": {
+                    "description": "参数1[币种:币种小数位]",
+                    "type": "string"
+                },
+                "param2": {
+                    "description": "参数1[币种:币种显示单位]",
+                    "type": "string"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                }
+            }
+        },
         "models.GoodsIDAndName": {
             "type": "object",
             "required": [

+ 57 - 4
docs/swagger.yaml

@@ -87,7 +87,6 @@ definitions:
       province:
         $ref: '#/definitions/models.Division'
         description: 省
-        type: object
     type: object
   common.QueryTableDefineRsp:
     properties:
@@ -1627,7 +1626,6 @@ definitions:
       ouruser:
         $ref: '#/definitions/erms3.CustomerInfo'
         description: 我方账号
-        type: object
       warehouseinfos:
         description: 仓库信息列表
         items:
@@ -1867,7 +1865,6 @@ definitions:
       province:
         $ref: '#/definitions/models.Division'
         description: 省
-        type: object
     type: object
   models.Division:
     properties:
@@ -1908,6 +1905,47 @@ definitions:
     - autoid
     - divisioncode
     type: object
+  models.Enumdicitem:
+    properties:
+      autoid:
+        description: 自增ID
+        type: integer
+      bankmappedvalue:
+        description: 银行服务对应值
+        type: string
+      enumdiccode:
+        description: 所属枚举代码
+        type: string
+      enumdicid:
+        description: 所属枚举ID
+        type: integer
+      enumdicname:
+        description: 枚举项名称
+        type: string
+      enumitemname:
+        description: 枚举项值
+        type: integer
+      enumitemstatus:
+        description: 枚举项状态 - 1.启用 2.不启用
+        type: integer
+      enumitemvalue:
+        description: 通用值 - [币种通用简写]
+        type: string
+      param1:
+        description: 参数1[币种:币种小数位]
+        type: string
+      param2:
+        description: 参数1[币种:币种显示单位]
+        type: string
+      remark:
+        description: 备注
+        type: string
+    required:
+    - autoid
+    - enumdiccode
+    - enumdicid
+    - enumitemname
+    type: object
   models.GoodsIDAndName:
     properties:
       goodscode:
@@ -4611,7 +4649,6 @@ definitions:
 info:
   contact: {}
   description: 新的查询服务,替代原通用查询服务。
-  license: {}
   termsOfService: http://muchinfo.cn
   title: MTP2.0 查询服务 API
   version: "1.0"
@@ -4830,6 +4867,22 @@ paths:
       summary: 查询远期订单信息
       tags:
       - 产能预售
+  /Common/GetAllEnums:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.Enumdicitem'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      summary: 获取所有枚举信息
+      tags:
+      - 通用服务
   /Common/NoticeReaded:
     post:
       parameters:

+ 16 - 4
models/common.go

@@ -77,12 +77,12 @@ func (Tablecolumnconfig) TableName() string {
 
 // Enumdicitem 枚举项字典表
 type Enumdicitem struct {
-	Autoid          uint64 `json:"autoid"  xorm:"'AUTOID'" binding:"required"`             // 自增ID
-	Enumdicid       uint32 `json:"enumdicid"  xorm:"'ENUMDICID'" binding:"required"`       // 所属枚举ID
+	Autoid          int64  `json:"autoid"  xorm:"'AUTOID'" binding:"required"`             // 自增ID
+	Enumdicid       int32  `json:"enumdicid"  xorm:"'ENUMDICID'" binding:"required"`       // 所属枚举ID
 	Enumdiccode     string `json:"enumdiccode"  xorm:"'ENUMDICCODE'" binding:"required"`   // 所属枚举代码
 	Enumdicname     string `json:"enumdicname"  xorm:"'ENUMDICNAME'"`                      // 枚举项名称
-	Enumitemname    uint64 `json:"enumitemname"  xorm:"'ENUMITEMNAME'" binding:"required"` // 枚举项值
-	Enumitemstatus  uint32 `json:"enumitemstatus"  xorm:"'ENUMITEMSTATUS'"`                // 枚举项状态 - 1.启用 2.不启用
+	Enumitemname    int64  `json:"enumitemname"  xorm:"'ENUMITEMNAME'" binding:"required"` // 枚举项值
+	Enumitemstatus  int32  `json:"enumitemstatus"  xorm:"'ENUMITEMSTATUS'"`                // 枚举项状态 - 1.启用 2.不启用
 	Bankmappedvalue string `json:"bankmappedvalue"  xorm:"'BANKMAPPEDVALUE'"`              // 银行服务对应值
 	Remark          string `json:"remark"  xorm:"'REMARK'"`                                // 备注
 	Enumitemvalue   string `json:"enumitemvalue"  xorm:"'ENUMITEMVALUE'"`                  // 通用值 - [币种通用简写]
@@ -574,6 +574,18 @@ func GetEnumDicItem(enumDicCode string, enumItemName int) ([]Enumdicitem, error)
 	return enumDicItems, nil
 }
 
+// GetEnums 获取所有枚举信息
+func GetEnums() ([]Enumdicitem, error) {
+	engine := db.GetEngine()
+
+	enumDicItems := make([]Enumdicitem, 0)
+	if err := engine.Find(&enumDicItems); err != nil {
+		return nil, err
+	}
+
+	return enumDicItems, nil
+}
+
 // GetProvincesAndCities 获取省市信息数组
 // 参数 provinceID int 省ID,选填
 // 返回 []Division 枚举信息数组

+ 2 - 0
routers/router.go

@@ -95,6 +95,8 @@ func InitRouter() *gin.Engine {
 		commonR.GET("/QueryProvincesAndCities", common.QueryProvincesAndCities)
 		// 查询轮播图配置信息
 		commonR.GET("/QueryImageConfigs", common.QueryImageConfigs)
+		// 获取所有枚举信息
+		commonR.GET("/GetAllEnums", common.GetAllEnums)
 		// 通知公告系统消息查询
 		commonR.Use(token.Auth()).GET("/QueryNotice", common.QueryNotice)
 		// 通知公告设置已读请求