Explorar o código

增加仓单贸易接口

Simon Zhou %!s(int64=5) %!d(string=hai) anos
pai
achega
8e73128541
Modificáronse 6 ficheiros con 145 adicións e 0 borrados
  1. 1 0
      controllers/cptrade/cpTrade.go
  2. 59 0
      controllers/wrtrade/wrTrade.go
  3. 30 0
      docs/docs.go
  4. 30 0
      docs/swagger.json
  5. 18 0
      docs/swagger.yaml
  6. 7 0
      routers/router.go

+ 1 - 0
controllers/cptrade/cpTrade.go

@@ -1,3 +1,4 @@
+// Package cptrade 产能预售
 package cptrade
 
 import (

+ 59 - 0
controllers/wrtrade/wrTrade.go

@@ -0,0 +1,59 @@
+// Package wrtrade 仓单贸易
+package wrtrade
+
+import (
+	"mtp2_if/db"
+	"mtp2_if/global/app"
+	"mtp2_if/global/e"
+	"mtp2_if/logger"
+	"net/http"
+
+	"github.com/gin-gonic/gin"
+)
+
+// Deliverygoods 现货品种表
+type Deliverygoods struct {
+	Deliverygoodsid   int64   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'" binding:"required"`     // 交割商品ID(SEQ_DELIVERYGOODS)
+	Deliverygoodscode string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'" binding:"required"` // 交割商品代码
+	Deliverygoodsname string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`                    // 交割商品名称
+	Goodsunitid       int64   `json:"goodsunitid"  xorm:"'GOODSUNITID'"`                                // 交割商品单位ID
+	Deliverygoodstype int64   `json:"deliverygoodstype"  xorm:"'DELIVERYGOODSTYPE'"`                    // 交割商品类型: 1-整装不拆分 2-散装记录明细 3:整装拆分 4:散装不记录明细
+	Standardqty       int64   `json:"standardqty"  xorm:"'STANDARDQTY'"`                                // 标准数量(库位数量) [标准品特有]
+	Standardqtyrange  float64 `json:"standardqtyrange"  xorm:"'STANDARDQTYRANGE'"`                      // 标准数量偏差范围 [标准品特有]
+	Issplit           int64   `json:"issplit"  xorm:"'ISSPLIT'"`                                        // 是否拆分 - 0:不拆分 1:拆分 [整装]   0:不记录明细 1:记录明细 [散货] - 作废整装时不拆分,则标准数量=合约单位;拆分时标准数量为合约单位的整数倍;整装时必须记录明细表数据
+	Agreeunit         int64   `json:"agreeunit"  xorm:"'AGREEUNIT'"`                                    // 合约单位[散货时默认为1, 整装时默认为标准数量]
+	Qtydecimalplace   int64   `json:"qtydecimalplace"  xorm:"'QTYDECIMALPLACE'"`                        // 成交量小数位
+	Categoryid        int64   `json:"categoryid"  xorm:"'CATEGORYID'"`                                  // 类别ID(SEQ_WRCATEGORY)
+}
+
+// TableName is DELIVERYGOODS
+func (Deliverygoods) TableName() string {
+	return "DELIVERYGOODS"
+}
+
+// GetAllDeliveryGoods 获取带仓单分类的种类信息
+// @Summary 获取带仓单分类的种类信息
+// @Produce json
+// @Security ApiKeyAuth
+// @Success 200 {object} app.Response
+// @Failure 500 {object} app.Response
+// @Router /WRTrade/GetAllDeliveryGoods [get]
+// @Tags 仓单贸易
+func GetAllDeliveryGoods(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	engine := db.GetEngine()
+
+	// 获取品种(交割商品)信息
+	deliveryGoodses := make([]Deliverygoods, 0)
+	if err := engine.Where("IsValid=1").And("categoryid<>0").Find(&deliveryGoodses); err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("GetAllDeliveryGoods failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 获取与品种相关的所有仓单分类信息
+
+	appG.Response(http.StatusOK, e.SUCCESS, deliveryGoodses)
+}

+ 30 - 0
docs/docs.go

@@ -76,6 +76,36 @@ var doc = `{
                     }
                 }
             }
+        },
+        "/WRTrade/GetAllDeliveryGoods": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易"
+                ],
+                "summary": "获取带仓单分类的种类信息",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
         }
     },
     "definitions": {

+ 30 - 0
docs/swagger.json

@@ -60,6 +60,36 @@
                     }
                 }
             }
+        },
+        "/WRTrade/GetAllDeliveryGoods": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易"
+                ],
+                "summary": "获取带仓单分类的种类信息",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
         }
     },
     "definitions": {

+ 18 - 0
docs/swagger.yaml

@@ -105,6 +105,24 @@ paths:
       summary: 查询产能预售申请表信息
       tags:
       - 产能预售
+  /WRTrade/GetAllDeliveryGoods:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/app.Response'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 获取带仓单分类的种类信息
+      tags:
+      - 仓单贸易
 securityDefinitions:
   ApiKeyAuth:
     in: header

+ 7 - 0
routers/router.go

@@ -2,6 +2,7 @@ package routers
 
 import (
 	"mtp2_if/controllers/cptrade"
+	"mtp2_if/controllers/wrtrade"
 	"mtp2_if/logger"
 	"mtp2_if/token"
 	"time"
@@ -28,6 +29,12 @@ func InitRouter() *gin.Engine {
 	// 路由分组
 	apiR := r.Group("/api")
 	apiR.Use(token.Auth())
+	// ************************ 仓单贸易 ************************
+	wrTradeR := apiR.Group("WRTrade")
+	wrTradeR.Use()
+	{
+		wrTradeR.GET("/GetAllDeliveryGoods", wrtrade.GetAllDeliveryGoods)
+	}
 	// ************************ 产能预售 ************************
 	cpTradeR := apiR.Group("CPTrade")
 	cpTradeR.Use()