report_share.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package controllers
  2. import (
  3. "hongze/hongze_api/models"
  4. "hongze/hongze_api/utils"
  5. "html"
  6. )
  7. // ReportShareController 报告分享
  8. type ReportShareController struct {
  9. BaseCommonController
  10. }
  11. // Detail
  12. // @Title 日评详情
  13. // @Description 日评详情接口
  14. // @Param ReportCode query string true "报告唯一编码"
  15. // @Success 200 {object} models.ReportShareDetailResp
  16. // @router /share/detail [get]
  17. func (this *ReportShareController) Detail() {
  18. br := new(models.BaseResponse).Init()
  19. defer func() {
  20. this.Data["json"] = br
  21. this.ServeJSON()
  22. }()
  23. reportCode := this.GetString("ReportCode")
  24. if reportCode == "" {
  25. br.Msg = "参数错误"
  26. br.ErrMsg = "参数错误,reportCode 为空"
  27. return
  28. }
  29. report, err := models.GetReportByCode(reportCode)
  30. if err != nil {
  31. br.Msg = "该报告已删除"
  32. br.ErrMsg = "获取报告详情失败,Err:" + err.Error()
  33. return
  34. }
  35. report.ContentSub = html.UnescapeString(report.ContentSub)
  36. report.Content = html.UnescapeString(report.Content)
  37. resp := new(models.ReportShareDetailResp)
  38. // 免责声明
  39. conf, e := models.GetBusinessConf()
  40. if e != nil && e.Error() != utils.ErrNoRow() {
  41. br.Msg = "获取失败"
  42. br.ErrMsg = "获取免责声明失败, Err: " + e.Error()
  43. return
  44. }
  45. if conf != nil {
  46. resp.Disclaimer = html.UnescapeString(conf.Disclaimer)
  47. }
  48. resp.Report = report
  49. br.Ret = 200
  50. br.Success = true
  51. br.Msg = "获取成功"
  52. br.Data = resp
  53. }
  54. // TrialDetail
  55. // @Title 日评详情-ETA试用平台
  56. // @Description 日评详情接口
  57. // @Param ReportCode query string true "报告唯一编码"
  58. // @Success 200 {object} models.ReportShareDetailResp
  59. // @router /trial/share/detail [get]
  60. func (this *ReportShareController) TrialDetail() {
  61. br := new(models.BaseResponse).Init()
  62. defer func() {
  63. this.Data["json"] = br
  64. this.ServeJSON()
  65. }()
  66. reportCode := this.GetString("ReportCode")
  67. if reportCode == "" {
  68. br.Msg = "参数错误"
  69. br.ErrMsg = "参数错误,reportCode 为空"
  70. return
  71. }
  72. report, err := models.GetTrialReportByCode(reportCode)
  73. if err != nil {
  74. br.Msg = "该报告已删除"
  75. br.ErrMsg = "获取报告详情失败,Err:" + err.Error()
  76. return
  77. }
  78. report.ContentSub = html.UnescapeString(report.ContentSub)
  79. report.Content = html.UnescapeString(report.Content)
  80. resp := new(models.ReportShareDetailResp)
  81. resp.Report = report
  82. br.Ret = 200
  83. br.Success = true
  84. br.Msg = "获取成功"
  85. br.Data = resp
  86. }