micro_roadshow.go 21 KB

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