micro_roadshow.go 21 KB

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