micro_roadshow.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/services"
  7. "hongze/hongze_cygx/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. filter := this.GetString("Filter")
  45. chartPermissionIds := this.GetString("ChartPermissionIds")
  46. sourceId, _ := this.GetInt("SourceId")
  47. sourceType, _ := this.GetInt("SourceType")
  48. searchType := this.GetString("SearchType")
  49. if pageSize <= 0 {
  50. pageSize = utils.PageSize20
  51. }
  52. if currentIndex <= 0 {
  53. currentIndex = 1
  54. }
  55. var keyWordArr []string
  56. var err error
  57. if keywords != "" {
  58. keyWordArr, err = services.GetIndustryMapNameSliceV3(keywords)
  59. if err != nil {
  60. br.Msg = "获取失败"
  61. br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
  62. return
  63. }
  64. keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  65. }
  66. var list []*models.MicroRoadShowPageList
  67. var total int
  68. var e error
  69. // 微路演列表
  70. list, total, e = services.GetMicroRoadShowPageListV12(pageSize, currentIndex, sourceId, sourceType, filter, keywords, searchType, chartPermissionIds)
  71. if e != nil {
  72. br.Msg = "获取失败"
  73. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  74. return
  75. }
  76. userId := user.UserId
  77. listMycollect, err := models.GetUserMicroRoadshowCollectList(userId)
  78. if err != nil {
  79. br.Msg = "获取数据失败"
  80. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  81. return
  82. }
  83. mapaudioIds := make(map[int]int) //活动音频
  84. mapvideoIds := make(map[int]int) // 微路演视频
  85. mapactivityVideoIds := make(map[int]int) // 活动视频
  86. mapAskserieVideoIds := make(map[int]int) // 问答系列音频
  87. for _, item := range listMycollect {
  88. if item.ActivityVoiceId > 0 {
  89. mapaudioIds[item.ActivityVoiceId] = item.ActivityVoiceId
  90. } else if item.VideoId > 0 {
  91. mapvideoIds[item.VideoId] = item.VideoId
  92. } else if item.ActivityVideoId > 0 {
  93. mapactivityVideoIds[item.ActivityVoiceId] = item.ActivityVoiceId
  94. }
  95. }
  96. listAskserieVideoCollect, err := models.GetUserCygxAskserieVideoCollectList(userId)
  97. if err != nil {
  98. br.Msg = "获取数据失败"
  99. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  100. return
  101. }
  102. for _, v := range listAskserieVideoCollect {
  103. if v.AskserieVideoId > 0 {
  104. mapAskserieVideoIds[v.AskserieVideoId] = v.AskserieVideoId
  105. }
  106. }
  107. for _, item := range list {
  108. if item.Type == 1 {
  109. //音频
  110. if mapaudioIds[item.Id] > 0 {
  111. item.IsCollect = true
  112. }
  113. } else if item.Type == 2 {
  114. //活动视频
  115. if mapactivityVideoIds[item.Id] > 0 {
  116. item.IsCollect = true
  117. }
  118. } else if item.Type == 3 {
  119. //微路演视频
  120. if mapvideoIds[item.Id] > 0 {
  121. item.IsCollect = true
  122. }
  123. } else if item.Type == 4 {
  124. //系列问答视频
  125. if mapAskserieVideoIds[item.SourceId] > 0 {
  126. item.IsCollect = true
  127. }
  128. }
  129. }
  130. // 用户权限
  131. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  132. if e != nil {
  133. br.Msg = "获取失败"
  134. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  135. return
  136. }
  137. // 获取默认图配置
  138. audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
  139. if e != nil {
  140. br.Msg = "获取失败"
  141. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  142. return
  143. }
  144. for i := range list {
  145. // 权限
  146. au := new(models.UserPermissionAuthInfo)
  147. au.SellerName = authInfo.SellerName
  148. au.SellerMobile = authInfo.SellerMobile
  149. au.HasPermission = authInfo.HasPermission
  150. au.OperationMode = authInfo.OperationMode
  151. if au.HasPermission == 1 {
  152. // 非宏观权限进一步判断是否有权限
  153. if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
  154. au.HasPermission = 2
  155. }
  156. }
  157. // 无权限的弹框提示
  158. if au.HasPermission != 1 {
  159. if au.OperationMode == services.UserPermissionOperationModeCall {
  160. if list[i].Type == 1 {
  161. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  162. } else {
  163. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  164. }
  165. } else {
  166. if list[i].Type == 1 {
  167. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  168. } else {
  169. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  170. }
  171. }
  172. }
  173. list[i].AuthInfo = au
  174. list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
  175. // 默认图
  176. if list[i].BackgroundImg == "" {
  177. if list[i].Type == 1 {
  178. list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
  179. } else {
  180. list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
  181. }
  182. }
  183. // 分享图
  184. if list[i].ShareImg == "" {
  185. if list[i].Type == 1 {
  186. list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
  187. } else {
  188. list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
  189. }
  190. }
  191. }
  192. if len(list) == 0 {
  193. list = make([]*models.MicroRoadShowPageList, 0)
  194. }
  195. resp := new(models.MicroRoadShowListResp)
  196. page := paging.GetPaging(currentIndex, pageSize, total)
  197. resp.List = list
  198. resp.Paging = page
  199. br.Ret = 200
  200. br.Success = true
  201. br.Msg = "获取成功"
  202. br.Data = resp
  203. }
  204. // @Title 记录用户浏览音频回放接口
  205. // @Description 记录用户浏览音频回放接口
  206. // @Param request body models.ActivityIdRep true "type json string"
  207. // @Success Ret=200 {object} models.AppointmentResp
  208. // @router /videoHistory/add [post]
  209. func (this *MicroRoadShowController) VideoHistoryAdd() {
  210. br := new(models.BaseResponse).Init()
  211. defer func() {
  212. this.Data["json"] = br
  213. this.ServeJSON()
  214. }()
  215. user := this.User
  216. if user == nil {
  217. br.Msg = "请登录"
  218. br.ErrMsg = "请登录,用户信息为空"
  219. br.Ret = 408
  220. return
  221. }
  222. var req models.AddVideoHistoryReq
  223. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  224. if err != nil {
  225. br.Msg = "参数解析异常!"
  226. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  227. return
  228. }
  229. sourceId := req.SourceId
  230. playSeconds := req.PlaySeconds
  231. sourceType := req.SourceType
  232. if sourceType == 0 {
  233. sourceType = 1
  234. }
  235. if sourceType == 1 {
  236. //添加活动音频的播放记录
  237. go services.AddActivityVoiceHistory(user, sourceId, playSeconds)
  238. } else if sourceType == 2 {
  239. //添加活动视频的播放记录
  240. go services.AddActivityVideoHistory(user, sourceId, playSeconds)
  241. } else if sourceType == 3 {
  242. // 添加产业视频播放记录
  243. go services.AddMicroRoadshowVideoRecord(user, sourceId, playSeconds)
  244. } else if sourceType == 4 {
  245. go services.AddAskserieVideoHistoryRecord(user, sourceId, playSeconds)
  246. }
  247. br.Ret = 200
  248. br.Success = true
  249. br.Msg = "操作成功"
  250. return
  251. }
  252. // @Title 微路演新增留言
  253. // @Description 微路演新增留言接口
  254. // @Param request body models.AddVideoCommnetReq true "type json string"
  255. // @Success Ret=200 {object} models.AppointmentResp
  256. // @router /comment/add [post]
  257. func (this *MicroRoadShowController) CommentAdd() {
  258. br := new(models.BaseResponse).Init()
  259. defer func() {
  260. this.Data["json"] = br
  261. this.ServeJSON()
  262. }()
  263. user := this.User
  264. if user == nil {
  265. br.Msg = "请登录"
  266. br.ErrMsg = "请登录,用户信息为空"
  267. br.Ret = 408
  268. return
  269. }
  270. uid := user.UserId
  271. var req models.AddVideoCommnetReq
  272. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  273. if err != nil {
  274. br.Msg = "参数解析异常!"
  275. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  276. return
  277. }
  278. var isResearch bool // 是否属于研选
  279. sourceType := req.SourceType
  280. title := req.Title
  281. if sourceType == 0 {
  282. sourceType = 1
  283. }
  284. item := models.CygxArticleComment{
  285. UserId: uid,
  286. CreateTime: time.Now(),
  287. RealName: user.RealName,
  288. Mobile: user.Mobile,
  289. Email: user.Email,
  290. CompanyId: user.CompanyId,
  291. CompanyName: user.CompanyName,
  292. Content: req.Content,
  293. Title: req.Title,
  294. }
  295. sourceId := req.SourceId
  296. //var resourceId int
  297. if sourceType == 1 {
  298. activityVoiceInfo, _ := models.GetCygxActivityVoiceByActivityId(sourceId)
  299. if activityVoiceInfo == nil {
  300. br.Msg = "操作失败"
  301. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
  302. return
  303. }
  304. item.ActivityId = sourceId
  305. item.ActivityVoiceId = activityVoiceInfo.ActivityVoiceId
  306. //resourceId = activityVoiceInfo.ActivityId
  307. } else if sourceType == 2 {
  308. activityInfo, _ := models.GetCygxActivityVideoByActivityId(sourceId)
  309. if activityInfo == nil {
  310. br.Msg = "操作失败"
  311. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
  312. return
  313. }
  314. item.VideoId = activityInfo.VideoId
  315. item.ActivityId = sourceId
  316. //resourceId = activityInfo.ActivityId
  317. } else if sourceType == 3 {
  318. item.VideoId = sourceId
  319. microVideo, e := models.GetMicroRoadshowVideoById(sourceId)
  320. if e != nil {
  321. br.Msg = "操作失败"
  322. br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(sourceId)
  323. return
  324. }
  325. item.IndustryId = microVideo.IndustryId
  326. //resourceId = microVideo.IndustryId
  327. } else if sourceType == 4 {
  328. item.AskserieVideoId = sourceId
  329. go services.AddCygxAskserieVideoCollection(user, item.AskserieVideoId, req.Content)
  330. }
  331. if sourceType == 2 || sourceType == 3 {
  332. detail, err := models.GetAddActivityInfoById(sourceId)
  333. if err != nil {
  334. br.Msg = "操作失败"
  335. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
  336. return
  337. }
  338. if strings.Contains(detail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  339. isResearch = true
  340. }
  341. }
  342. msgId, err := models.AddArticleComment(&item)
  343. if err != nil {
  344. br.Msg = "提交失败"
  345. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  346. return
  347. }
  348. services.SendWxMsgWithMicroRoadshowAsk(req, user, sourceType, int(msgId), title, isResearch)
  349. br.Ret = 200
  350. br.Success = true
  351. br.Msg = "操作成功"
  352. return
  353. }
  354. // @Title 微路演收藏
  355. // @Description 微路演收藏
  356. // @Param request body models.MicroRoadshowCollectReq true "type json string"
  357. // @Success 200 {object} models.FontsCollectResp
  358. // @router /collect [post]
  359. func (this *MicroRoadShowController) Collect() {
  360. br := new(models.BaseResponse).Init()
  361. defer func() {
  362. this.Data["json"] = br
  363. this.ServeJSON()
  364. }()
  365. user := this.User
  366. if user == nil {
  367. br.Msg = "请重新登录"
  368. br.Ret = 408
  369. return
  370. }
  371. uid := user.UserId
  372. var req models.MicroRoadshowCollectReq
  373. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  374. if err != nil {
  375. br.Msg = "参数解析异常!"
  376. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  377. return
  378. }
  379. sourceId := req.SourceId
  380. if req.SourceType == 1 {
  381. _, err := models.GetCygxActivityVoiceById(sourceId)
  382. if err != nil {
  383. br.Msg = "获取信息失败"
  384. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  385. return
  386. }
  387. count, err := models.GetVoiceCollectCount(uid, sourceId)
  388. if err != nil {
  389. br.Msg = "获取数据失败!"
  390. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  391. return
  392. }
  393. resp := new(models.ArticleCollectResp)
  394. if count <= 0 {
  395. item := new(models.CygxArticleCollect)
  396. item.ActivityVoiceId = sourceId
  397. item.UserId = uid
  398. item.CreateTime = time.Now()
  399. item.Mobile = user.Mobile
  400. item.Email = user.Email
  401. item.CompanyId = user.CompanyId
  402. item.CompanyName = user.CompanyName
  403. item.RealName = user.RealName
  404. _, err = models.AddCygxArticleCollect(item)
  405. if err != nil {
  406. br.Msg = "收藏失败"
  407. br.ErrMsg = "收藏失败,Err:" + err.Error()
  408. return
  409. }
  410. br.Msg = "收藏成功"
  411. resp.Status = 1
  412. // 文章收藏消息发送
  413. //go services.ArticleUserRemind(user, detail, 2)
  414. } else {
  415. err = models.RemoveVoiceCollect(uid, sourceId)
  416. if err != nil {
  417. br.Msg = "取消收藏失败"
  418. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  419. return
  420. }
  421. br.Msg = "已取消收藏"
  422. resp.Status = 2
  423. }
  424. collectTotal, err := models.GetVoiceCollectUsersCount(sourceId)
  425. if err != nil {
  426. br.Msg = "获取数据失败"
  427. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  428. return
  429. }
  430. resp.CollectCount = collectTotal
  431. br.Ret = 200
  432. br.Success = true
  433. br.Data = resp
  434. } else if req.SourceType == 2 {
  435. _, err := models.GetCygxActivityVideoById(sourceId)
  436. if err != nil {
  437. br.Msg = "获取信息失败"
  438. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  439. return
  440. }
  441. count, err := models.GetActivityVideoCollectCount(uid, sourceId)
  442. if err != nil {
  443. br.Msg = "获取数据失败!"
  444. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  445. return
  446. }
  447. resp := new(models.ArticleCollectResp)
  448. if count <= 0 {
  449. item := new(models.CygxArticleCollect)
  450. item.ActivityVideoId = sourceId
  451. item.UserId = uid
  452. item.CreateTime = time.Now()
  453. item.ModifyTime = time.Now()
  454. item.Mobile = user.Mobile
  455. item.Email = user.Email
  456. item.CompanyId = user.CompanyId
  457. item.CompanyName = user.CompanyName
  458. item.RealName = user.RealName
  459. _, err = models.AddCygxArticleCollect(item)
  460. if err != nil {
  461. br.Msg = "收藏失败"
  462. br.ErrMsg = "收藏失败,Err:" + err.Error()
  463. return
  464. }
  465. br.Msg = "收藏成功"
  466. resp.Status = 1
  467. // 文章收藏消息发送
  468. //go services.ArticleUserRemind(user, detail, 2)
  469. } else {
  470. err = models.RemoveActivityVideoCollect(uid, sourceId)
  471. if err != nil {
  472. br.Msg = "取消收藏失败"
  473. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  474. return
  475. }
  476. br.Msg = "已取消收藏"
  477. resp.Status = 2
  478. }
  479. collectTotal, err := models.GetActivityVideoCollectUsersCount(sourceId)
  480. if err != nil {
  481. br.Msg = "获取数据失败"
  482. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  483. return
  484. }
  485. resp.CollectCount = collectTotal
  486. br.Ret = 200
  487. br.Success = true
  488. br.Data = resp
  489. } else if req.SourceType == 3 {
  490. _, err := models.GetMicroRoadshowVideoById(sourceId)
  491. if err != nil {
  492. br.Msg = "获取信息失败"
  493. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  494. return
  495. }
  496. count, err := models.GetVideoCollectCount(uid, sourceId)
  497. if err != nil {
  498. br.Msg = "获取数据失败!"
  499. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  500. return
  501. }
  502. resp := new(models.ArticleCollectResp)
  503. if count <= 0 {
  504. item := new(models.CygxArticleCollect)
  505. item.VideoId = sourceId
  506. item.UserId = uid
  507. item.CreateTime = time.Now()
  508. item.Mobile = user.Mobile
  509. item.Email = user.Email
  510. item.CompanyId = user.CompanyId
  511. item.CompanyName = user.CompanyName
  512. item.RealName = user.RealName
  513. _, err = models.AddCygxArticleCollect(item)
  514. if err != nil {
  515. br.Msg = "收藏失败"
  516. br.ErrMsg = "收藏失败,Err:" + err.Error()
  517. return
  518. }
  519. br.Msg = "收藏成功"
  520. resp.Status = 1
  521. // 文章收藏消息发送
  522. //go services.ArticleUserRemind(user, detail, 2)
  523. } else {
  524. err = models.RemoveVideoCollect(uid, sourceId)
  525. if err != nil {
  526. br.Msg = "取消收藏失败"
  527. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  528. return
  529. }
  530. br.Msg = "已取消收藏"
  531. resp.Status = 2
  532. }
  533. collectTotal, err := models.GetVideoCollectUsersCount(sourceId)
  534. if err != nil {
  535. br.Msg = "获取数据失败"
  536. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  537. return
  538. }
  539. resp.CollectCount = collectTotal
  540. br.Ret = 200
  541. br.Success = true
  542. br.Data = resp
  543. } else if req.SourceType == 4 {
  544. // 系列问答视频收藏
  545. count, err := models.GetAskserieVideoCount(uid, sourceId)
  546. if err != nil {
  547. br.Msg = "获取数据失败!"
  548. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  549. return
  550. }
  551. resp := new(models.ArticleCollectResp)
  552. if count <= 0 {
  553. item := new(models.CygxAskserieVideoCollect)
  554. item.AskserieVideoId = sourceId
  555. item.UserId = uid
  556. item.CreateTime = time.Now()
  557. item.Mobile = user.Mobile
  558. item.Email = user.Email
  559. item.CompanyId = user.CompanyId
  560. item.CompanyName = user.CompanyName
  561. item.RealName = user.RealName
  562. item.RegisterPlatform = utils.REGISTER_PLATFORM
  563. err = models.AddCygxAskserieVideoCollect(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.RemoveAskserieVideoCollect(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. br.Ret = 200
  584. br.Success = true
  585. br.Data = resp
  586. }
  587. }
  588. // @Title 我的收藏微路演列表
  589. // @Description 我的收藏微路演列表接口
  590. // @Param PageSize query int true "每页数据条数"
  591. // @Param CurrentIndex query int true "当前页页码,从1开始"
  592. // @Success 200 {object} models.HomeListResp
  593. // @router /mycollect [get]
  594. func (this *MicroRoadShowController) Mycollect() {
  595. br := new(models.BaseResponse).Init()
  596. defer func() {
  597. this.Data["json"] = br
  598. this.ServeJSON()
  599. }()
  600. user := this.User
  601. if user == nil {
  602. br.Msg = "请登录"
  603. br.ErrMsg = "请登录,用户信息为空"
  604. br.Ret = 408
  605. return
  606. }
  607. pageSize, _ := this.GetInt("PageSize")
  608. currentIndex, _ := this.GetInt("CurrentIndex")
  609. if pageSize <= 0 {
  610. pageSize = utils.PageSize20
  611. }
  612. if currentIndex <= 0 {
  613. currentIndex = 1
  614. }
  615. userId := user.UserId
  616. listMycollect, err := models.GetUserMicroRoadshowCollectList(userId)
  617. if err != nil {
  618. br.Msg = "获取数据失败"
  619. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  620. return
  621. }
  622. listAskserieVideoCollect, err := models.GetUserCygxAskserieVideoCollectList(userId)
  623. if err != nil {
  624. br.Msg = "获取数据失败"
  625. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  626. return
  627. }
  628. var audioIds []string
  629. var videoIds []string
  630. var activityVideoIds []string
  631. var askserieVideoIds []string //问答系列视频
  632. for _, item := range listMycollect {
  633. if item.ActivityVoiceId > 0 {
  634. audioIds = append(audioIds, strconv.Itoa(item.ActivityVoiceId))
  635. } else if item.VideoId > 0 {
  636. videoIds = append(videoIds, strconv.Itoa(item.VideoId))
  637. } else if item.ActivityVideoId > 0 {
  638. activityVideoIds = append(activityVideoIds, strconv.Itoa(item.ActivityVideoId))
  639. }
  640. }
  641. for _, item := range listAskserieVideoCollect {
  642. askserieVideoIds = append(askserieVideoIds, strconv.Itoa(item.AskserieVideoId))
  643. }
  644. if len(audioIds) == 0 && len(videoIds) == 0 && len(activityVideoIds) == 0 && len(askserieVideoIds) == 0 {
  645. resp := new(models.MicroRoadShowListResp)
  646. page := paging.GetPaging(currentIndex, pageSize, 0)
  647. resp.List = make([]*models.MicroRoadShowPageList, 0)
  648. resp.Paging = page
  649. br.Ret = 200
  650. br.Success = true
  651. br.Msg = "获取成功"
  652. br.Data = resp
  653. return
  654. }
  655. audioIdstr := strings.Join(audioIds, ",")
  656. ideoIdsStr := strings.Join(videoIds, ",")
  657. activityVideoIdsStr := strings.Join(activityVideoIds, ",")
  658. askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
  659. // 微路演列表
  660. list, total, e := services.GetMicroRoadShowMycollectV12(pageSize, currentIndex, audioIdstr, activityVideoIdsStr, ideoIdsStr, askserieVideoIdsStr, user)
  661. if e != nil {
  662. br.Msg = "获取失败"
  663. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  664. return
  665. }
  666. for _, item := range list {
  667. //if item.Type == 1 {
  668. // //音频
  669. // count, err := models.GetVoiceCollectCount(user.UserId, item.Id)
  670. // if err != nil {
  671. // br.Msg = "获取数据失败!"
  672. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  673. // return
  674. // }
  675. // if count > 0 {
  676. // item.IsCollect = true
  677. // }
  678. //} else if item.Type == 2 {
  679. // //活动视频
  680. // count, err := models.GetActivityVideoCollectCount(user.UserId, item.Id)
  681. // if err != nil {
  682. // br.Msg = "获取数据失败!"
  683. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  684. // return
  685. // }
  686. // if count > 0 {
  687. // item.IsCollect = true
  688. // }
  689. //} else if item.Type == 3 {
  690. // //微路演视频
  691. // count, err := models.GetVideoCollectCount(user.UserId, item.Id)
  692. // if err != nil {
  693. // br.Msg = "获取数据失败!"
  694. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  695. // return
  696. // }
  697. // if count > 0 {
  698. // item.IsCollect = true
  699. // }
  700. //}
  701. item.IsCollect = true
  702. }
  703. // 用户权限
  704. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  705. if e != nil {
  706. br.Msg = "获取失败"
  707. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  708. return
  709. }
  710. // 获取默认图配置
  711. audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
  712. if e != nil {
  713. br.Msg = "获取失败"
  714. br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
  715. return
  716. }
  717. for i := range list {
  718. // 权限
  719. au := new(models.UserPermissionAuthInfo)
  720. au.SellerName = authInfo.SellerName
  721. au.SellerMobile = authInfo.SellerMobile
  722. au.HasPermission = authInfo.HasPermission
  723. au.OperationMode = authInfo.OperationMode
  724. if au.HasPermission == 1 {
  725. // 非宏观权限进一步判断是否有权限
  726. if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
  727. au.HasPermission = 2
  728. }
  729. }
  730. // 无权限的弹框提示
  731. if au.HasPermission != 1 {
  732. if au.OperationMode == services.UserPermissionOperationModeCall {
  733. if list[i].Type == 1 {
  734. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  735. } else {
  736. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  737. }
  738. } else {
  739. if list[i].Type == 1 {
  740. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  741. } else {
  742. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  743. }
  744. }
  745. }
  746. list[i].AuthInfo = au
  747. list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
  748. // 默认图
  749. if list[i].BackgroundImg == "" {
  750. if list[i].Type == 1 {
  751. list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
  752. } else {
  753. list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
  754. }
  755. }
  756. // 分享图
  757. if list[i].ShareImg == "" {
  758. if list[i].Type == 1 {
  759. list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
  760. } else {
  761. list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
  762. }
  763. }
  764. }
  765. resp := new(models.MicroRoadShowListResp)
  766. page := paging.GetPaging(currentIndex, pageSize, total)
  767. resp.List = list
  768. resp.Paging = page
  769. br.Ret = 200
  770. br.Success = true
  771. br.Msg = "获取成功"
  772. br.Data = resp
  773. }
  774. // @Title 模版消息留言详情
  775. // @Description 模版消息留言详情接口
  776. // @Param SourceId query int true "资源ID"
  777. // @Param SourceType query int true "留言类型,1:文章、2:活动、3:微路演视频、4:活动视频、5:活动音频"
  778. // @Success Ret=200 {object} models.CygxArticleCommentWxResp
  779. // @router /comment/detail [get]
  780. func (this *MicroRoadShowController) CommentDetail() {
  781. br := new(models.BaseResponse).Init()
  782. defer func() {
  783. this.Data["json"] = br
  784. this.ServeJSON()
  785. }()
  786. user := this.User
  787. if user == nil {
  788. br.Msg = "请登录"
  789. br.ErrMsg = "请登录,用户信息为空"
  790. br.Ret = 408
  791. return
  792. }
  793. sourceId, _ := this.GetInt("SourceId")
  794. sourceType, _ := this.GetInt("SourceType")
  795. resp := new(models.CygxArticleCommentWxResp)
  796. if sourceType == 1 || sourceType == 3 || sourceType == 4 || sourceType == 5 {
  797. detail, err := models.GetArticleCommentById(sourceId)
  798. if err != nil {
  799. br.Msg = "获取失败"
  800. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  801. return
  802. }
  803. resp.Content = detail.Content
  804. if sourceType == 1 {
  805. resp.SourceId = detail.ArticleId
  806. resp.RedirectType = 1
  807. } else if sourceType == 3 {
  808. resp.SourceId = detail.IndustryId
  809. resp.RedirectType = 3
  810. } else {
  811. resp.SourceId = detail.ActivityId
  812. resp.RedirectType = 2
  813. }
  814. } else {
  815. detail, err := models.GetCygxActivityHelpAskById(sourceId)
  816. if err != nil {
  817. br.Msg = "获取失败"
  818. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  819. return
  820. }
  821. resp.Content = detail.Content
  822. resp.SourceId = detail.ActivityId
  823. resp.RedirectType = 2
  824. }
  825. br.Ret = 200
  826. br.Success = true
  827. br.Data = resp
  828. br.Msg = "操作成功"
  829. return
  830. }