Browse Source

fix:商品价格/利润曲线,新增基础图表信息接口,便于前端调用时,不需要返回特殊的数据

Roc 1 year ago
parent
commit
7468c3d256
2 changed files with 94 additions and 0 deletions
  1. 85 0
      controllers/data_manage/chart_common.go
  2. 9 0
      routers/commentsRouter.go

+ 85 - 0
controllers/data_manage/chart_common.go

@@ -144,3 +144,88 @@ func (this *ChartInfoController) CommonChartInfoDetailFromUniqueCode() {
 		return
 	}
 }
+
+// CommonBaseChartInfoDetailFromUniqueCode
+// @Title 根据编码获取图表详情(基础信息,没有数据)
+// @Description 根据编码获取图表详情(基础信息,没有数据)
+// @Param   UniqueCode   query   int  true       "图表唯一编码,如果是管理后台访问,传固定字符串:7c69b590249049942070ae9dcd5bf6dc"
+// @Success 200 {object} data_manage.ChartInfoDetailFromUniqueCodeResp
+// @router /chart_info/common/base_detail/from_unique_code [get]
+func (this *ChartInfoController) CommonBaseChartInfoDetailFromUniqueCode() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	uniqueCode := this.GetString("UniqueCode")
+	if uniqueCode == "" {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,uniqueCode is empty"
+		return
+	}
+
+	status := true
+	chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			status = false
+		} else {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
+			return
+		}
+	}
+
+	if chartInfo == nil {
+		status = false
+	}
+
+	if !status {
+		resp := new(data_manage.ChartInfoDetailFromUniqueCodeResp)
+		endInfoList := make([]*data_manage.ChartEdbInfoMapping, 0)
+		resp.EdbInfoList = endInfoList
+		resp.ChartInfo = chartInfo
+		resp.Status = false
+
+		br.Data = resp
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		return
+	}
+
+	switch chartInfo.Source {
+	case utils.CHART_SOURCE_FUTURE_GOOD, utils.CHART_SOURCE_FUTURE_GOOD_PROFIT:
+		edbInfoMapping, err := data_manage.GetEtaEdbChartEdbMapping(chartInfo.ChartInfoId)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取图表,现货指标信息失败,Err:" + err.Error()
+			return
+		}
+		edbList := []*data_manage.ChartEdbInfoMapping{
+			edbInfoMapping,
+		}
+		resp := data_manage.ChartInfoDetailFromUniqueCodeResp{
+			ChartInfo:   chartInfo,
+			Status:      true,
+			EdbInfoList: edbList,
+		}
+
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+	default:
+		br.Msg = "暂未实现"
+		br.ErrMsg = "暂未实现"
+		return
+	}
+}

+ 9 - 0
routers/commentsRouter.go

@@ -1159,6 +1159,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:ChartInfoController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:ChartInfoController"],
+        beego.ControllerComments{
+            Method: "CommonBaseChartInfoDetailFromUniqueCode",
+            Router: `/chart_info/common/base_detail/from_unique_code`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:ChartInfoController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:ChartInfoController"],
         beego.ControllerComments{
             Method: "CommonChartInfoDetailFromUniqueCode",