ficc_report.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package controllers
  2. import (
  3. "hongze/hongze_cygx/models"
  4. "hongze/hongze_cygx/models/ficc_report"
  5. "hongze/hongze_cygx/services"
  6. "hongze/hongze_cygx/utils"
  7. "time"
  8. )
  9. type FiccYbController struct {
  10. BaseAuthController
  11. }
  12. // @Title 获取报告详情
  13. // @Description 获取报告详情接口
  14. // @Param ReportId query int true "报告ID"
  15. // @Success 200 {object} models.ArticleDetailResp
  16. // @router /detail [get]
  17. func (this *FiccYbController) Detail() {
  18. br := new(models.BaseResponse).Init()
  19. defer func() {
  20. this.Data["json"] = br
  21. this.ServeJSON()
  22. }()
  23. user := this.User
  24. if user == nil {
  25. br.Msg = "请登录"
  26. br.ErrMsg = "请登录,用户信息为空"
  27. br.Ret = 408
  28. return
  29. }
  30. //uid := user.UserId
  31. reportId, err := this.GetInt("ReportId")
  32. if err != nil {
  33. br.Msg = "文章不存在"
  34. br.ErrMsg = "文章不存在,文章ID错误" + err.Error()
  35. return
  36. }
  37. if reportId <= 0 {
  38. br.Msg = "文章不存在"
  39. br.ErrMsg = "文章不存在,文章ID错误"
  40. return
  41. }
  42. detail, err := services.GetReportDetail(user, reportId)
  43. if err != nil {
  44. br.Msg = "文章不存在"
  45. br.ErrMsg = "获取研报信息失败" + err.Error()
  46. return
  47. }
  48. br.Ret = 200
  49. br.Success = true
  50. br.Msg = "获取成功"
  51. br.Data = detail
  52. }
  53. // @Title 记录点击信息
  54. // @Description 记录点击信息
  55. // @Param request body cygx.CygxBannerIdReq true "type json string"
  56. // @Success 200 Ret=200 发布成功
  57. // @router /add/xcx/history [post]
  58. func (this *FiccYbController) AddXcxHistory() {
  59. br := new(models.BaseResponse).Init()
  60. defer func() {
  61. this.Data["json"] = br
  62. this.ServeJSON()
  63. }()
  64. user := this.User
  65. if user == nil {
  66. br.Msg = "请登录"
  67. br.ErrMsg = "请登录,用户信息为空"
  68. br.Ret = 408
  69. return
  70. }
  71. historyRecord := new(ficc_report.FiccYbXcxHistory)
  72. historyRecord.UserId = user.UserId
  73. historyRecord.RealName = user.RealName
  74. historyRecord.CreateTime = time.Now()
  75. historyRecord.Mobile = user.Mobile
  76. historyRecord.Email = user.Email
  77. historyRecord.CompanyId = user.CompanyId
  78. historyRecord.CompanyName = user.CompanyName
  79. historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
  80. historyRecord.SellerName, _, _ = services.GetSellerName(user)
  81. _, err := ficc_report.AddFiccYbXcxHistory(historyRecord)
  82. if err != nil {
  83. br.Msg = "记录访问信息失败"
  84. br.ErrMsg = "记录访问信息失败" + err.Error()
  85. }
  86. br.Ret = 200
  87. br.Success = true
  88. br.Msg = "记录成功"
  89. }