micro_roadshow.go 21 KB

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