micro_roadshow.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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 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. if sourceType == 0 {
  293. sourceType = 1
  294. }
  295. if sourceType == 1 {
  296. //添加活动音频的播放记录
  297. go services.AddActivityVoiceHistory(user, sourceId, playSeconds)
  298. } else if sourceType == 2 {
  299. //添加活动视频的播放记录
  300. go services.AddActivityVideoHistory(user, sourceId, playSeconds)
  301. } else if sourceType == 3 {
  302. //添加产业视频播放记录
  303. go services.AddMicroRoadshowVideoRecord(user, sourceId, playSeconds)
  304. } else if sourceType == 4 {
  305. //问答系列音频播放记录
  306. go services.AddAskserieVideoHistoryRecord(user, sourceId, playSeconds)
  307. }
  308. go services.AddAllCygxVoiceAndVideoHistory(user, sourceId, sourceType, playSeconds)
  309. br.Ret = 200
  310. br.Success = true
  311. br.Msg = "操作成功"
  312. return
  313. }
  314. // @Title 微路演新增留言
  315. // @Description 微路演新增留言接口
  316. // @Param request body models.AddVideoCommnetReq true "type json string"
  317. // @Success Ret=200 {object} models.AppointmentResp
  318. // @router /comment/add [post]
  319. func (this *MicroRoadShowController) CommentAdd() {
  320. br := new(models.BaseResponse).Init()
  321. defer func() {
  322. this.Data["json"] = br
  323. this.ServeJSON()
  324. }()
  325. user := this.User
  326. if user == nil {
  327. br.Msg = "请登录"
  328. br.ErrMsg = "请登录,用户信息为空"
  329. br.Ret = 408
  330. return
  331. }
  332. uid := user.UserId
  333. var req models.AddVideoCommnetReq
  334. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  335. if err != nil {
  336. br.Msg = "参数解析异常!"
  337. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  338. return
  339. }
  340. content := req.Content
  341. if content == "" {
  342. br.Msg = "留言内容不能为空!"
  343. return
  344. }
  345. sourceType := req.SourceType
  346. sourceId := req.SourceId
  347. title := req.Title
  348. if sourceType == 0 {
  349. sourceType = 1
  350. }
  351. item := models.CygxArticleComment{
  352. UserId: uid,
  353. CreateTime: time.Now(),
  354. RealName: user.RealName,
  355. Mobile: user.Mobile,
  356. Email: user.Email,
  357. CompanyId: user.CompanyId,
  358. CompanyName: user.CompanyName,
  359. Content: req.Content,
  360. Title: req.Title,
  361. }
  362. //var resourceId int
  363. if sourceType == 1 {
  364. activityVoiceInfo, _ := models.GetCygxActivityVoiceByActivityId(sourceId)
  365. if activityVoiceInfo == nil {
  366. br.Msg = "操作失败"
  367. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
  368. return
  369. }
  370. item.ActivityId = activityVoiceInfo.ActivityId
  371. item.Title = activityVoiceInfo.VoiceName
  372. item.ActivityVoiceId = activityVoiceInfo.ActivityVoiceId
  373. title = activityVoiceInfo.VoiceName
  374. err = models.UpdateActivityVoiceCommentNum(sourceId)
  375. if err != nil {
  376. br.Msg = "操作失败"
  377. br.ErrMsg = "操作失败 ,更新活动音频留言次数失败:" + strconv.Itoa(sourceId)
  378. return
  379. }
  380. } else if sourceType == 2 {
  381. activityInfo, _ := models.GetCygxActivityVideoByActivityIdInfo(sourceId)
  382. if activityInfo == nil {
  383. br.Msg = "操作失败"
  384. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
  385. return
  386. }
  387. item.Title = activityInfo.Title
  388. item.VideoId = activityInfo.Id
  389. item.ActivityId = activityInfo.ActivityId
  390. title = activityInfo.Title
  391. err = models.UpdateActivityVideoCommentNum(sourceId)
  392. if err != nil {
  393. br.Msg = "操作失败"
  394. br.ErrMsg = "操作失败 ,更新活动视频留言次数失败:" + strconv.Itoa(sourceId)
  395. return
  396. }
  397. } else if sourceType == 3 {
  398. item.VideoId = sourceId
  399. microVideo, e := models.GetMicroRoadshowVideoById(sourceId)
  400. if e != nil {
  401. br.Msg = "操作失败"
  402. br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(sourceId)
  403. return
  404. }
  405. item.Title = microVideo.VideoName
  406. item.IndustryId = microVideo.IndustryId
  407. title = microVideo.VideoName
  408. //resourceId = microVideo.IndustryId
  409. } else if sourceType == 4 {
  410. item.AskserieVideoId = sourceId
  411. go services.AddCygxAskserieVideoCollection(user, item.AskserieVideoId, req.Content)
  412. }
  413. var isResearch bool // 是否属于研选
  414. if sourceType == 1 || sourceType == 2 {
  415. detail, err := models.GetAddActivityInfoById(sourceId)
  416. if err != nil {
  417. br.Msg = "操作失败"
  418. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
  419. return
  420. }
  421. if strings.Contains(detail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  422. isResearch = true
  423. }
  424. }
  425. msgId, err := models.AddArticleComment(&item)
  426. if err != nil {
  427. br.Msg = "提交失败"
  428. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  429. return
  430. }
  431. services.SendWxMsgWithMicroRoadshowAsk(req, user, sourceType, int(msgId), title, isResearch)
  432. br.Ret = 200
  433. br.Success = true
  434. br.Msg = "操作成功"
  435. return
  436. }
  437. // @Title 微路演收藏
  438. // @Description 微路演收藏
  439. // @Param request body models.MicroRoadshowCollectReq true "type json string"
  440. // @Success 200 {object} models.FontsCollectResp
  441. // @router /collect [post]
  442. func (this *MicroRoadShowController) Collect() {
  443. br := new(models.BaseResponse).Init()
  444. defer func() {
  445. this.Data["json"] = br
  446. this.ServeJSON()
  447. }()
  448. user := this.User
  449. if user == nil {
  450. br.Msg = "请重新登录"
  451. br.Ret = 408
  452. return
  453. }
  454. uid := user.UserId
  455. var req models.MicroRoadshowCollectReq
  456. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  457. if err != nil {
  458. br.Msg = "参数解析异常!"
  459. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  460. return
  461. }
  462. sourceId := req.SourceId
  463. if req.SourceType == 1 {
  464. detail, err := models.GetCygxActivityVoiceByActivityId(sourceId)
  465. if err != nil {
  466. br.Msg = "获取信息失败"
  467. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  468. return
  469. }
  470. count, err := models.GetVoiceCollectCount(uid, detail.ActivityVoiceId)
  471. if err != nil {
  472. br.Msg = "获取数据失败!"
  473. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  474. return
  475. }
  476. resp := new(models.ArticleCollectResp)
  477. if count <= 0 {
  478. item := new(models.CygxArticleCollect)
  479. item.ActivityVoiceId = detail.ActivityVoiceId
  480. item.UserId = uid
  481. item.CreateTime = time.Now()
  482. item.Mobile = user.Mobile
  483. item.Email = user.Email
  484. item.CompanyId = user.CompanyId
  485. item.CompanyName = user.CompanyName
  486. item.RealName = user.RealName
  487. _, err = models.AddCygxArticleCollect(item)
  488. if err != nil {
  489. br.Msg = "收藏失败"
  490. br.ErrMsg = "收藏失败,Err:" + err.Error()
  491. return
  492. }
  493. br.Msg = "收藏成功"
  494. resp.Status = 1
  495. // 文章收藏消息发送
  496. //go services.ArticleUserRemind(user, detail, 2)
  497. } else {
  498. err = models.RemoveVoiceCollect(uid, detail.ActivityVoiceId)
  499. if err != nil {
  500. br.Msg = "取消收藏失败"
  501. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  502. return
  503. }
  504. br.Msg = "已取消收藏"
  505. resp.Status = 2
  506. }
  507. collectTotal, err := models.GetVoiceCollectUsersCount(detail.ActivityVoiceId)
  508. if err != nil {
  509. br.Msg = "获取数据失败"
  510. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  511. return
  512. }
  513. resp.CollectCount = collectTotal
  514. br.Ret = 200
  515. br.Success = true
  516. br.Data = resp
  517. } else if req.SourceType == 2 {
  518. detail, err := models.GetCygxActivityVideoByActivityIdInfo(sourceId)
  519. if err != nil {
  520. br.Msg = "获取信息失败"
  521. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  522. return
  523. }
  524. count, err := models.GetActivityVideoCollectCount(uid, detail.Id)
  525. if err != nil {
  526. br.Msg = "获取数据失败!"
  527. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  528. return
  529. }
  530. resp := new(models.ArticleCollectResp)
  531. if count <= 0 {
  532. item := new(models.CygxArticleCollect)
  533. item.ActivityVideoId = detail.Id
  534. item.UserId = uid
  535. item.CreateTime = time.Now()
  536. item.Mobile = user.Mobile
  537. item.Email = user.Email
  538. item.CompanyId = user.CompanyId
  539. item.CompanyName = user.CompanyName
  540. item.RealName = user.RealName
  541. _, err = models.AddCygxArticleCollect(item)
  542. if err != nil {
  543. br.Msg = "收藏失败"
  544. br.ErrMsg = "收藏失败,Err:" + err.Error()
  545. return
  546. }
  547. br.Msg = "收藏成功"
  548. resp.Status = 1
  549. // 文章收藏消息发送
  550. //go services.ArticleUserRemind(user, detail, 2)
  551. } else {
  552. err = models.RemoveActivityVideoCollect(uid, detail.Id)
  553. if err != nil {
  554. br.Msg = "取消收藏失败"
  555. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  556. return
  557. }
  558. br.Msg = "已取消收藏"
  559. resp.Status = 2
  560. }
  561. collectTotal, err := models.GetActivityVideoCollectUsersCount(detail.Id)
  562. if err != nil {
  563. br.Msg = "获取数据失败"
  564. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  565. return
  566. }
  567. resp.CollectCount = collectTotal
  568. br.Ret = 200
  569. br.Success = true
  570. br.Data = resp
  571. } else if req.SourceType == 3 {
  572. _, err := models.GetMicroRoadshowVideoById(sourceId)
  573. if err != nil {
  574. br.Msg = "获取信息失败"
  575. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  576. return
  577. }
  578. count, err := models.GetVideoCollectCount(uid, sourceId)
  579. if err != nil {
  580. br.Msg = "获取数据失败!"
  581. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  582. return
  583. }
  584. resp := new(models.ArticleCollectResp)
  585. if count <= 0 {
  586. item := new(models.CygxArticleCollect)
  587. item.VideoId = sourceId
  588. item.UserId = uid
  589. item.CreateTime = time.Now()
  590. item.Mobile = user.Mobile
  591. item.Email = user.Email
  592. item.CompanyId = user.CompanyId
  593. item.CompanyName = user.CompanyName
  594. item.RealName = user.RealName
  595. _, err = models.AddCygxArticleCollect(item)
  596. if err != nil {
  597. br.Msg = "收藏失败"
  598. br.ErrMsg = "收藏失败,Err:" + err.Error()
  599. return
  600. }
  601. br.Msg = "收藏成功"
  602. resp.Status = 1
  603. // 文章收藏消息发送
  604. //go services.ArticleUserRemind(user, detail, 2)
  605. } else {
  606. err = models.RemoveVideoCollect(uid, sourceId)
  607. if err != nil {
  608. br.Msg = "取消收藏失败"
  609. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  610. return
  611. }
  612. br.Msg = "已取消收藏"
  613. resp.Status = 2
  614. }
  615. collectTotal, err := models.GetVideoCollectUsersCount(sourceId)
  616. if err != nil {
  617. br.Msg = "获取数据失败"
  618. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  619. return
  620. }
  621. resp.CollectCount = collectTotal
  622. br.Ret = 200
  623. br.Success = true
  624. br.Data = resp
  625. } else if req.SourceType == 4 {
  626. // 系列问答视频收藏
  627. count, err := models.GetAskserieVideoCount(uid, sourceId)
  628. if err != nil {
  629. br.Msg = "获取数据失败!"
  630. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  631. return
  632. }
  633. resp := new(models.ArticleCollectResp)
  634. if count <= 0 {
  635. item := new(models.CygxAskserieVideoCollect)
  636. item.AskserieVideoId = sourceId
  637. item.UserId = uid
  638. item.CreateTime = time.Now()
  639. item.ModifyTime = time.Now()
  640. item.Mobile = user.Mobile
  641. item.Email = user.Email
  642. item.CompanyId = user.CompanyId
  643. item.CompanyName = user.CompanyName
  644. item.RealName = user.RealName
  645. item.RegisterPlatform = utils.REGISTER_PLATFORM
  646. err = models.AddCygxAskserieVideoCollect(item)
  647. if err != nil {
  648. br.Msg = "收藏失败"
  649. br.ErrMsg = "收藏失败,Err:" + err.Error()
  650. return
  651. }
  652. br.Msg = "收藏成功"
  653. resp.Status = 1
  654. // 文章收藏消息发送
  655. } else {
  656. err = models.RemoveAskserieVideoCollect(uid, sourceId)
  657. if err != nil {
  658. br.Msg = "取消收藏失败"
  659. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  660. return
  661. }
  662. br.Msg = "已取消收藏"
  663. resp.Status = 2
  664. }
  665. br.Ret = 200
  666. br.Success = true
  667. br.Data = resp
  668. }
  669. }
  670. // @Title 问答系列视频详情
  671. // @Description 问答系列视频详情接口
  672. // @Param VideoId query int true "视频ID"
  673. // @Success 200 {object} models.IndustryVideoDetailResp
  674. // @router /askserie_video/detail [get]
  675. func (this *MicroRoadShowController) AskserieVideoDetail() {
  676. br := new(models.BaseResponse).Init()
  677. defer func() {
  678. this.Data["json"] = br
  679. this.ServeJSON()
  680. }()
  681. user := this.User
  682. if user == nil {
  683. br.Msg = "请重新登录"
  684. br.Ret = 408
  685. return
  686. }
  687. askserieVideoId, _ := this.GetInt("VideoId")
  688. videoSimple, au, err := services.GetAskserieVideoDetailById(user, askserieVideoId)
  689. if err != nil {
  690. br.Msg = "获取失败"
  691. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  692. return
  693. }
  694. resp := new(models.IndustryVideoDetailResp)
  695. resp.IndustryVideo = videoSimple
  696. resp.AuthInfo = au
  697. br.Ret = 200
  698. br.Success = true
  699. br.Msg = "获取成功"
  700. br.Data = resp
  701. }