report_share.go 3.0 KB

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