micro_roadshow.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  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. "strings"
  10. "time"
  11. )
  12. // 微路演
  13. type MicroRoadShowController struct {
  14. BaseAuthController
  15. }
  16. // @Title 微路演列表
  17. // @Description 微路演列表接口
  18. // @Param PageSize query int true "每页数据条数"
  19. // @Param CurrentIndex query int true "当前页页码,从1开始"
  20. // @Param KeyWord query string false "搜索关键词"
  21. // @Param AudioId query int false "音频ID"
  22. // @Param VideoId query int false "视频ID"
  23. // @Param ActivityVideoId query int false "活动视频ID"
  24. // @Param Filter query string false "筛选条件 为空:全部 1:视频 2:音频 3:逻辑解析 4:路演回放 多个用 , 隔开"
  25. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  26. // @Param SourceId query int true "资源ID"
  27. // @Param SourceType query int true " 1:活动音频 2:活动视频 3:产业视频 4:问答系列"
  28. // @Param SearchType string int true "搜索类型: 1-路演回放; 2-问答系列; 3-调研反馈 多个用 , 隔开"
  29. // @Success 200 {object} models.HomeListResp
  30. // @router /list [get]
  31. func (this *MicroRoadShowController) List() {
  32. br := new(models.BaseResponse).Init()
  33. defer func() {
  34. this.Data["json"] = br
  35. this.ServeJSON()
  36. }()
  37. user := this.User
  38. if user == nil {
  39. br.Msg = "请登录"
  40. br.ErrMsg = "请登录,用户信息为空"
  41. br.Ret = 408
  42. return
  43. }
  44. pageSize, _ := this.GetInt("PageSize")
  45. currentIndex, _ := this.GetInt("CurrentIndex")
  46. keywords := this.GetString("KeyWord")
  47. //audioId, _ := this.GetInt("AudioId")
  48. //videoId, _ := this.GetInt("VideoId")
  49. //activityVideoId, _ := this.GetInt("ActivityVideoId")
  50. filter := this.GetString("Filter")
  51. chartPermissionIds := this.GetString("ChartPermissionIds")
  52. sourceId, _ := this.GetInt("SourceId")
  53. sourceType, _ := this.GetInt("SourceType")
  54. searchType := this.GetString("SearchType")
  55. if pageSize <= 0 {
  56. pageSize = utils.PageSize20
  57. }
  58. if currentIndex <= 0 {
  59. currentIndex = 1
  60. }
  61. var keyWordArr []string
  62. var err error
  63. if keywords != "" {
  64. keyWordArr, err = services.GetIndustryMapNameSliceV3(keywords)
  65. if err != nil {
  66. br.Msg = "获取失败"
  67. br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
  68. return
  69. }
  70. keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  71. }
  72. var list []*models.MicroRoadShowPageList
  73. var total int
  74. var e error
  75. // 微路演列表
  76. list, total, e = services.GetMicroRoadShowPageListV12(pageSize, currentIndex, sourceId, sourceType, filter, keywords, searchType, chartPermissionIds)
  77. if e != nil {
  78. br.Msg = "获取失败"
  79. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  80. return
  81. }
  82. //var pageSizeIk int
  83. //获取总的数量
  84. //totalIk, e := services.CountMicroRoadShowPageListIkWord(audioId, videoId, activityVideoId, keyWordArr, filter)
  85. //if e != nil {
  86. // br.Msg = "获取失败"
  87. // br.ErrMsg = "获取微路演联想词列表失败, Err: " + e.Error()
  88. // return
  89. //}
  90. ////return
  91. //pageSizeIk = totalIk - len(list)
  92. ////处理IK分词部分的分页获取条数
  93. //startSizeIk := utils.StartIndex(currentIndex, pageSize)
  94. //startSizeIk = startSizeIk - total
  95. //if startSizeIk < 0 {
  96. // startSizeIk = 0
  97. //}
  98. //if len(keyWordArr) > 0 {
  99. // lisIk, e := services.GetMicroRoadShowPageListIkWord(startSizeIk, pageSizeIk, audioId, videoId, activityVideoId, keyWordArr, filter, keywords)
  100. // if e != nil {
  101. // br.Msg = "获取失败"
  102. // br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  103. // return
  104. // }
  105. // for _, item := range lisIk {
  106. // list = append(list, item)
  107. // }
  108. //}
  109. userId := user.UserId
  110. listMycollect, err := models.GetUserMicroRoadshowCollectList(userId)
  111. if err != nil {
  112. br.Msg = "获取数据失败"
  113. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  114. return
  115. }
  116. mapaudioIds := make(map[int]int) //活动音频
  117. mapvideoIds := make(map[int]int) // 微路演视频
  118. mapactivityVideoIds := make(map[int]int) // 活动视频
  119. for _, item := range listMycollect {
  120. if item.ActivityVoiceId > 0 {
  121. mapaudioIds[item.ActivityVoiceId] = item.ActivityVoiceId
  122. } else if item.VideoId > 0 {
  123. mapvideoIds[item.VideoId] = item.VideoId
  124. } else if item.ActivityVideoId > 0 {
  125. mapactivityVideoIds[item.ActivityVoiceId] = item.ActivityVoiceId
  126. }
  127. }
  128. for _, item := range list {
  129. if item.Type == 1 {
  130. //音频
  131. if mapaudioIds[item.Id] > 0 {
  132. item.IsCollect = true
  133. }
  134. } else if item.Type == 2 {
  135. //活动视频
  136. if mapactivityVideoIds[item.Id] > 0 {
  137. item.IsCollect = true
  138. }
  139. } else if item.Type == 3 {
  140. //微路演视频
  141. if mapvideoIds[item.Id] > 0 {
  142. item.IsCollect = true
  143. }
  144. }
  145. }
  146. // 用户权限
  147. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  148. if e != nil {
  149. br.Msg = "获取失败"
  150. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  151. return
  152. }
  153. // 获取默认图配置
  154. audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
  155. if e != nil {
  156. br.Msg = "获取失败"
  157. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  158. return
  159. }
  160. for i := range list {
  161. // 权限
  162. au := new(models.UserPermissionAuthInfo)
  163. au.SellerName = authInfo.SellerName
  164. au.SellerMobile = authInfo.SellerMobile
  165. au.HasPermission = authInfo.HasPermission
  166. au.OperationMode = authInfo.OperationMode
  167. if au.HasPermission == 1 {
  168. // 非宏观权限进一步判断是否有权限
  169. if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
  170. au.HasPermission = 2
  171. }
  172. }
  173. // 无权限的弹框提示
  174. if au.HasPermission != 1 {
  175. if au.OperationMode == services.UserPermissionOperationModeCall {
  176. if list[i].Type == 1 {
  177. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  178. } else {
  179. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  180. }
  181. } else {
  182. if list[i].Type == 1 {
  183. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  184. } else {
  185. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  186. }
  187. }
  188. }
  189. list[i].AuthInfo = au
  190. list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
  191. // 默认图
  192. if list[i].BackgroundImg == "" {
  193. if list[i].Type == 1 {
  194. list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
  195. } else {
  196. list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
  197. }
  198. }
  199. // 分享图
  200. if list[i].ShareImg == "" {
  201. if list[i].Type == 1 {
  202. list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
  203. } else {
  204. list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
  205. }
  206. }
  207. }
  208. resp := new(models.MicroRoadShowListResp)
  209. page := paging.GetPaging(currentIndex, pageSize, total)
  210. resp.List = list
  211. resp.Paging = page
  212. br.Ret = 200
  213. br.Success = true
  214. br.Msg = "获取成功"
  215. br.Data = resp
  216. }
  217. // @Title 视频详情
  218. // @Description 时间线接口
  219. // @Param VideoId query int true "视频ID"
  220. // @Success 200 {object} models.IndustryVideoDetailResp
  221. // @router /detail [get]
  222. func (this *MicroRoadShowController) Detail() {
  223. br := new(models.BaseResponse).Init()
  224. defer func() {
  225. this.Data["json"] = br
  226. this.ServeJSON()
  227. }()
  228. user := this.User
  229. if user == nil {
  230. br.Msg = "请重新登录"
  231. br.Ret = 408
  232. return
  233. }
  234. videoId, _ := this.GetInt("VideoId")
  235. videoSimple, au, err := services.GetindustryVideoDetailById(user, videoId)
  236. if err != nil {
  237. br.Msg = "获取失败"
  238. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  239. return
  240. }
  241. resp := new(models.IndustryVideoDetailResp)
  242. resp.IndustryVideo = videoSimple
  243. resp.AuthInfo = au
  244. br.Ret = 200
  245. br.Success = true
  246. br.Msg = "获取成功"
  247. br.Data = resp
  248. }
  249. // @Title 记录用户浏览音频回放接口
  250. // @Description 记录用户浏览音频回放接口
  251. // @Param request body models.ActivityIdRep true "type json string"
  252. // @Success Ret=200 {object} models.AddVideoHistoryReq
  253. // @router /videoHistory/add [post]
  254. func (this *MicroRoadShowController) VideoHistoryAdd() {
  255. br := new(models.BaseResponse).Init()
  256. defer func() {
  257. this.Data["json"] = br
  258. this.ServeJSON()
  259. }()
  260. user := this.User
  261. if user == nil {
  262. br.Msg = "请登录"
  263. br.ErrMsg = "请登录,用户信息为空"
  264. br.Ret = 408
  265. return
  266. }
  267. uid := user.UserId
  268. var req models.AddVideoHistoryReq
  269. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  270. if err != nil {
  271. br.Msg = "参数解析异常!"
  272. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  273. return
  274. }
  275. videoId := req.VideoId
  276. playSeconds := req.PlaySeconds
  277. sourceType := req.SourceType
  278. if sourceType == 0 {
  279. sourceType = 1
  280. }
  281. var sellerName string
  282. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  283. if err != nil {
  284. br.Msg = "报名失败!"
  285. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  286. return
  287. }
  288. if sourceType == 1 {
  289. //添加活动音频的播放记录
  290. go services.AddActivityVoiceHistory(user, videoId, playSeconds)
  291. } else if sourceType == 2 {
  292. //添加活动视频的播放记录
  293. go services.AddActivityVideoHistory(user, videoId, playSeconds)
  294. //if err != nil {
  295. // br.Msg = "更新失败"
  296. // br.ErrMsg = "更新失败,AddActivityVideoHistory Err:" + err.Error()
  297. // return
  298. //}
  299. } else if sourceType == 3 {
  300. item := models.CygxMicroRoadshowVideoHistory{
  301. VideoId: videoId,
  302. UserId: uid,
  303. Mobile: user.Mobile,
  304. Email: user.Email,
  305. CompanyId: user.CompanyId,
  306. CompanyName: user.CompanyName,
  307. RealName: user.RealName,
  308. SellerName: sellerName,
  309. PlaySeconds: strconv.Itoa(playSeconds),
  310. CreateTime: time.Now(),
  311. ModifyTime: time.Now(),
  312. }
  313. if playSeconds != 0 {
  314. lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
  315. if err != nil {
  316. br.Msg = "操作失败"
  317. br.ErrMsg = "操作失败,GetLastCygxMicroRoadshowVideoHistory Err:" + err.Error()
  318. return
  319. }
  320. err = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
  321. if err != nil {
  322. br.Msg = "更新失败"
  323. br.ErrMsg = "更新失败,UpdateLastCygxActivityVideoHistory Err:" + err.Error()
  324. return
  325. }
  326. } else {
  327. err = models.AddCygxMicroRoadshowVideoHistory(&item)
  328. if err != nil {
  329. br.Msg = "操作失败"
  330. br.ErrMsg = "操作失败,Err:" + err.Error()
  331. return
  332. }
  333. err = models.UpdateCygxActivityVideoCounts(videoId)
  334. if err != nil {
  335. br.Msg = "更新失败"
  336. br.ErrMsg = "更新失败,Err:" + err.Error()
  337. return
  338. }
  339. }
  340. go services.MicroRoadshowVideoUserRmind(user, videoId)
  341. } else if sourceType == 4 {
  342. go services.AddAskserieVideoHistoryRecord(user, videoId, playSeconds)
  343. }
  344. br.Ret = 200
  345. br.Success = true
  346. br.Msg = "操作成功"
  347. return
  348. }
  349. // @Title 微路演新增留言
  350. // @Description 微路演新增留言接口
  351. // @Param request body models.AddVideoCommnetReq true "type json string"
  352. // @Success Ret=200 {object} models.AppointmentResp
  353. // @router /comment/add [post]
  354. func (this *MicroRoadShowController) CommentAdd() {
  355. br := new(models.BaseResponse).Init()
  356. defer func() {
  357. this.Data["json"] = br
  358. this.ServeJSON()
  359. }()
  360. user := this.User
  361. if user == nil {
  362. br.Msg = "请登录"
  363. br.ErrMsg = "请登录,用户信息为空"
  364. br.Ret = 408
  365. return
  366. }
  367. uid := user.UserId
  368. var req models.AddVideoCommnetReq
  369. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  370. if err != nil {
  371. br.Msg = "参数解析异常!"
  372. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  373. return
  374. }
  375. content := req.Content
  376. if content == "" {
  377. br.Msg = "留言内容不能为空!"
  378. return
  379. }
  380. sourceType := req.SourceType
  381. title := req.Title
  382. if sourceType == 0 {
  383. sourceType = 1
  384. }
  385. item := models.CygxArticleComment{
  386. UserId: uid,
  387. CreateTime: time.Now(),
  388. RealName: user.RealName,
  389. Mobile: user.Mobile,
  390. Email: user.Email,
  391. CompanyId: user.CompanyId,
  392. CompanyName: user.CompanyName,
  393. Content: req.Content,
  394. Title: req.Title,
  395. }
  396. //var resourceId int
  397. if sourceType == 1 {
  398. activityVoiceInfo, _ := models.GetCygxActivityVoiceById(req.Id)
  399. if activityVoiceInfo == nil {
  400. br.Msg = "操作失败"
  401. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
  402. return
  403. }
  404. item.ActivityId = activityVoiceInfo.ActivityId
  405. item.Title = activityVoiceInfo.VoiceName
  406. item.ActivityVoiceId = activityVoiceInfo.ActivityVoiceId
  407. title = activityVoiceInfo.VoiceName
  408. //resourceId = activityVoiceInfo.ActivityId
  409. } else if sourceType == 2 {
  410. activityInfo, _ := models.GetCygxActivityVideoById(req.Id)
  411. if activityInfo == nil {
  412. br.Msg = "操作失败"
  413. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
  414. return
  415. }
  416. item.Title = activityInfo.Title
  417. item.VideoId = activityInfo.Id
  418. item.ActivityId = activityInfo.ActivityId
  419. title = activityInfo.Title
  420. //resourceId = activityInfo.ActivityId
  421. } else if sourceType == 3 {
  422. item.VideoId = req.Id
  423. microVideo, e := models.GetMicroRoadshowVideoById(req.Id)
  424. if e != nil {
  425. br.Msg = "操作失败"
  426. br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(req.Id)
  427. return
  428. }
  429. item.Title = microVideo.VideoName
  430. item.IndustryId = microVideo.IndustryId
  431. title = microVideo.VideoName
  432. //resourceId = microVideo.IndustryId
  433. } else if sourceType == 4 {
  434. item.AskserieVideoId = req.Id
  435. go services.AddCygxAskserieVideoCollection(user, item.AskserieVideoId, req.Content)
  436. }
  437. var isResearch bool // 是否属于研选
  438. if sourceType == 2 || sourceType == 3 {
  439. detail, err := models.GetAddActivityInfoById(req.Id)
  440. if err != nil {
  441. br.Msg = "操作失败"
  442. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
  443. return
  444. }
  445. if strings.Contains(detail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  446. isResearch = true
  447. }
  448. }
  449. msgId, err := models.AddArticleComment(&item)
  450. if err != nil {
  451. br.Msg = "提交失败"
  452. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  453. return
  454. }
  455. services.SendWxMsgWithMicroRoadshowAsk(req, user, sourceType, int(msgId), title, isResearch)
  456. br.Ret = 200
  457. br.Success = true
  458. br.Msg = "操作成功"
  459. return
  460. }
  461. // @Title 微路演收藏
  462. // @Description 微路演收藏
  463. // @Param request body models.MicroRoadshowCollectReq true "type json string"
  464. // @Success 200 {object} models.FontsCollectResp
  465. // @router /collect [post]
  466. func (this *MicroRoadShowController) Collect() {
  467. br := new(models.BaseResponse).Init()
  468. defer func() {
  469. this.Data["json"] = br
  470. this.ServeJSON()
  471. }()
  472. user := this.User
  473. if user == nil {
  474. br.Msg = "请重新登录"
  475. br.Ret = 408
  476. return
  477. }
  478. uid := user.UserId
  479. var req models.MicroRoadshowCollectReq
  480. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  481. if err != nil {
  482. br.Msg = "参数解析异常!"
  483. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  484. return
  485. }
  486. if req.SourceType == 1 {
  487. _, err := models.GetCygxActivityVoiceById(req.Id)
  488. if err != nil {
  489. br.Msg = "获取信息失败"
  490. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  491. return
  492. }
  493. count, err := models.GetVoiceCollectCount(uid, req.Id)
  494. if err != nil {
  495. br.Msg = "获取数据失败!"
  496. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  497. return
  498. }
  499. resp := new(models.ArticleCollectResp)
  500. if count <= 0 {
  501. item := new(models.CygxArticleCollect)
  502. item.ActivityVoiceId = req.Id
  503. item.UserId = uid
  504. item.CreateTime = time.Now()
  505. item.Mobile = user.Mobile
  506. item.Email = user.Email
  507. item.CompanyId = user.CompanyId
  508. item.CompanyName = user.CompanyName
  509. item.RealName = user.RealName
  510. _, err = models.AddCygxArticleCollect(item)
  511. if err != nil {
  512. br.Msg = "收藏失败"
  513. br.ErrMsg = "收藏失败,Err:" + err.Error()
  514. return
  515. }
  516. br.Msg = "收藏成功"
  517. resp.Status = 1
  518. // 文章收藏消息发送
  519. //go services.ArticleUserRemind(user, detail, 2)
  520. } else {
  521. err = models.RemoveVoiceCollect(uid, req.Id)
  522. if err != nil {
  523. br.Msg = "取消收藏失败"
  524. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  525. return
  526. }
  527. br.Msg = "已取消收藏"
  528. resp.Status = 2
  529. }
  530. collectTotal, err := models.GetVoiceCollectUsersCount(req.Id)
  531. if err != nil {
  532. br.Msg = "获取数据失败"
  533. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  534. return
  535. }
  536. resp.CollectCount = collectTotal
  537. br.Ret = 200
  538. br.Success = true
  539. br.Data = resp
  540. } else if req.SourceType == 2 {
  541. _, err := models.GetCygxActivityVideoById(req.Id)
  542. if err != nil {
  543. br.Msg = "获取信息失败"
  544. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  545. return
  546. }
  547. count, err := models.GetActivityVideoCollectCount(uid, req.Id)
  548. if err != nil {
  549. br.Msg = "获取数据失败!"
  550. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  551. return
  552. }
  553. resp := new(models.ArticleCollectResp)
  554. if count <= 0 {
  555. item := new(models.CygxArticleCollect)
  556. item.ActivityVideoId = req.Id
  557. item.UserId = uid
  558. item.CreateTime = time.Now()
  559. item.Mobile = user.Mobile
  560. item.Email = user.Email
  561. item.CompanyId = user.CompanyId
  562. item.CompanyName = user.CompanyName
  563. item.RealName = user.RealName
  564. _, err = models.AddCygxArticleCollect(item)
  565. if err != nil {
  566. br.Msg = "收藏失败"
  567. br.ErrMsg = "收藏失败,Err:" + err.Error()
  568. return
  569. }
  570. br.Msg = "收藏成功"
  571. resp.Status = 1
  572. // 文章收藏消息发送
  573. //go services.ArticleUserRemind(user, detail, 2)
  574. } else {
  575. err = models.RemoveActivityVideoCollect(uid, req.Id)
  576. if err != nil {
  577. br.Msg = "取消收藏失败"
  578. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  579. return
  580. }
  581. br.Msg = "已取消收藏"
  582. resp.Status = 2
  583. }
  584. collectTotal, err := models.GetActivityVideoCollectUsersCount(req.Id)
  585. if err != nil {
  586. br.Msg = "获取数据失败"
  587. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  588. return
  589. }
  590. resp.CollectCount = collectTotal
  591. br.Ret = 200
  592. br.Success = true
  593. br.Data = resp
  594. } else if req.SourceType == 3 {
  595. _, err := models.GetMicroRoadshowVideoById(req.Id)
  596. if err != nil {
  597. br.Msg = "获取信息失败"
  598. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  599. return
  600. }
  601. count, err := models.GetVideoCollectCount(uid, req.Id)
  602. if err != nil {
  603. br.Msg = "获取数据失败!"
  604. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  605. return
  606. }
  607. resp := new(models.ArticleCollectResp)
  608. if count <= 0 {
  609. item := new(models.CygxArticleCollect)
  610. item.VideoId = req.Id
  611. item.UserId = uid
  612. item.CreateTime = time.Now()
  613. item.Mobile = user.Mobile
  614. item.Email = user.Email
  615. item.CompanyId = user.CompanyId
  616. item.CompanyName = user.CompanyName
  617. item.RealName = user.RealName
  618. _, err = models.AddCygxArticleCollect(item)
  619. if err != nil {
  620. br.Msg = "收藏失败"
  621. br.ErrMsg = "收藏失败,Err:" + err.Error()
  622. return
  623. }
  624. br.Msg = "收藏成功"
  625. resp.Status = 1
  626. // 文章收藏消息发送
  627. //go services.ArticleUserRemind(user, detail, 2)
  628. } else {
  629. err = models.RemoveVideoCollect(uid, req.Id)
  630. if err != nil {
  631. br.Msg = "取消收藏失败"
  632. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  633. return
  634. }
  635. br.Msg = "已取消收藏"
  636. resp.Status = 2
  637. }
  638. collectTotal, err := models.GetVideoCollectUsersCount(req.Id)
  639. if err != nil {
  640. br.Msg = "获取数据失败"
  641. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  642. return
  643. }
  644. resp.CollectCount = collectTotal
  645. br.Ret = 200
  646. br.Success = true
  647. br.Data = resp
  648. } else if req.SourceType == 4 {
  649. // 系列问答视频收藏
  650. count, err := models.GetAskserieVideoCount(uid, req.Id)
  651. if err != nil {
  652. br.Msg = "获取数据失败!"
  653. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  654. return
  655. }
  656. resp := new(models.ArticleCollectResp)
  657. if count <= 0 {
  658. item := new(models.CygxAskserieVideoCollect)
  659. item.AskserieVideoId = req.Id
  660. item.UserId = uid
  661. item.CreateTime = time.Now()
  662. item.Mobile = user.Mobile
  663. item.Email = user.Email
  664. item.CompanyId = user.CompanyId
  665. item.CompanyName = user.CompanyName
  666. item.RealName = user.RealName
  667. item.RegisterPlatform = utils.REGISTER_PLATFORM
  668. err = models.AddCygxAskserieVideoCollect(item)
  669. if err != nil {
  670. br.Msg = "收藏失败"
  671. br.ErrMsg = "收藏失败,Err:" + err.Error()
  672. return
  673. }
  674. br.Msg = "收藏成功"
  675. resp.Status = 1
  676. // 文章收藏消息发送
  677. //go services.ArticleUserRemind(user, detail, 2)
  678. } else {
  679. err = models.RemoveAskserieVideoCollect(uid, req.Id)
  680. if err != nil {
  681. br.Msg = "取消收藏失败"
  682. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  683. return
  684. }
  685. br.Msg = "已取消收藏"
  686. resp.Status = 2
  687. }
  688. br.Ret = 200
  689. br.Success = true
  690. br.Data = resp
  691. }
  692. }