1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000 |
- package controllers
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/services"
- "hongze/hongze_cygx/utils"
- "strconv"
- "strings"
- "time"
- )
- // 微路演
- type MicroRoadShowController struct {
- BaseAuthController
- }
- // @Title 微路演列表
- // @Description 微路演列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param KeyWord query string false "搜索关键词"
- // @Param Filter query string false "筛选条件 为空:全部 1:视频 2:音频 多个用 , 隔开"
- // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
- // @Param SourceId query int true "资源ID"
- // @Param SourceType query int true " 1:活动音频 2:活动视频 3:产业视频 4:问答系列"
- // @Param SearchType string int true "搜索类型: 1-路演回放; 2-问答系列; 3-调研反馈 多个用 , 隔开"
- // @Success 200 {object} models.HomeListResp
- // @router /list [get]
- func (this *MicroRoadShowController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- keywords := this.GetString("KeyWord")
- filter := this.GetString("Filter")
- chartPermissionIds := this.GetString("ChartPermissionIds")
- sourceId, _ := this.GetInt("SourceId")
- sourceType, _ := this.GetInt("SourceType")
- searchType := this.GetString("SearchType")
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- var keyWordArr []string
- var err error
- if keywords != "" {
- keyWordArr, err = services.GetIndustryMapNameSliceV3(keywords)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
- return
- }
- keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
- }
- var list []*models.MicroRoadShowPageList
- var total int
- var e error
- // 微路演列表
- list, total, e = services.GetMicroRoadShowPageListV12(pageSize, currentIndex, sourceId, sourceType, filter, keywords, searchType, chartPermissionIds)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
- return
- }
- userId := user.UserId
- listMycollect, err := models.GetUserMicroRoadshowCollectList(userId)
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- mapaudioIds := make(map[int]int) //活动音频
- mapvideoIds := make(map[int]int) // 微路演视频
- mapactivityVideoIds := make(map[int]int) // 活动视频
- mapAskserieVideoIds := make(map[int]int) // 问答系列音频
- for _, item := range listMycollect {
- if item.ActivityVoiceId > 0 {
- mapaudioIds[item.ActivityVoiceId] = item.ActivityVoiceId
- } else if item.VideoId > 0 {
- mapvideoIds[item.VideoId] = item.VideoId
- } else if item.ActivityVideoId > 0 {
- mapactivityVideoIds[item.ActivityVideoId] = item.ActivityVideoId
- }
- }
- listAskserieVideoCollect, err := models.GetUserCygxAskserieVideoCollectList(userId)
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listAskserieVideoCollect {
- if v.AskserieVideoId > 0 {
- mapAskserieVideoIds[v.AskserieVideoId] = v.AskserieVideoId
- }
- }
- for _, item := range list {
- if item.Type == 1 {
- //音频
- if mapaudioIds[item.Id] > 0 {
- item.IsCollect = true
- }
- } else if item.Type == 2 {
- //活动视频
- if mapactivityVideoIds[item.Id] > 0 {
- item.IsCollect = true
- }
- } else if item.Type == 3 {
- //微路演视频
- if mapvideoIds[item.Id] > 0 {
- item.IsCollect = true
- }
- } else if item.Type == 4 {
- //系列问答视频
- if mapAskserieVideoIds[item.SourceId] > 0 {
- item.IsCollect = true
- }
- }
- }
- // 用户权限
- authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
- return
- }
- // 获取默认图配置
- audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
- return
- }
- for i := range list {
- // 权限
- au := new(models.UserPermissionAuthInfo)
- au.SellerName = authInfo.SellerName
- au.SellerMobile = authInfo.SellerMobile
- au.HasPermission = authInfo.HasPermission
- au.OperationMode = authInfo.OperationMode
- if au.HasPermission == 1 {
- // 非宏观权限进一步判断是否有权限
- if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
- au.HasPermission = 2
- }
- }
- // 无权限的弹框提示
- if au.HasPermission != 1 {
- if au.OperationMode == services.UserPermissionOperationModeCall {
- if list[i].Type == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgCallActivity
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
- }
- } else {
- if list[i].Type == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
- }
- }
- }
- list[i].AuthInfo = au
- list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
- // 默认图
- if list[i].BackgroundImg == "" {
- if list[i].Type == 1 {
- list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
- } else {
- list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
- }
- }
- // 分享图
- if list[i].ShareImg == "" {
- if list[i].Type == 1 {
- list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
- } else {
- list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
- }
- }
- }
- if len(list) == 0 {
- list = make([]*models.MicroRoadShowPageList, 0)
- }
- resp := new(models.MicroRoadShowListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 记录用户浏览音频回放接口
- // @Description 记录用户浏览音频回放接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.AppointmentResp
- // @router /videoHistory/add [post]
- func (this *MicroRoadShowController) VideoHistoryAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- var req models.AddVideoHistoryReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- sourceId := req.SourceId
- playSeconds := req.PlaySeconds
- sourceType := req.SourceType
- if sourceType == 0 {
- sourceType = 1
- }
- if sourceType == 1 {
- //添加活动音频的播放记录
- go services.AddActivityVoiceHistory(user, sourceId, playSeconds)
- } else if sourceType == 2 {
- //添加活动视频的播放记录
- go services.AddActivityVideoHistory(user, sourceId, playSeconds)
- } else if sourceType == 3 {
- // 添加产业视频播放记录
- go services.AddMicroRoadshowVideoRecord(user, sourceId, playSeconds)
- } else if sourceType == 4 {
- go services.AddAskserieVideoHistoryRecord(user, sourceId, playSeconds)
- }
- go services.AddAllCygxVoiceAndVideoHistory(user, sourceId, sourceType, playSeconds)
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
- // @Title 微路演新增留言
- // @Description 微路演新增留言接口
- // @Param request body models.AddVideoCommnetReq true "type json string"
- // @Success Ret=200 {object} models.AppointmentResp
- // @router /comment/add [post]
- func (this *MicroRoadShowController) CommentAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.AddVideoCommnetReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- var isResearch bool // 是否属于研选
- sourceType := req.SourceType
- title := req.Title
- if sourceType == 0 {
- sourceType = 1
- }
- fmt.Println(sourceType)
- item := models.CygxArticleComment{
- UserId: uid,
- CreateTime: time.Now(),
- RealName: user.RealName,
- Mobile: user.Mobile,
- Email: user.Email,
- CompanyId: user.CompanyId,
- CompanyName: user.CompanyName,
- Content: req.Content,
- Title: req.Title,
- }
- sourceId := req.SourceId
- //var resourceId int
- if sourceType == 1 {
- activityVoiceInfo, _ := models.GetCygxActivityVoiceByActivityId(sourceId)
- if activityVoiceInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
- return
- }
- item.ActivityId = sourceId
- item.ActivityVoiceId = activityVoiceInfo.ActivityVoiceId
- err = models.UpdateActivityVoiceCommentNum(sourceId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败 ,更新活动音频留言次数失败:" + strconv.Itoa(sourceId)
- return
- }
- } else if sourceType == 2 {
- activityInfo, _ := models.GetCygxActivityVideoByActivityId(sourceId)
- if activityInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
- return
- }
- item.VideoId = activityInfo.VideoId
- item.ActivityId = sourceId
- err = models.UpdateActivityVideoCommentNum(sourceId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败 ,更新活动视频留言次数失败:" + strconv.Itoa(sourceId)
- return
- }
- } else if sourceType == 3 {
- item.VideoId = sourceId
- microVideo, e := models.GetMicroRoadshowVideoById(sourceId)
- if e != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(sourceId)
- return
- }
- item.IndustryId = microVideo.IndustryId
- //resourceId = microVideo.IndustryId
- } else if sourceType == 4 {
- item.AskserieVideoId = sourceId
- go services.AddCygxAskserieVideoCollection(user, item.AskserieVideoId, req.Content)
- }
- if sourceType == 1 || sourceType == 2 {
- detail, err := models.GetAddActivityInfoById(sourceId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
- return
- }
- if strings.Contains(detail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- isResearch = true
- }
- }
- msgId, err := models.AddArticleComment(&item)
- if err != nil {
- br.Msg = "提交失败"
- br.ErrMsg = "提交留言失败,Err:" + err.Error()
- return
- }
- services.SendWxMsgWithMicroRoadshowAsk(req, user, sourceType, int(msgId), title, isResearch)
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
- // @Title 微路演收藏
- // @Description 微路演收藏
- // @Param request body models.MicroRoadshowCollectReq true "type json string"
- // @Success 200 {object} models.FontsCollectResp
- // @router /collect [post]
- func (this *MicroRoadShowController) Collect() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.MicroRoadshowCollectReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- sourceId := req.SourceId
- if req.SourceType == 1 {
- detail, err := models.GetCygxActivityVoiceByActivityId(sourceId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- count, err := models.GetVoiceCollectCount(uid, detail.ActivityVoiceId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.ArticleCollectResp)
- if count <= 0 {
- item := new(models.CygxArticleCollect)
- item.ActivityVoiceId = detail.ActivityVoiceId
- item.UserId = uid
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.RealName = user.RealName
- _, err = models.AddCygxArticleCollect(item)
- if err != nil {
- br.Msg = "收藏失败"
- br.ErrMsg = "收藏失败,Err:" + err.Error()
- return
- }
- br.Msg = "收藏成功"
- resp.Status = 1
- // 文章收藏消息发送
- //go services.ArticleUserRemind(user, detail, 2)
- } else {
- err = models.RemoveVoiceCollect(uid, detail.ActivityVoiceId)
- if err != nil {
- br.Msg = "取消收藏失败"
- br.ErrMsg = "取消收藏失败,Err:" + err.Error()
- return
- }
- br.Msg = "已取消收藏"
- resp.Status = 2
- }
- collectTotal, err := models.GetVoiceCollectUsersCount(detail.ActivityVoiceId)
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp.CollectCount = collectTotal
- br.Ret = 200
- br.Success = true
- br.Data = resp
- } else if req.SourceType == 2 {
- detail, err := models.GetCygxActivityVideoByActivityIdInfo(sourceId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- count, err := models.GetActivityVideoCollectCount(uid, detail.Id)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.ArticleCollectResp)
- if count <= 0 {
- item := new(models.CygxArticleCollect)
- item.ActivityVideoId = detail.Id
- item.UserId = uid
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.RealName = user.RealName
- _, err = models.AddCygxArticleCollect(item)
- if err != nil {
- br.Msg = "收藏失败"
- br.ErrMsg = "收藏失败,Err:" + err.Error()
- return
- }
- br.Msg = "收藏成功"
- resp.Status = 1
- // 文章收藏消息发送
- //go services.ArticleUserRemind(user, detail, 2)
- } else {
- err = models.RemoveActivityVideoCollect(uid, detail.Id)
- if err != nil {
- br.Msg = "取消收藏失败"
- br.ErrMsg = "取消收藏失败,Err:" + err.Error()
- return
- }
- br.Msg = "已取消收藏"
- resp.Status = 2
- }
- collectTotal, err := models.GetActivityVideoCollectUsersCount(detail.Id)
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp.CollectCount = collectTotal
- br.Ret = 200
- br.Success = true
- br.Data = resp
- } else if req.SourceType == 3 {
- _, err := models.GetMicroRoadshowVideoById(sourceId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- count, err := models.GetVideoCollectCount(uid, sourceId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.ArticleCollectResp)
- if count <= 0 {
- item := new(models.CygxArticleCollect)
- item.VideoId = sourceId
- item.UserId = uid
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.RealName = user.RealName
- _, err = models.AddCygxArticleCollect(item)
- if err != nil {
- br.Msg = "收藏失败"
- br.ErrMsg = "收藏失败,Err:" + err.Error()
- return
- }
- br.Msg = "收藏成功"
- resp.Status = 1
- // 文章收藏消息发送
- //go services.ArticleUserRemind(user, detail, 2)
- } else {
- err = models.RemoveVideoCollect(uid, sourceId)
- if err != nil {
- br.Msg = "取消收藏失败"
- br.ErrMsg = "取消收藏失败,Err:" + err.Error()
- return
- }
- br.Msg = "已取消收藏"
- resp.Status = 2
- }
- collectTotal, err := models.GetVideoCollectUsersCount(sourceId)
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp.CollectCount = collectTotal
- br.Ret = 200
- br.Success = true
- br.Data = resp
- } else if req.SourceType == 4 {
- // 系列问答视频收藏
- count, err := models.GetAskserieVideoCount(uid, sourceId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.ArticleCollectResp)
- if count <= 0 {
- item := new(models.CygxAskserieVideoCollect)
- item.AskserieVideoId = sourceId
- item.UserId = uid
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.RealName = user.RealName
- item.RegisterPlatform = utils.REGISTER_PLATFORM
- err = models.AddCygxAskserieVideoCollect(item)
- if err != nil {
- br.Msg = "收藏失败"
- br.ErrMsg = "收藏失败,Err:" + err.Error()
- return
- }
- br.Msg = "收藏成功"
- resp.Status = 1
- // 文章收藏消息发送
- //go services.ArticleUserRemind(user, detail, 2)
- } else {
- err = models.RemoveAskserieVideoCollect(uid, sourceId)
- if err != nil {
- br.Msg = "取消收藏失败"
- br.ErrMsg = "取消收藏失败,Err:" + err.Error()
- return
- }
- br.Msg = "已取消收藏"
- resp.Status = 2
- }
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- }
- // @Title 我的收藏微路演列表
- // @Description 我的收藏微路演列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.HomeListResp
- // @router /mycollect [get]
- func (this *MicroRoadShowController) Mycollect() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- userId := user.UserId
- listMycollect, err := models.GetUserMicroRoadshowCollectList(userId)
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- listAskserieVideoCollect, err := models.GetUserCygxAskserieVideoCollectList(userId)
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var audioIds []string
- var videoIds []string
- var activityVideoIds []string
- var askserieVideoIds []string //问答系列视频
- for _, item := range listMycollect {
- if item.ActivityVoiceId > 0 {
- audioIds = append(audioIds, strconv.Itoa(item.ActivityVoiceId))
- } else if item.VideoId > 0 {
- videoIds = append(videoIds, strconv.Itoa(item.VideoId))
- } else if item.ActivityVideoId > 0 {
- activityVideoIds = append(activityVideoIds, strconv.Itoa(item.ActivityVideoId))
- }
- }
- for _, item := range listAskserieVideoCollect {
- askserieVideoIds = append(askserieVideoIds, strconv.Itoa(item.AskserieVideoId))
- }
- if len(audioIds) == 0 && len(videoIds) == 0 && len(activityVideoIds) == 0 && len(askserieVideoIds) == 0 {
- resp := new(models.MicroRoadShowListResp)
- page := paging.GetPaging(currentIndex, pageSize, 0)
- resp.List = make([]*models.MicroRoadShowPageList, 0)
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- audioIdstr := strings.Join(audioIds, ",")
- ideoIdsStr := strings.Join(videoIds, ",")
- activityVideoIdsStr := strings.Join(activityVideoIds, ",")
- askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
- // 微路演列表
- list, total, e := services.GetMicroRoadShowMycollectV12(pageSize, currentIndex, audioIdstr, activityVideoIdsStr, ideoIdsStr, askserieVideoIdsStr, user)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
- return
- }
- for _, item := range list {
- //if item.Type == 1 {
- // //音频
- // count, err := models.GetVoiceCollectCount(user.UserId, item.Id)
- // if err != nil {
- // br.Msg = "获取数据失败!"
- // br.ErrMsg = "获取数据失败,Err:" + err.Error()
- // return
- // }
- // if count > 0 {
- // item.IsCollect = true
- // }
- //} else if item.Type == 2 {
- // //活动视频
- // count, err := models.GetActivityVideoCollectCount(user.UserId, item.Id)
- // if err != nil {
- // br.Msg = "获取数据失败!"
- // br.ErrMsg = "获取数据失败,Err:" + err.Error()
- // return
- // }
- // if count > 0 {
- // item.IsCollect = true
- // }
- //} else if item.Type == 3 {
- // //微路演视频
- // count, err := models.GetVideoCollectCount(user.UserId, item.Id)
- // if err != nil {
- // br.Msg = "获取数据失败!"
- // br.ErrMsg = "获取数据失败,Err:" + err.Error()
- // return
- // }
- // if count > 0 {
- // item.IsCollect = true
- // }
- //}
- item.IsCollect = true
- }
- // 用户权限
- authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
- return
- }
- // 获取默认图配置
- audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
- return
- }
- for i := range list {
- // 权限
- au := new(models.UserPermissionAuthInfo)
- au.SellerName = authInfo.SellerName
- au.SellerMobile = authInfo.SellerMobile
- au.HasPermission = authInfo.HasPermission
- au.OperationMode = authInfo.OperationMode
- if au.HasPermission == 1 {
- // 非宏观权限进一步判断是否有权限
- if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
- au.HasPermission = 2
- }
- }
- // 无权限的弹框提示
- if au.HasPermission != 1 {
- if au.OperationMode == services.UserPermissionOperationModeCall {
- if list[i].Type == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgCallActivity
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
- }
- } else {
- if list[i].Type == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
- }
- }
- }
- list[i].AuthInfo = au
- list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
- // 默认图
- if list[i].BackgroundImg == "" {
- if list[i].Type == 1 {
- list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
- } else {
- list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
- }
- }
- // 分享图
- if list[i].ShareImg == "" {
- if list[i].Type == 1 {
- list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
- } else {
- list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
- }
- }
- }
- resp := new(models.MicroRoadShowListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 模版消息留言详情
- // @Description 模版消息留言详情接口
- // @Param SourceId query int true "资源ID"
- // @Param SourceType query int true "留言类型,1:文章、2:活动、3:微路演视频、4:活动视频、5:活动音频"
- // @Success Ret=200 {object} models.CygxArticleCommentWxResp
- // @router /comment/detail [get]
- func (this *MicroRoadShowController) CommentDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- sourceId, _ := this.GetInt("SourceId")
- sourceType, _ := this.GetInt("SourceType")
- resp := new(models.CygxArticleCommentWxResp)
- if sourceType == 1 || sourceType == 3 || sourceType == 4 || sourceType == 5 {
- detail, err := models.GetArticleCommentById(sourceId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
- return
- }
- resp.Content = detail.Content
- if sourceType == 1 {
- resp.SourceId = detail.ArticleId
- resp.RedirectType = 1
- } else if sourceType == 3 {
- resp.SourceId = detail.IndustryId
- resp.RedirectType = 3
- } else {
- resp.SourceId = detail.ActivityId
- resp.RedirectType = 2
- }
- } else {
- detail, err := models.GetCygxActivityHelpAskById(sourceId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
- return
- }
- resp.Content = detail.Content
- resp.SourceId = detail.ActivityId
- resp.RedirectType = 2
- }
- br.Ret = 200
- br.Success = true
- br.Data = resp
- br.Msg = "操作成功"
- return
- }
- // @Title 策略系列培训视频
- // @Description 策略系列培训视频接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.HomeListResp
- // @router /training/list [get]
- func (this *MicroRoadShowController) TrainingList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- var audioIds []string
- var videoIds []string
- var activityVideoIds []string
- var askserieVideoIds []string //问答系列视频
- activityVideoIds = []string{"461", "462", "463", "464", "465", "466"} // 系列培训视频,固定的六个,这里先写死
- activityVideoTitle := []string{"第一期_A股运行特征探讨", "第二期_行业比较研究", "第三期_市场风格观察与我们的研究方法", "第四期_市场估值指标追踪", "第五期_宏观经济研究", "第六期_市场回顾专题"} // 系列培训视频,固定的六个,这里先写死
- audioIdstr := strings.Join(audioIds, ",")
- ideoIdsStr := strings.Join(videoIds, ",")
- activityVideoIdsStr := strings.Join(activityVideoIds, ",")
- askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
- // 微路演列表
- list, total, e := services.GetMicroRoadShowMycollectV12(pageSize, currentIndex, audioIdstr, activityVideoIdsStr, ideoIdsStr, askserieVideoIdsStr, user)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
- return
- }
- //存储反转数据
- reversed := []*models.MicroRoadShowPageList{}
- for i := range list {
- n := list[len(list)-1-i]
- reversed = append(reversed, n)
- }
- list = reversed
- // 用户权限
- authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
- return
- }
- // 获取默认图配置
- audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
- return
- }
- for i := range list {
- // 权限
- au := new(models.UserPermissionAuthInfo)
- au.SellerName = authInfo.SellerName
- au.SellerMobile = authInfo.SellerMobile
- au.HasPermission = authInfo.HasPermission
- au.OperationMode = authInfo.OperationMode
- if au.HasPermission == 1 {
- // 非宏观权限进一步判断是否有权限
- if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
- au.HasPermission = 2
- }
- }
- // 无权限的弹框提示
- if au.HasPermission != 1 {
- if au.OperationMode == services.UserPermissionOperationModeCall {
- if list[i].Type == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgCallActivity
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
- }
- } else {
- if list[i].Type == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
- }
- }
- }
- list[i].AuthInfo = au
- list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
- // 默认图
- if list[i].BackgroundImg == "" {
- if list[i].Type == 1 {
- list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
- } else {
- list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
- }
- }
- // 分享图
- if list[i].ShareImg == "" {
- if list[i].Type == 1 {
- list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
- } else {
- list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
- }
- }
- if i <= len(activityVideoTitle)-1 {
- list[i].Title = activityVideoTitle[i]
- }
- }
- resp := new(models.MicroRoadShowListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.List = list
- resp.Paging = page
- resp.Describe = "弘则策略首席 马冬凡 主讲"
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|