micro_roadshow.go 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/services"
  7. "hongze/hongze_clpt/utils"
  8. "strconv"
  9. "time"
  10. )
  11. // 微路演
  12. type MicroRoadShowController struct {
  13. BaseAuthController
  14. }
  15. // @Title 微路演列表
  16. // @Description 微路演列表接口
  17. // @Param PageSize query int true "每页数据条数"
  18. // @Param CurrentIndex query int true "当前页页码,从1开始"
  19. // @Param KeyWord query string false "搜索关键词"
  20. // @Param AudioId query int false "音频ID"
  21. // @Param VideoId query int false "视频ID"
  22. // @Param ActivityVideoId query int false "活动视频ID"
  23. // @Param AudioIds query string false "活动音频IDs"
  24. // @Param ActivityVideoIds query string false "活动视频IDs"
  25. // @Param VideoIds query string false "视频IDs"
  26. // @Param Filter query string false "筛选条件 为空:全部 1:视频 2:音频 3:逻辑解析 4:路演回放 多个用 , 隔开"
  27. // @Success 200 {object} models.HomeListResp
  28. // @router /list [get]
  29. func (this *MicroRoadShowController) List() {
  30. br := new(models.BaseResponse).Init()
  31. defer func() {
  32. this.Data["json"] = br
  33. this.ServeJSON()
  34. }()
  35. user := this.User
  36. if user == nil {
  37. br.Msg = "请登录"
  38. br.ErrMsg = "请登录,用户信息为空"
  39. br.Ret = 408
  40. return
  41. }
  42. pageSize, _ := this.GetInt("PageSize")
  43. currentIndex, _ := this.GetInt("CurrentIndex")
  44. keywords := this.GetString("KeyWord")
  45. audioId, _ := this.GetInt("AudioId")
  46. videoId, _ := this.GetInt("VideoId")
  47. activityVideoId, _ := this.GetInt("ActivityVideoId")
  48. filter := this.GetString("Filter")
  49. audioIds := this.GetString("AudioIds")
  50. videoIds := this.GetString("VideoIds")
  51. activityVideoIds := this.GetString("ActivityVideoIds")
  52. if pageSize <= 0 {
  53. pageSize = utils.PageSize20
  54. }
  55. if currentIndex <= 0 {
  56. currentIndex = 1
  57. }
  58. // 微路演列表
  59. list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords, audioIds, videoIds, activityVideoIds)
  60. if e != nil {
  61. br.Msg = "获取失败"
  62. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  63. return
  64. }
  65. // 用户权限
  66. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  67. if e != nil {
  68. br.Msg = "获取失败"
  69. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  70. return
  71. }
  72. // 获取默认图配置
  73. audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
  74. if e != nil {
  75. br.Msg = "获取失败"
  76. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  77. return
  78. }
  79. for i := range list {
  80. // 权限
  81. au := new(models.UserPermissionAuthInfo)
  82. au.SellerName = authInfo.SellerName
  83. au.SellerMobile = authInfo.SellerMobile
  84. au.HasPermission = authInfo.HasPermission
  85. au.OperationMode = authInfo.OperationMode
  86. if au.HasPermission == 1 {
  87. // 非宏观权限进一步判断是否有权限
  88. if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
  89. au.HasPermission = 2
  90. }
  91. }
  92. // 无权限的弹框提示
  93. if au.HasPermission != 1 {
  94. if au.OperationMode == services.UserPermissionOperationModeCall {
  95. if list[i].Type == 1 {
  96. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  97. } else {
  98. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  99. }
  100. } else {
  101. if list[i].Type == 1 {
  102. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  103. } else {
  104. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  105. }
  106. }
  107. }
  108. list[i].AuthInfo = au
  109. list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
  110. // 默认图
  111. if list[i].BackgroundImg == "" {
  112. if list[i].Type == 1 {
  113. list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
  114. } else {
  115. list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
  116. }
  117. }
  118. // 分享图
  119. if list[i].ShareImg == "" {
  120. if list[i].Type == 1 {
  121. list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
  122. } else {
  123. list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
  124. }
  125. }
  126. }
  127. resp := new(models.MicroRoadShowListResp)
  128. page := paging.GetPaging(currentIndex, pageSize, total)
  129. resp.List = list
  130. resp.Paging = page
  131. br.Ret = 200
  132. br.Success = true
  133. br.Msg = "获取成功"
  134. br.Data = resp
  135. }
  136. // @Title 视频详情
  137. // @Description 时间线接口
  138. // @Param VideoId query int true "视频ID"
  139. // @Success 200 {object} models.IndustryVideoDetailResp
  140. // @router /detail [get]
  141. func (this *MicroRoadShowController) Detail() {
  142. br := new(models.BaseResponse).Init()
  143. defer func() {
  144. this.Data["json"] = br
  145. this.ServeJSON()
  146. }()
  147. user := this.User
  148. if user == nil {
  149. br.Msg = "请重新登录"
  150. br.Ret = 408
  151. return
  152. }
  153. videoId, _ := this.GetInt("VideoId")
  154. videoSimple, au, err := services.GetindustryVideoDetailById(user, videoId)
  155. if err != nil {
  156. br.Msg = "获取失败"
  157. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  158. return
  159. }
  160. resp := new(models.IndustryVideoDetailResp)
  161. resp.IndustryVideo = videoSimple
  162. resp.AuthInfo = au
  163. br.Ret = 200
  164. br.Success = true
  165. br.Msg = "获取成功"
  166. br.Data = resp
  167. }
  168. // @Title 记录用户浏览音频回放接口
  169. // @Description 记录用户浏览音频回放接口
  170. // @Param request body models.ActivityIdRep true "type json string"
  171. // @Success Ret=200 {object} models.AddVideoHistoryReq
  172. // @router /videoHistory/add [post]
  173. func (this *MicroRoadShowController) VideoHistoryAdd() {
  174. br := new(models.BaseResponse).Init()
  175. defer func() {
  176. this.Data["json"] = br
  177. this.ServeJSON()
  178. }()
  179. user := this.User
  180. if user == nil {
  181. br.Msg = "请登录"
  182. br.ErrMsg = "请登录,用户信息为空"
  183. br.Ret = 408
  184. return
  185. }
  186. uid := user.UserId
  187. var req models.AddVideoHistoryReq
  188. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  189. if err != nil {
  190. br.Msg = "参数解析异常!"
  191. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  192. return
  193. }
  194. videoId := req.VideoId
  195. playSeconds := req.PlaySeconds
  196. var sellerName string
  197. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  198. if err != nil {
  199. br.Msg = "报名失败!"
  200. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  201. return
  202. }
  203. item := models.CygxMicroRoadshowVideoHistory{
  204. VideoId: videoId,
  205. UserId: uid,
  206. Mobile: user.Mobile,
  207. Email: user.Email,
  208. CompanyId: user.CompanyId,
  209. CompanyName: user.CompanyName,
  210. RealName: user.RealName,
  211. SellerName: sellerName,
  212. PlaySeconds: strconv.Itoa(playSeconds),
  213. CreateTime: time.Now(),
  214. ModifyTime: time.Now(),
  215. }
  216. //if playSeconds != 0 {
  217. // lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
  218. // if err != nil {
  219. // br.Msg = "操作失败"
  220. // br.ErrMsg = "操作失败,GetLastCygxMicroRoadshowVideoHistory Err:" + err.Error()
  221. // return
  222. // }
  223. // err = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
  224. // if err != nil {
  225. // br.Msg = "更新失败"
  226. // br.ErrMsg = "更新失败,UpdateLastCygxActivityVideoHistory Err:" + err.Error()
  227. // return
  228. // }
  229. //} else {
  230. // err = models.AddCygxMicroRoadshowVideoHistory(&item)
  231. // if err != nil {
  232. // br.Msg = "操作失败"
  233. // br.ErrMsg = "操作失败,Err:" + err.Error()
  234. // return
  235. // }
  236. // err = models.UpdateCygxActivityVideoCounts(videoId)
  237. // if err != nil {
  238. // br.Msg = "更新失败"
  239. // br.ErrMsg = "更新失败,Err:" + err.Error()
  240. // return
  241. // }
  242. //}
  243. err = models.AddCygxMicroRoadshowVideoHistory(&item)
  244. if err != nil {
  245. br.Msg = "操作失败"
  246. br.ErrMsg = "操作失败,Err:" + err.Error()
  247. return
  248. }
  249. err = models.UpdateCygxActivityVideoCounts(videoId)
  250. if err != nil {
  251. br.Msg = "更新失败"
  252. br.ErrMsg = "更新失败,Err:" + err.Error()
  253. return
  254. }
  255. br.Ret = 200
  256. br.Success = true
  257. br.Msg = "操作成功"
  258. return
  259. }