Quellcode durchsuchen

增加接口“/Ferroalloy/QuerySpotgoodsPrice 查询行情-现货列表”

zhou.xiaoning vor 3 Jahren
Ursprung
Commit
789cefd004
7 geänderte Dateien mit 1050 neuen und 1014 gelöschten Zeilen
  1. 20 3
      controllers/ferroalloy/quote.go
  2. 2 2
      controllers/ferroalloy/trade.go
  3. 342 242
      docs/docs.go
  4. 342 242
      docs/swagger.json
  5. 297 525
      docs/swagger.yaml
  6. 46 0
      models/ferroalloy.go
  7. 1 0
      routers/router.go

+ 20 - 3
controllers/ferroalloy/quote.go

@@ -14,10 +14,10 @@ import (
 // @Summary  获取现货行情
 // @Produce  json
 // @Security ApiKeyAuth
-// @Param    page           query    int    false "页码"
-// @Param    pagesize       query    int    false "每页条数"
+// @Param    page     query    int false "页码"
+// @Param    pagesize query    int false "每页条数"
 // @Success  200      {array}  models.GErmcpspotgoodsprice
-// @Failure  500            {object} app.Response
+// @Failure  500      {object} app.Response
 // @Router   /Ferroalloy/GetSpotGoodsPrice [get]
 // @Tags     铁合金
 func GetSpotGoodsPrice(c *gin.Context) {
@@ -174,3 +174,20 @@ func QueryTHJPurchaseTransferDetail(c *gin.Context) {
 		a.Gin.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
 	}
 }
+
+// QuerySpotgoodsPrice
+// @Summary  查询行情-现货列表
+// @Produce  json
+// @Security ApiKeyAuth
+// @Param    page           query    int    false "页码"
+// @Param    pagesize       query    int    false "每页条数"
+// @Success  200      {array}  models.Spotgoodsprice
+// @Failure  500            {object} app.Response
+// @Router   /Ferroalloy/QuerySpotgoodsPrice [get]
+// @Tags     铁合金
+func QuerySpotgoodsPrice(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Spotgoodsprice{}
+	a.DoBindReq(&m)
+	a.DoGetDataByPage(&m)
+}

+ 2 - 2
controllers/ferroalloy/trade.go

@@ -16,7 +16,7 @@ import (
 // @Param    page         query    int false "页码"
 // @Param    pagesize     query    int false "每页条数"
 // @Success  200      {array}  models.Thjpurchasetradedetail
-// @Failure  500             {object} app.Response
+// @Failure  500        {object} app.Response
 // @Router   /Ferroalloy/QueryTHJPurchaseTradeDetail [get]
 // @Tags     铁合金
 func QueryTHJPurchaseTradeDetail(c *gin.Context) {
@@ -69,7 +69,7 @@ func QueryTHJPurchaseTransferOrder(c *gin.Context) {
 // @Produce  json
 // @Security ApiKeyAuth
 // @Param    transferid query    string true "转让单号"
-// @Success  200             {array}  models.ThjpurchasetransferDetail
+// @Success  200        {array}  models.ThjpurchasetransferDetail
 // @Failure  500      {object} app.Response
 // @Router   /Ferroalloy/QueryTHJPurchaseTransferOrderDetail [get]
 // @Tags     铁合金

Datei-Diff unterdrückt, da er zu groß ist
+ 342 - 242
docs/docs.go


Datei-Diff unterdrückt, da er zu groß ist
+ 342 - 242
docs/swagger.json


Datei-Diff unterdrückt, da er zu groß ist
+ 297 - 525
docs/swagger.yaml


+ 46 - 0
models/ferroalloy.go

@@ -1620,3 +1620,49 @@ func (r *THJUserLevelInfo) Get() (err error) {
 
 	return
 }
+
+// Spotgoodsprice 现货市价
+type Spotgoodsprice struct {
+	WRSTANDARDID      int64   `json:"wrstandardid" xorm:"WRSTANDARDID"`           // 现货商品ID(通用则为0)
+	WRSTANDARDCODE    string  `json:"wrstandardcode" xorm:"WRSTANDARDCODE"`       // 现货商品代码
+	WRSTANDARDNAME    string  `json:"wrstandardname" xorm:"WRSTANDARDNAME"`       // 现货商品名称
+	SPOTGOODSPRICE    float64 `json:"spotgoodsprice" xorm:"SPOTGOODSPRICE"`       // 当前价格
+	PRESPOTGOODSPRICE float64 `json:"prespotgoodsprice" xorm:"PRESPOTGOODSPRICE"` // 上日价格
+	TRADEDATE         string  `json:"tradedate" xorm:"TRADEDATE"`                 // 交易日(yyyyMMdd)
+
+	PageEx `xorm:"extends"` // 页码信息
+}
+
+func (r *Spotgoodsprice) calc() {
+
+}
+
+func (r *Spotgoodsprice) buildSql() string {
+	var sqlId utils.SQLVal = `
+	select 
+		wr.WRSTANDARDID,
+		wr.WRSTANDARDCODE,
+		wr.wrstandardname, 
+		t.prespotgoodsprice, 
+		t.spotgoodsprice,
+		to_char(to_date(t.TRADEDATE, 'yyyymmdd'), 'yyyy-mm-dd') TRADEDATE
+  	from ERMCP_SpotGoodsPrice t
+	left join wrstandard wr
+    	on t.wrstandardid = wr.wrstandardid
+	order by wr.wrstandardname desc
+`
+
+	sqlId.Page(r.Page, r.PageSize)
+	return sqlId.String()
+}
+
+func (r *Spotgoodsprice) GetDataByPage() (interface{}, error, int, int, int) {
+	sData := make([]Spotgoodsprice, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	total := 0
+	for i := range sData {
+		sData[i].calc()
+		total = sData[i].Total
+	}
+	return sData, err, r.Page, r.PageSize, total
+}

+ 1 - 0
routers/router.go

@@ -710,6 +710,7 @@ func InitRouter() *gin.Engine {
 		ferroalloyR.Use(token.Auth()).GET("QueryTHJPromotionIncomeDetail", ferroalloy.QueryTHJPromotionIncomeDetail)
 		ferroalloyR.Use(token.Auth()).GET("QueryTHJPurchaseTransferOrderDetail", ferroalloy.QueryTHJPurchaseTransferOrderDetail)
 		ferroalloyR.Use(token.Auth()).GET("QueryUserLevelInfo", ferroalloy.QueryUserLevelInfo)
+		ferroalloyR.Use(token.Auth()).GET("QuerySpotgoodsPrice", ferroalloy.QuerySpotgoodsPrice)
 	}
 
 	return r

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.