Procházet zdrojové kódy

增加查询指数详情(价格走势)接口

zou.yingbin před 4 roky
rodič
revize
db55f3dfba
6 změnil soubory, kde provedl 235 přidání a 0 odebrání
  1. 18 0
      controllers/wrTrade2/qryWrTrade.go
  2. 66 0
      docs/docs.go
  3. 66 0
      docs/swagger.json
  4. 43 0
      docs/swagger.yaml
  5. 41 0
      models/wrTrade2.go
  6. 1 0
      routers/router.go

+ 18 - 0
controllers/wrTrade2/qryWrTrade.go

@@ -682,3 +682,21 @@ func QuerySpotGroupTradeSum(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QuerySpotGroupTradeSumDetail
+// @Summary 查询指数详细(价格走势图)
+// @Description 查询的结果将会按日期 从小到大 排序
+// @Produce json
+// @Security ApiKeyAuth
+// @param deliverygoodsid query int true "现货商品id"
+// @param lastnum query int false "查询最新多少条记录(如不填写此项, 默认查30条)"
+// @Success 200 {array} models.WrSpotGroupTradeSumDetail
+// @Failure 500 {object} app.Response
+// @Router /WrTrade2/QuerySpotGroupTradeSumDetail [get]
+// @Tags 仓单贸易v2
+func QuerySpotGroupTradeSumDetail(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.WrSpotGroupTradeSumDetail{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 66 - 0
docs/docs.go

@@ -12642,6 +12642,55 @@ var doc = `{
                 }
             }
         },
+        "/WrTrade2/QuerySpotGroupTradeSumDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "查询的结果将会按日期 从小到大 排序",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询指数详细(价格走势图)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "现货商品id",
+                        "name": "deliverygoodsid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询最新多少条记录(如不填写此项, 默认查30条)",
+                        "name": "lastnum",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrSpotGroupTradeSumDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryWrAverageTradePrice": {
             "get": {
                 "security": [
@@ -36340,6 +36389,23 @@ var doc = `{
                 }
             }
         },
+        "models.WrSpotGroupTradeSumDetail": {
+            "type": "object",
+            "properties": {
+                "deliverygoodsid": {
+                    "description": "现货商品id",
+                    "type": "integer"
+                },
+                "price": {
+                    "description": "价格",
+                    "type": "number"
+                },
+                "reckondate": {
+                    "description": "日期(yyymmdd, 如:20211031)",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrSpotGroupTradeSumEx": {
             "type": "object",
             "properties": {

+ 66 - 0
docs/swagger.json

@@ -12626,6 +12626,55 @@
                 }
             }
         },
+        "/WrTrade2/QuerySpotGroupTradeSumDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "查询的结果将会按日期 从小到大 排序",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询指数详细(价格走势图)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "现货商品id",
+                        "name": "deliverygoodsid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询最新多少条记录(如不填写此项, 默认查30条)",
+                        "name": "lastnum",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrSpotGroupTradeSumDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryWrAverageTradePrice": {
             "get": {
                 "security": [
@@ -36324,6 +36373,23 @@
                 }
             }
         },
+        "models.WrSpotGroupTradeSumDetail": {
+            "type": "object",
+            "properties": {
+                "deliverygoodsid": {
+                    "description": "现货商品id",
+                    "type": "integer"
+                },
+                "price": {
+                    "description": "价格",
+                    "type": "number"
+                },
+                "reckondate": {
+                    "description": "日期(yyymmdd, 如:20211031)",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrSpotGroupTradeSumEx": {
             "type": "object",
             "properties": {

+ 43 - 0
docs/swagger.yaml

@@ -16595,6 +16595,18 @@ definitions:
         description: 涨幅(已格式化, 直接显示即可)
         type: string
     type: object
+  models.WrSpotGroupTradeSumDetail:
+    properties:
+      deliverygoodsid:
+        description: 现货商品id
+        type: integer
+      price:
+        description: 价格
+        type: number
+      reckondate:
+        description: 日期(yyymmdd, 如:20211031)
+        type: string
+    type: object
   models.WrSpotGroupTradeSumEx:
     properties:
       lst:
@@ -26866,6 +26878,37 @@ paths:
       summary: 查询指数
       tags:
       - 仓单贸易v2
+  /WrTrade2/QuerySpotGroupTradeSumDetail:
+    get:
+      description: 查询的结果将会按日期 从小到大 排序
+      parameters:
+      - description: 现货商品id
+        in: query
+        name: deliverygoodsid
+        required: true
+        type: integer
+      - description: 查询最新多少条记录(如不填写此项, 默认查30条)
+        in: query
+        name: lastnum
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.WrSpotGroupTradeSumDetail'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询指数详细(价格走势图)
+      tags:
+      - 仓单贸易v2
   /WrTrade2/QueryWrAverageTradePrice:
     get:
       parameters:

+ 41 - 0
models/wrTrade2.go

@@ -3896,3 +3896,44 @@ func (r *WrSpotGroupTradeSumEx) GetDataEx() (interface{}, error) {
 
 	return sData, err
 }
+
+// WrSpotGroupTradeSumDetail 折线图价格走势
+type WrSpotGroupTradeSumDetail struct {
+	RECKONDATE      string  `json:"reckondate"  xorm:"'RECKONDATE'"`                                  // 日期(yyymmdd, 如:20211031)
+	DELIVERYGOODSID int64   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'" form:"deliverygoodsid"` // 现货商品id
+	PRICE           float64 `json:"price"  xorm:"'PRICE'"`                                            // 价格
+
+	LASTNUM int32 `json:"-" form:"lastnum"` // 最新多少条
+}
+
+func (r *WrSpotGroupTradeSumDetail) calc() {
+
+}
+
+func (r *WrSpotGroupTradeSumDetail) buildSql() string {
+	var sqlId utils.SQLVal = `
+select a.*
+   from (select t.reckondate, t.deliverygoodsid, t.todayavgprice price, rownum cnt
+           from reckon_spotgrouptradesum t
+          where 1 = 1
+            and t.deliverygoodsid = %v
+          order by t.reckondate desc) a
+  where a.cnt <= %v
+  order by a.reckondate
+`
+	if r.LASTNUM == 0 {
+		r.LASTNUM = 30 // 如果没传值, 默认查最近30条
+	}
+	sqlId.FormatParam(r.DELIVERYGOODSID, r.LASTNUM)
+	return sqlId.String()
+}
+
+// GetDataEx 获取折线图价格走势
+func (r *WrSpotGroupTradeSumDetail) GetDataEx() (interface{}, error) {
+	sData := make([]WrSpotGroupTradeSumDetail, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -579,6 +579,7 @@ func InitRouter() *gin.Engine {
 		wrTrade2R.GET("QuerySiteColumnDetail", wrTrade2.QuerySiteColumnDetail)
 		wrTrade2R.GET("QueryDeliveryGoodsSection", wrTrade2.QueryDeliveryGoodsSection)
 		wrTrade2R.GET("QuerySpotGroupTradeSum", wrTrade2.QuerySpotGroupTradeSum)
+		wrTrade2R.GET("QuerySpotGroupTradeSumDetail", wrTrade2.QuerySpotGroupTradeSumDetail)
 	}
 
 	// **************************天津麦顿*************************