micro_roadshow.go 22 KB

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