Переглянути джерело

增加查品牌和型号接口

zou.yingbin 4 роки тому
батько
коміт
2e970a6c59
6 змінених файлів з 660 додано та 0 видалено
  1. 52 0
      controllers/ermcp/qryBrandModel.go
  2. 190 0
      docs/docs.go
  3. 190 0
      docs/swagger.json
  4. 130 0
      docs/swagger.yaml
  5. 96 0
      models/ermcpBrandModel.go
  6. 2 0
      routers/router.go

+ 52 - 0
controllers/ermcp/qryBrandModel.go

@@ -0,0 +1,52 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/3/15 10:41
+* @Modify  : 2021/3/15 10:41
+ */
+
+package ermcp
+
+import (
+	"github.com/gin-gonic/gin"
+	"mtp2_if/global/app"
+	"mtp2_if/models"
+)
+
+// QueryBrandModelReq 查询品牌和型号请求
+type QueryBrandModelReq struct {
+	UserId int64 `form:"userid" binding:"required"` // 用户ID
+}
+
+// QueryGoodsBrand
+// @Summary 查询商品品牌
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Success 200 {array} models.ErmcpGoodsBrand
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryGoodsBrand [get]
+// @Tags 企业风险管理(app)
+func QueryGoodsBrand(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QueryBrandModelReq{}
+	a.DoBindReq(&req)
+	m := models.ErmcpGoodsBrand{AREAUSERID: req.UserId}
+	a.DoGetDataEx(&m)
+}
+
+// QueryGoodsModel
+// @Summary 查询商品型号
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Success 200 {array} models.ErmcpGoodsModel
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryGoodsModel [get]
+// @Tags 企业风险管理(app)
+func QueryGoodsModel(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QueryBrandModelReq{}
+	a.DoBindReq(&req)
+	m := models.ErmcpGoodsModel{AREAUSERID: req.UserId}
+	a.DoGetDataEx(&m)
+}

+ 190 - 0
docs/docs.go

@@ -2559,6 +2559,90 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp/QueryGoodsBrand": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询商品品牌",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpGoodsBrand"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryGoodsModel": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询商品型号",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpGoodsModel"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QueryHedgePlan": {
             "get": {
                 "security": [
@@ -11496,6 +11580,112 @@ var doc = `{
                 }
             }
         },
+        "models.ErmcpGoodsBrand": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "brandid": {
+                    "description": "BrandID(SEQ_SPOTGOODSBRAND)",
+                    "type": "integer"
+                },
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "creatorsrc": {
+                    "description": "创建人来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "isvalid": {
+                    "description": "是否有效 - 0:无效 1:有效",
+                    "type": "integer"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "updatorid": {
+                    "description": "更新人",
+                    "type": "integer"
+                },
+                "updatorsrc": {
+                    "description": "更新人来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpGoodsModel": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "creatorsrc": {
+                    "description": "创建人来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "isvalid": {
+                    "description": "是否有效 - 0:无效 1:有效",
+                    "type": "integer"
+                },
+                "modelid": {
+                    "description": "ModelID(SEQ_SPOTGOODSMODEL)",
+                    "type": "integer"
+                },
+                "modelname": {
+                    "description": "型号名称",
+                    "type": "string"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "updatorid": {
+                    "description": "更新人",
+                    "type": "integer"
+                },
+                "updatorsrc": {
+                    "description": "更新人来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.ErmcpHedgePlan": {
             "type": "object",
             "properties": {

+ 190 - 0
docs/swagger.json

@@ -2543,6 +2543,90 @@
                 }
             }
         },
+        "/Ermcp/QueryGoodsBrand": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询商品品牌",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpGoodsBrand"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryGoodsModel": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询商品型号",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpGoodsModel"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QueryHedgePlan": {
             "get": {
                 "security": [
@@ -11480,6 +11564,112 @@
                 }
             }
         },
+        "models.ErmcpGoodsBrand": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "brandid": {
+                    "description": "BrandID(SEQ_SPOTGOODSBRAND)",
+                    "type": "integer"
+                },
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "creatorsrc": {
+                    "description": "创建人来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "isvalid": {
+                    "description": "是否有效 - 0:无效 1:有效",
+                    "type": "integer"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "updatorid": {
+                    "description": "更新人",
+                    "type": "integer"
+                },
+                "updatorsrc": {
+                    "description": "更新人来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpGoodsModel": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "creatorsrc": {
+                    "description": "创建人来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "isvalid": {
+                    "description": "是否有效 - 0:无效 1:有效",
+                    "type": "integer"
+                },
+                "modelid": {
+                    "description": "ModelID(SEQ_SPOTGOODSMODEL)",
+                    "type": "integer"
+                },
+                "modelname": {
+                    "description": "型号名称",
+                    "type": "string"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "updatorid": {
+                    "description": "更新人",
+                    "type": "integer"
+                },
+                "updatorsrc": {
+                    "description": "更新人来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.ErmcpHedgePlan": {
             "type": "object",
             "properties": {

+ 130 - 0
docs/swagger.yaml

@@ -3460,6 +3460,84 @@ definitions:
         description: 源品种单位名称
         type: string
     type: object
+  models.ErmcpGoodsBrand:
+    properties:
+      areauserid:
+        description: 所属机构
+        type: integer
+      brandid:
+        description: BrandID(SEQ_SPOTGOODSBRAND)
+        type: integer
+      brandname:
+        description: 品牌名称
+        type: string
+      createtime:
+        description: 创建时间
+        type: string
+      creatorid:
+        description: 创建人
+        type: integer
+      creatorsrc:
+        description: 创建人来源 - 1:管理端 2:终端
+        type: integer
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      isvalid:
+        description: 是否有效 - 0:无效 1:有效
+        type: integer
+      updatetime:
+        description: 更新时间
+        type: string
+      updatorid:
+        description: 更新人
+        type: integer
+      updatorsrc:
+        description: 更新人来源 - 1:管理端 2:终端
+        type: integer
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+    type: object
+  models.ErmcpGoodsModel:
+    properties:
+      areauserid:
+        description: 所属机构
+        type: integer
+      createtime:
+        description: 创建时间
+        type: string
+      creatorid:
+        description: 创建人
+        type: integer
+      creatorsrc:
+        description: 创建人来源 - 1:管理端 2:终端
+        type: integer
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      isvalid:
+        description: 是否有效 - 0:无效 1:有效
+        type: integer
+      modelid:
+        description: ModelID(SEQ_SPOTGOODSMODEL)
+        type: integer
+      modelname:
+        description: 型号名称
+        type: string
+      updatetime:
+        description: 更新时间
+        type: string
+      updatorid:
+        description: 更新人
+        type: integer
+      updatorsrc:
+        description: 更新人来源 - 1:管理端 2:终端
+        type: integer
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+    type: object
   models.ErmcpHedgePlan:
     properties:
       areauserid:
@@ -11157,6 +11235,58 @@ paths:
       summary: 查询期货品种配置(菜单:商品信息/期货品种)
       tags:
       - 企业风险管理(app)
+  /Ermcp/QueryGoodsBrand:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ErmcpGoodsBrand'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询商品品牌
+      tags:
+      - 企业风险管理(app)
+  /Ermcp/QueryGoodsModel:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ErmcpGoodsModel'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询商品型号
+      tags:
+      - 企业风险管理(app)
   /Ermcp/QueryHedgePlan:
     get:
       parameters:

+ 96 - 0
models/ermcpBrandModel.go

@@ -0,0 +1,96 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/3/15 10:27
+* @Modify  : 2021/3/15 10:27
+ */
+
+package models
+
+import (
+	"mtp2_if/db"
+	"mtp2_if/utils"
+)
+
+// ErmcpGoodsBrand 品牌
+type ErmcpGoodsBrand struct {
+	BRANDID         int32  `json:"brandid"  xorm:"'BRANDID'"`                 // BrandID(SEQ_SPOTGOODSBRAND)
+	BRANDNAME       string `json:"brandname"  xorm:"'BRANDNAME'"`             // 品牌名称
+	WRSTANDARDID    int64  `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`       // 现货商品ID
+	DELIVERYGOODSID int32  `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"` // 现货品种ID
+	AREAUSERID      int64  `json:"areauserid"  xorm:"'AREAUSERID'"`           // 所属机构
+	ISVALID         int32  `json:"isvalid"  xorm:"'ISVALID'"`                 // 是否有效 - 0:无效 1:有效
+	CREATORSRC      int32  `json:"creatorsrc"  xorm:"'CREATORSRC'"`           // 创建人来源 - 1:管理端 2:终端
+	CREATORID       int64  `json:"creatorid"  xorm:"'CREATORID'"`             // 创建人
+	CREATETIME      string `json:"createtime"  xorm:"'CREATETIME'"`           // 创建时间
+	UPDATORSRC      int32  `json:"updatorsrc"  xorm:"'UPDATORSRC'"`           // 更新人来源 - 1:管理端 2:终端
+	UPDATORID       int64  `json:"updatorid"  xorm:"'UPDATORID'"`             // 更新人
+	UPDATETIME      string `json:"updatetime"  xorm:"'UPDATETIME'"`           // 更新时间
+}
+
+func (r *ErmcpGoodsBrand) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT t.BRANDID," +
+		"       t.BRANDNAME," +
+		"       t.WRSTANDARDID," +
+		"       t.DELIVERYGOODSID," +
+		"       t.AREAUSERID," +
+		"       t.ISVALID," +
+		"       t.CREATORSRC," +
+		"       t.CREATORID," +
+		"       to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME," +
+		"       t.UPDATORSRC," +
+		"       t.UPDATORID," +
+		"       to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME" +
+		"  FROM SPOTGOODSBRAND t" +
+		" WHERE 1 = 1"
+	sqlId.And("t.AREAUSERID", r.AREAUSERID)
+	return sqlId.String()
+}
+
+// GetDataEx 获取品牌数据
+func (r *ErmcpGoodsBrand) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpGoodsBrand, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	return sData, err
+}
+
+// ErmcpGoodsModel 商品型号
+type ErmcpGoodsModel struct {
+	MODELID         int32  `json:"modelid"  xorm:"'MODELID'"`                 // ModelID(SEQ_SPOTGOODSMODEL)
+	MODELNAME       string `json:"modelname"  xorm:"'MODELNAME'"`             // 型号名称
+	WRSTANDARDID    int64  `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`       // 现货商品ID
+	DELIVERYGOODSID int32  `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"` // 现货品种ID
+	AREAUSERID      int64  `json:"areauserid"  xorm:"'AREAUSERID'"`           // 所属机构
+	ISVALID         int32  `json:"isvalid"  xorm:"'ISVALID'"`                 // 是否有效 - 0:无效 1:有效
+	CREATORSRC      int32  `json:"creatorsrc"  xorm:"'CREATORSRC'"`           // 创建人来源 - 1:管理端 2:终端
+	CREATORID       int64  `json:"creatorid"  xorm:"'CREATORID'"`             // 创建人
+	CREATETIME      string `json:"createtime"  xorm:"'CREATETIME'"`           // 创建时间
+	UPDATORSRC      int32  `json:"updatorsrc"  xorm:"'UPDATORSRC'"`           // 更新人来源 - 1:管理端 2:终端
+	UPDATORID       int64  `json:"updatorid"  xorm:"'UPDATORID'"`             // 更新人
+	UPDATETIME      string `json:"updatetime"  xorm:"'UPDATETIME'"`           // 更新时间
+}
+
+func (r *ErmcpGoodsModel) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT t.MODELID," +
+		"       t.MODELNAME," +
+		"       t.WRSTANDARDID," +
+		"       t.DELIVERYGOODSID," +
+		"       t.AREAUSERID," +
+		"       t.ISVALID," +
+		"       t.CREATORSRC," +
+		"       t.CREATORID," +
+		"       to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME," +
+		"       t.UPDATORSRC," +
+		"       t.UPDATORID," +
+		"       to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME" +
+		"  FROM SPOTGOODSMODEL t" +
+		" WHERE 1 = 1"
+	sqlId.And("t.AREAUSERID", r.AREAUSERID)
+	return sqlId.String()
+}
+
+// GetDataEx 商品型号
+func (r *ErmcpGoodsModel) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpGoodsModel, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	return sData, err
+}

+ 2 - 0
routers/router.go

@@ -367,6 +367,8 @@ func InitRouter() *gin.Engine {
 		ermcpR.GET("/QueryAreaStock", ermcp.QueryAreaStock)
 		ermcpR.GET("/QueryAreaStockReport", ermcp.QueryAreaStockReport)
 		ermcpR.GET("/QueryAreaStockReportDetail", ermcp.QueryAreaStockReportDetail)
+		ermcpR.GET("/QueryGoodsBrand", ermcp.QueryGoodsBrand)
+		ermcpR.GET("/QueryGoodsModel", ermcp.QueryGoodsModel)
 
 		// 期货相关
 		// 查询企业风管期货商品信息