edb_info.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package controllers
  2. import (
  3. "eta/eta_forum_admin/models"
  4. "eta/eta_forum_admin/services"
  5. "eta/eta_forum_admin/utils"
  6. )
  7. // EdbInfoController 数据管理
  8. type EdbInfoController struct {
  9. BaseAuthController
  10. }
  11. // TraceEdbInfo
  12. // @Title 指标溯源接口
  13. // @Description 指标溯源接口
  14. // @Param UniqueCode query int true "指标唯一编码,如果是管理后台访问,传固定字符串:7c69b590249049942070ae9dcd5bf6dc"
  15. // @Success 200 {object} data_manage.ChartListResp
  16. // @router /trace [get]
  17. func (this *EdbInfoController) TraceEdbInfo() {
  18. br := new(models.BaseResponse).Init()
  19. defer func() {
  20. this.Data["json"] = br
  21. this.ServeJSON()
  22. }()
  23. sysUser := this.SysUser
  24. if sysUser == nil {
  25. br.Msg = "请登录"
  26. br.ErrMsg = "请登录,SysUser Is Empty"
  27. br.Ret = 408
  28. return
  29. }
  30. //edbInfoId, _ := this.GetInt("EdbInfoId")
  31. //if edbInfoId <= 0 {
  32. // br.Msg = "参数错误"
  33. // br.ErrMsg = "参数错误"
  34. // return
  35. //}
  36. uniqueCode := this.GetString("UniqueCode")
  37. if uniqueCode == `` {
  38. br.Msg = "参数错误"
  39. br.ErrMsg = "参数错误"
  40. return
  41. }
  42. // 根据UniqueCode获取指标信息
  43. edbInfo, err := models.GetEdbInfoByUniqueCode(uniqueCode)
  44. if err != nil {
  45. br.Msg = "获取失败"
  46. br.Msg = "获取失败,Err:" + err.Error()
  47. if err.Error() == utils.ErrNoRow() {
  48. br.Msg = "指标不存在"
  49. }
  50. return
  51. }
  52. resp, err := services.TraceEdbInfoByEdbInfoId(edbInfo.EdbInfoId)
  53. if err != nil {
  54. br.Msg = "获取失败"
  55. br.Msg = "获取失败,Err:" + err.Error()
  56. return
  57. }
  58. br.Ret = 200
  59. br.Data = resp
  60. br.Success = true
  61. br.Msg = "查询成功"
  62. }