123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- package data_manage
- import (
- "hongze/hz_eta_api/controllers/data_manage/correlation"
- "hongze/hz_eta_api/controllers/data_manage/future_good"
- "hongze/hz_eta_api/controllers/data_manage/line_equation"
- "hongze/hz_eta_api/controllers/data_manage/line_feature"
- "hongze/hz_eta_api/models"
- "hongze/hz_eta_api/models/data_manage"
- "hongze/hz_eta_api/utils"
- )
- // CommonChartInfoDetailFromUniqueCode
- // @Title 根据编码获取图表详情
- // @Description 根据编码获取图表详情接口
- // @Param UniqueCode query int true "图表唯一编码,如果是管理后台访问,传固定字符串:7c69b590249049942070ae9dcd5bf6dc"
- // @Param IsCache query bool true "是否走缓存,默认false"
- // @Success 200 {object} data_manage.ChartInfoDetailFromUniqueCodeResp
- // @router /chart_info/common/detail/from_unique_code [get]
- func (this *ChartInfoController) CommonChartInfoDetailFromUniqueCode() {
- 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
- }
- //是否走缓存
- isCache, _ := this.GetBool("IsCache")
- 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_DEFAULT:
- resp, isOk, msg, errMsg := GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
- if !isOk {
- br.Msg = msg
- br.ErrMsg = errMsg
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- case utils.CHART_SOURCE_FUTURE_GOOD:
- resp, isOk, msg, errMsg := future_good.GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
- if !isOk {
- br.Msg = msg
- br.ErrMsg = errMsg
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- case utils.CHART_SOURCE_FUTURE_GOOD_PROFIT:
- resp, isOk, msg, errMsg := future_good.GetFutureGoodProfitChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
- if !isOk {
- br.Msg = msg
- br.ErrMsg = errMsg
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- case utils.CHART_SOURCE_CORRELATION, utils.CHART_SOURCE_ROLLING_CORRELATION:
- resp, isOk, msg, errMsg := correlation.GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
- if !isOk {
- br.Msg = msg
- br.ErrMsg = errMsg
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- case utils.CHART_SOURCE_LINE_EQUATION:
- resp, isOk, msg, errMsg := line_equation.GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
- if !isOk {
- br.Msg = msg
- br.ErrMsg = errMsg
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- case utils.CHART_SOURCE_LINE_FEATURE_STANDARD_DEVIATION, utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE, utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY:
- resp, isOk, msg, errMsg := line_feature.GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
- if !isOk {
- br.Msg = msg
- br.ErrMsg = errMsg
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- default:
- br.Msg = "错误的图表"
- br.ErrMsg = "错误的图表"
- return
- }
- }
|