chart_common.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package data_manage
  2. import (
  3. "hongze/hongze_ETA_mobile_api/controllers/data_manage/correlation"
  4. "hongze/hongze_ETA_mobile_api/controllers/data_manage/future_good"
  5. "hongze/hongze_ETA_mobile_api/models"
  6. "hongze/hongze_ETA_mobile_api/models/data_manage"
  7. "hongze/hongze_ETA_mobile_api/utils"
  8. )
  9. // CommonChartInfoDetailFromUniqueCode
  10. // @Title 根据编码获取图表详情
  11. // @Description 根据编码获取图表详情接口
  12. // @Param UniqueCode query int true "图表唯一编码,如果是管理后台访问,传固定字符串:7c69b590249049942070ae9dcd5bf6dc"
  13. // @Param IsCache query bool true "是否走缓存,默认false"
  14. // @Success 200 {object} data_manage.ChartInfoDetailFromUniqueCodeResp
  15. // @router /chart_info/common/detail/from_unique_code [get]
  16. func (this *ChartInfoController) CommonChartInfoDetailFromUniqueCode() {
  17. br := new(models.BaseResponse).Init()
  18. defer func() {
  19. this.Data["json"] = br
  20. this.ServeJSON()
  21. }()
  22. sysUser := this.SysUser
  23. if sysUser == nil {
  24. br.Msg = "请登录"
  25. br.ErrMsg = "请登录,SysUser Is Empty"
  26. br.Ret = 408
  27. return
  28. }
  29. uniqueCode := this.GetString("UniqueCode")
  30. if uniqueCode == "" {
  31. br.Msg = "参数错误"
  32. br.ErrMsg = "参数错误,uniqueCode is empty"
  33. return
  34. }
  35. //是否走缓存
  36. isCache, _ := this.GetBool("IsCache")
  37. status := true
  38. chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
  39. if err != nil {
  40. if err.Error() == utils.ErrNoRow() {
  41. status = false
  42. } else {
  43. br.Msg = "获取失败"
  44. br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
  45. return
  46. }
  47. }
  48. if chartInfo == nil {
  49. status = false
  50. }
  51. if !status {
  52. resp := new(data_manage.ChartInfoDetailFromUniqueCodeResp)
  53. endInfoList := make([]*data_manage.ChartEdbInfoMapping, 0)
  54. resp.EdbInfoList = endInfoList
  55. resp.ChartInfo = chartInfo
  56. resp.Status = false
  57. br.Data = resp
  58. br.Ret = 200
  59. br.Success = true
  60. br.Msg = "获取成功"
  61. return
  62. }
  63. switch chartInfo.Source {
  64. case utils.CHART_SOURCE_DEFAULT:
  65. resp, isOk, msg, errMsg := GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
  66. if !isOk {
  67. br.Msg = msg
  68. br.ErrMsg = errMsg
  69. return
  70. }
  71. br.Ret = 200
  72. br.Success = true
  73. br.Msg = "获取成功"
  74. br.Data = resp
  75. case utils.CHART_SOURCE_FUTURE_GOOD:
  76. resp, isOk, msg, errMsg := future_good.GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
  77. if !isOk {
  78. br.Msg = msg
  79. br.ErrMsg = errMsg
  80. return
  81. }
  82. br.Ret = 200
  83. br.Success = true
  84. br.Msg = "获取成功"
  85. br.Data = resp
  86. case utils.CHART_SOURCE_FUTURE_GOOD_PROFIT:
  87. resp, isOk, msg, errMsg := future_good.GetFutureGoodProfitChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
  88. if !isOk {
  89. br.Msg = msg
  90. br.ErrMsg = errMsg
  91. return
  92. }
  93. br.Ret = 200
  94. br.Success = true
  95. br.Msg = "获取成功"
  96. br.Data = resp
  97. case utils.CHART_SOURCE_CORRELATION, utils.CHART_SOURCE_ROLLING_CORRELATION:
  98. resp, isOk, msg, errMsg := correlation.GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
  99. if !isOk {
  100. br.Msg = msg
  101. br.ErrMsg = errMsg
  102. return
  103. }
  104. br.Ret = 200
  105. br.Success = true
  106. br.Msg = "获取成功"
  107. br.Data = resp
  108. default:
  109. br.Msg = "错误的图表"
  110. br.ErrMsg = "错误的图表"
  111. return
  112. }
  113. }