Browse Source

修改“QueryTradePosition”接口参数

Zhou Xiaoning 5 years ago
parent
commit
199da7ed14
5 changed files with 21 additions and 20 deletions
  1. 1 1
      config/config.xml
  2. 8 7
      controllers/order/order.go
  3. 4 4
      docs/docs.go
  4. 4 4
      docs/swagger.json
  5. 4 4
      docs/swagger.yaml

+ 1 - 1
config/config.xml

@@ -2,7 +2,7 @@
 
 <Configuration xmlns:http="http://www.w3.org/2001/XMLSchema-instance">
     <WebSetting>
-        <ListenAddress value="0.0.0.0:8080"/>
+        <ListenAddress value="0.0.0.0:8081"/>
         <DebugMode value="1"/>
     </WebSetting>
 

+ 8 - 7
controllers/order/order.go

@@ -2,6 +2,7 @@ package order
 
 import (
 	"encoding/json"
+	"fmt"
 	"mtp2_if/db"
 	"mtp2_if/global/app"
 	"mtp2_if/global/e"
@@ -14,8 +15,8 @@ import (
 
 // QueryTradePositionReq 持仓汇总查询请求参数
 type QueryTradePositionReq struct {
-	AccountID int `form:"accountID" binding:"required"`
-	TradeMode int `form:"tradeMode"`
+	AccountID string `form:"accountID" binding:"required"`
+	TradeMode string `form:"tradeMode"`
 }
 
 // QueryTradePositionRsp 持仓汇总查询返回模型
@@ -50,8 +51,8 @@ type QueryTradePositionRsp struct {
 // @Summary 持仓汇总查询(合约市场)
 // @Produce json
 // @Security ApiKeyAuth
-// @Param accountID query int true "资金账户"
-// @Param tradeMode query int false "交易模式"
+// @Param accountID query string true "资金账户 - 格式:1,2,3"
+// @Param tradeMode query string false "交易模式 - 格式:1,2,3"
 // @Success 200 {object} QueryTradePositionRsp
 // @Failure 500 {object} app.Response
 // @Router /Order/QueryTradePosition [get]
@@ -88,9 +89,9 @@ func QueryTradePosition(c *gin.Context) {
 		Join("LEFT", "MARKET", "GOODS.MARKETID = MARKET.MARKETID").
 		Join("LEFT", "ENUMDICITEM", "GOODS.GOODUNITID = ENUMDICITEM.ENUMITEMNAME and ENUMDICITEM.ENUMDICCODE = 'goodsunit'").
 		Select("TRADEPOSITION.*, GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.CURRENCYID, GOODS.GOODUNITID, ENUMDICITEM.ENUMDICNAME as GOODUNIT, GOODS.AGREEUNIT, GOODS.DECIMALPLACE, MARKET.MARKETID, MARKET.TRADEMODE").
-		Where("TRADEPOSITION.ACCOUNTID = ?", req.AccountID)
-	if req.TradeMode != 0 {
-		s = s.And("MARKET.TRADEMODE = ?", req.TradeMode)
+		Where(fmt.Sprintf(`TRADEPOSITION.ACCOUNTID in (%s)`, req.AccountID))
+	if len(req.TradeMode) > 0 {
+		s = s.And(fmt.Sprintf(`MARKET.TRADEMODE in (%s)`, req.TradeMode))
 	}
 	if err := s.Find(&datas); err != nil {
 		// 查询失败

+ 4 - 4
docs/docs.go

@@ -631,15 +631,15 @@ var doc = `{
                 "summary": "持仓汇总查询(合约市场)",
                 "parameters": [
                     {
-                        "type": "integer",
-                        "description": "资金账户",
+                        "type": "string",
+                        "description": "资金账户 - 格式:1,2,3",
                         "name": "accountID",
                         "in": "query",
                         "required": true
                     },
                     {
-                        "type": "integer",
-                        "description": "交易模式",
+                        "type": "string",
+                        "description": "交易模式 - 格式:1,2,3",
                         "name": "tradeMode",
                         "in": "query"
                     }

+ 4 - 4
docs/swagger.json

@@ -615,15 +615,15 @@
                 "summary": "持仓汇总查询(合约市场)",
                 "parameters": [
                     {
-                        "type": "integer",
-                        "description": "资金账户",
+                        "type": "string",
+                        "description": "资金账户 - 格式:1,2,3",
                         "name": "accountID",
                         "in": "query",
                         "required": true
                     },
                     {
-                        "type": "integer",
-                        "description": "交易模式",
+                        "type": "string",
+                        "description": "交易模式 - 格式:1,2,3",
                         "name": "tradeMode",
                         "in": "query"
                     }

+ 4 - 4
docs/swagger.yaml

@@ -1680,15 +1680,15 @@ paths:
   /Order/QueryTradePosition:
     get:
       parameters:
-      - description: 资金账户
+      - description: 资金账户 - 格式:1,2,3
         in: query
         name: accountID
         required: true
-        type: integer
-      - description: 交易模式
+        type: string
+      - description: 交易模式 - 格式:1,2,3
         in: query
         name: tradeMode
-        type: integer
+        type: string
       produces:
       - application/json
       responses: