micro_roadshow.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "hongze/hongze_mfyx/models"
  5. "hongze/hongze_mfyx/services"
  6. )
  7. // 微路演 (查看留言详情,之前老的项目写到这个模块下了)
  8. type MicroRoadShowController struct {
  9. BaseAuthController
  10. }
  11. // @Title 模版消息留言详情
  12. // @Description 模版消息留言详情接口
  13. // @Param SourceId query int true "资源ID"
  14. // @Param SourceType query int true "留言类型,1:文章、2:活动、3:微路演视频、4:活动视频、5:活动音频"
  15. // @Success Ret=200 {object} models.CygxArticleCommentWxResp
  16. // @router /comment/detail [get]
  17. func (this *MicroRoadShowController) CommentDetail() {
  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. sourceId, _ := this.GetInt("SourceId")
  31. sourceType, _ := this.GetInt("SourceType")
  32. resp := new(models.CygxArticleCommentWxResp)
  33. if sourceType == 1 || sourceType == 3 || sourceType == 4 || sourceType == 5 {
  34. detail, err := models.GetArticleCommentById(sourceId)
  35. if err != nil {
  36. br.Msg = "获取失败"
  37. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  38. return
  39. }
  40. resp.Content = detail.Content
  41. if sourceType == 1 {
  42. resp.SourceId = detail.ArticleId
  43. resp.RedirectType = 1
  44. } else if sourceType == 3 {
  45. resp.SourceId = detail.IndustryId
  46. resp.RedirectType = 3
  47. } else {
  48. resp.SourceId = detail.ActivityId
  49. resp.RedirectType = 2
  50. }
  51. } else {
  52. detail, err := models.GetCygxActivityHelpAskById(sourceId)
  53. if err != nil {
  54. br.Msg = "获取失败"
  55. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  56. return
  57. }
  58. resp.Content = detail.Content
  59. resp.SourceId = detail.ActivityId
  60. resp.RedirectType = 2
  61. }
  62. br.Ret = 200
  63. br.Success = true
  64. br.Data = resp
  65. br.Msg = "操作成功"
  66. return
  67. }
  68. // @Title 记录用户浏览音频回放接口
  69. // @Description 记录用户浏览音频回放接口
  70. // @Param request body models.ActivityIdRep true "type json string"
  71. // @Success Ret=200 {object} models.AddVideoHistoryReq
  72. // @router /videoHistory/add [post]
  73. func (this *MicroRoadShowController) VideoHistoryAdd() {
  74. br := new(models.BaseResponse).Init()
  75. defer func() {
  76. this.Data["json"] = br
  77. this.ServeJSON()
  78. }()
  79. user := this.User
  80. if user == nil {
  81. br.Msg = "请登录"
  82. br.ErrMsg = "请登录,用户信息为空"
  83. br.Ret = 408
  84. return
  85. }
  86. var req models.AddVideoHistoryReq
  87. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  88. if err != nil {
  89. br.Msg = "参数解析异常!"
  90. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  91. return
  92. }
  93. sourceId := req.SourceId
  94. playSeconds := req.PlaySeconds
  95. sourceType := req.SourceType
  96. inviteShareCode := req.InviteShareCode
  97. if sourceType == 0 {
  98. sourceType = 1
  99. }
  100. if sourceType == 1 {
  101. //添加活动音频的播放记录
  102. go services.AddActivityVoiceHistory(user, sourceId, playSeconds, inviteShareCode)
  103. } else if sourceType == 2 {
  104. //添加活动视频的播放记录
  105. go services.AddActivityVideoHistory(user, sourceId, playSeconds, inviteShareCode)
  106. } else if sourceType == 3 {
  107. //添加产业视频播放记录
  108. go services.AddMicroRoadshowVideoRecord(user, sourceId, playSeconds)
  109. } else if sourceType == 4 {
  110. //问答系列音频播放记录
  111. //go services.AddAskserieVideoHistoryRecord(user, sourceId, playSeconds)
  112. }
  113. go services.AddAllCygxVoiceAndVideoHistory(user, sourceId, sourceType, playSeconds)
  114. br.Ret = 200
  115. br.Success = true
  116. br.Msg = "操作成功"
  117. return
  118. }