xingzai 1 an în urmă
părinte
comite
e4cbbe8afb
2 a modificat fișierele cu 66 adăugiri și 44 ștergeri
  1. 61 41
      controllers/micro_roadshow.go
  2. 5 3
      models/micro_roadshow.go

+ 61 - 41
controllers/micro_roadshow.go

@@ -21,7 +21,7 @@ type MicroRoadShowController struct {
 // @Param   PageSize		query	int		true	"每页数据条数"
 // @Param   CurrentIndex	query	int		true	"当前页页码,从1开始"
 // @Param   KeyWord			query	string	false	"搜索关键词"
-// @Param   Filter			query	string		false	"筛选条件 为空:全部 1:视频 2:音频 3:逻辑解析 4:路演回放 多个用 , 隔开"
+// @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:问答系列"
@@ -93,6 +93,7 @@ func (this *MicroRoadShowController) List() {
 	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
@@ -102,6 +103,20 @@ func (this *MicroRoadShowController) List() {
 			mapactivityVideoIds[item.ActivityVoiceId] = item.ActivityVoiceId
 		}
 	}
+
+	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 {
 			//音频
@@ -118,6 +133,11 @@ func (this *MicroRoadShowController) List() {
 			if mapvideoIds[item.Id] > 0 {
 				item.IsCollect = true
 			}
+		} else if item.Type == 4 {
+			//系列问答视频
+			if mapAskserieVideoIds[item.SourceId] > 0 {
+				item.IsCollect = true
+			}
 		}
 	}
 	// 用户权限
@@ -222,7 +242,7 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
-	videoId := req.VideoId
+	sourceId := req.SourceId
 	playSeconds := req.PlaySeconds
 	sourceType := req.SourceType
 	if sourceType == 0 {
@@ -237,10 +257,10 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 	}
 	if sourceType == 1 {
 		//添加活动音频的播放记录
-		go services.AddActivityVoiceHistory(user, videoId, playSeconds)
+		go services.AddActivityVoiceHistory(user, sourceId, playSeconds)
 	} else if sourceType == 2 {
 		//添加活动视频的播放记录
-		go services.AddActivityVideoHistory(user, videoId, playSeconds)
+		go services.AddActivityVideoHistory(user, sourceId, playSeconds)
 		//if err != nil {
 		//	br.Msg = "更新失败"
 		//	br.ErrMsg = "更新失败,AddActivityVideoHistory Err:" + err.Error()
@@ -248,7 +268,7 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 		//}
 	} else if sourceType == 3 {
 		item := models.CygxMicroRoadshowVideoHistory{
-			VideoId:     videoId,
+			VideoId:     sourceId,
 			UserId:      uid,
 			Mobile:      user.Mobile,
 			Email:       user.Email,
@@ -261,7 +281,7 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 			ModifyTime:  time.Now(),
 		}
 		if playSeconds != 0 {
-			lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
+			lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(sourceId, user.UserId)
 			if err != nil {
 				br.Msg = "操作失败"
 				br.ErrMsg = "操作失败,GetLastCygxMicroRoadshowVideoHistory Err:" + err.Error()
@@ -280,16 +300,16 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 				br.ErrMsg = "操作失败,Err:" + err.Error()
 				return
 			}
-			err = models.UpdateCygxActivityVideoCounts(videoId)
+			err = models.UpdateCygxActivityVideoCounts(sourceId)
 			if err != nil {
 				br.Msg = "更新失败"
 				br.ErrMsg = "更新失败,Err:" + err.Error()
 				return
 			}
 		}
-		go services.MicroRoadshowVideoUserRmind(user, videoId)
+		go services.MicroRoadshowVideoUserRmind(user, sourceId)
 	} else if sourceType == 4 {
-		go services.AddAskserieVideoHistoryRecord(user, videoId, playSeconds)
+		go services.AddAskserieVideoHistoryRecord(user, sourceId, playSeconds)
 	}
 	br.Ret = 200
 	br.Success = true
@@ -340,49 +360,49 @@ func (this *MicroRoadShowController) CommentAdd() {
 		Content:     req.Content,
 		Title:       req.Title,
 	}
-
+	sourceId := req.SourceId
 	//var resourceId int
 	if sourceType == 1 {
-		activityVoiceInfo, _ := models.GetCygxActivityVoiceByActivityId(req.Id)
+		activityVoiceInfo, _ := models.GetCygxActivityVoiceByActivityId(sourceId)
 		if activityVoiceInfo == nil {
 			br.Msg = "操作失败"
-			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
+			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
 			return
 		}
-		item.ActivityId = req.Id
+		item.ActivityId = sourceId
 		item.ActivityVoiceId = activityVoiceInfo.ActivityVoiceId
 		//resourceId = activityVoiceInfo.ActivityId
 	} else if sourceType == 2 {
-		activityInfo, _ := models.GetCygxActivityVideoByActivityId(req.Id)
+		activityInfo, _ := models.GetCygxActivityVideoByActivityId(sourceId)
 		if activityInfo == nil {
 			br.Msg = "操作失败"
-			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
+			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
 			return
 		}
 		item.VideoId = activityInfo.VideoId
-		item.ActivityId = req.Id
+		item.ActivityId = sourceId
 		//resourceId = activityInfo.ActivityId
 	} else if sourceType == 3 {
-		item.VideoId = req.Id
-		microVideo, e := models.GetMicroRoadshowVideoById(req.Id)
+		item.VideoId = sourceId
+		microVideo, e := models.GetMicroRoadshowVideoById(sourceId)
 		if e != nil {
 			br.Msg = "操作失败"
-			br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(req.Id)
+			br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(sourceId)
 			return
 		}
 		item.IndustryId = microVideo.IndustryId
 		//resourceId = microVideo.IndustryId
 	} else if sourceType == 4 {
-		item.AskserieVideoId = req.Id
+		item.AskserieVideoId = sourceId
 
 		go services.AddCygxAskserieVideoCollection(user, item.AskserieVideoId, req.Content)
 	}
 
 	if sourceType == 2 || sourceType == 3 {
-		detail, err := models.GetAddActivityInfoById(req.Id)
+		detail, err := models.GetAddActivityInfoById(sourceId)
 		if err != nil {
 			br.Msg = "操作失败"
-			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
+			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
 			return
 		}
 		if strings.Contains(detail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
@@ -428,15 +448,15 @@ func (this *MicroRoadShowController) Collect() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
-
+	sourceId := req.SourceId
 	if req.SourceType == 1 {
-		_, err := models.GetCygxActivityVoiceById(req.Id)
+		_, err := models.GetCygxActivityVoiceById(sourceId)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
-		count, err := models.GetVoiceCollectCount(uid, req.Id)
+		count, err := models.GetVoiceCollectCount(uid, sourceId)
 		if err != nil {
 			br.Msg = "获取数据失败!"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -445,7 +465,7 @@ func (this *MicroRoadShowController) Collect() {
 		resp := new(models.ArticleCollectResp)
 		if count <= 0 {
 			item := new(models.CygxArticleCollect)
-			item.ActivityVoiceId = req.Id
+			item.ActivityVoiceId = sourceId
 			item.UserId = uid
 			item.CreateTime = time.Now()
 			item.Mobile = user.Mobile
@@ -464,7 +484,7 @@ func (this *MicroRoadShowController) Collect() {
 			// 文章收藏消息发送
 			//go services.ArticleUserRemind(user, detail, 2)
 		} else {
-			err = models.RemoveVoiceCollect(uid, req.Id)
+			err = models.RemoveVoiceCollect(uid, sourceId)
 			if err != nil {
 				br.Msg = "取消收藏失败"
 				br.ErrMsg = "取消收藏失败,Err:" + err.Error()
@@ -473,7 +493,7 @@ func (this *MicroRoadShowController) Collect() {
 			br.Msg = "已取消收藏"
 			resp.Status = 2
 		}
-		collectTotal, err := models.GetVoiceCollectUsersCount(req.Id)
+		collectTotal, err := models.GetVoiceCollectUsersCount(sourceId)
 		if err != nil {
 			br.Msg = "获取数据失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -484,13 +504,13 @@ func (this *MicroRoadShowController) Collect() {
 		br.Success = true
 		br.Data = resp
 	} else if req.SourceType == 2 {
-		_, err := models.GetCygxActivityVideoById(req.Id)
+		_, err := models.GetCygxActivityVideoById(sourceId)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
-		count, err := models.GetActivityVideoCollectCount(uid, req.Id)
+		count, err := models.GetActivityVideoCollectCount(uid, sourceId)
 		if err != nil {
 			br.Msg = "获取数据失败!"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -499,7 +519,7 @@ func (this *MicroRoadShowController) Collect() {
 		resp := new(models.ArticleCollectResp)
 		if count <= 0 {
 			item := new(models.CygxArticleCollect)
-			item.ActivityVideoId = req.Id
+			item.ActivityVideoId = sourceId
 			item.UserId = uid
 			item.CreateTime = time.Now()
 			item.ModifyTime = time.Now()
@@ -519,7 +539,7 @@ func (this *MicroRoadShowController) Collect() {
 			// 文章收藏消息发送
 			//go services.ArticleUserRemind(user, detail, 2)
 		} else {
-			err = models.RemoveActivityVideoCollect(uid, req.Id)
+			err = models.RemoveActivityVideoCollect(uid, sourceId)
 			if err != nil {
 				br.Msg = "取消收藏失败"
 				br.ErrMsg = "取消收藏失败,Err:" + err.Error()
@@ -528,7 +548,7 @@ func (this *MicroRoadShowController) Collect() {
 			br.Msg = "已取消收藏"
 			resp.Status = 2
 		}
-		collectTotal, err := models.GetActivityVideoCollectUsersCount(req.Id)
+		collectTotal, err := models.GetActivityVideoCollectUsersCount(sourceId)
 		if err != nil {
 			br.Msg = "获取数据失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -539,13 +559,13 @@ func (this *MicroRoadShowController) Collect() {
 		br.Success = true
 		br.Data = resp
 	} else if req.SourceType == 3 {
-		_, err := models.GetMicroRoadshowVideoById(req.Id)
+		_, err := models.GetMicroRoadshowVideoById(sourceId)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
-		count, err := models.GetVideoCollectCount(uid, req.Id)
+		count, err := models.GetVideoCollectCount(uid, sourceId)
 		if err != nil {
 			br.Msg = "获取数据失败!"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -554,7 +574,7 @@ func (this *MicroRoadShowController) Collect() {
 		resp := new(models.ArticleCollectResp)
 		if count <= 0 {
 			item := new(models.CygxArticleCollect)
-			item.VideoId = req.Id
+			item.VideoId = sourceId
 			item.UserId = uid
 			item.CreateTime = time.Now()
 			item.Mobile = user.Mobile
@@ -573,7 +593,7 @@ func (this *MicroRoadShowController) Collect() {
 			// 文章收藏消息发送
 			//go services.ArticleUserRemind(user, detail, 2)
 		} else {
-			err = models.RemoveVideoCollect(uid, req.Id)
+			err = models.RemoveVideoCollect(uid, sourceId)
 			if err != nil {
 				br.Msg = "取消收藏失败"
 				br.ErrMsg = "取消收藏失败,Err:" + err.Error()
@@ -582,7 +602,7 @@ func (this *MicroRoadShowController) Collect() {
 			br.Msg = "已取消收藏"
 			resp.Status = 2
 		}
-		collectTotal, err := models.GetVideoCollectUsersCount(req.Id)
+		collectTotal, err := models.GetVideoCollectUsersCount(sourceId)
 		if err != nil {
 			br.Msg = "获取数据失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -594,7 +614,7 @@ func (this *MicroRoadShowController) Collect() {
 		br.Data = resp
 	} else if req.SourceType == 4 {
 		// 系列问答视频收藏
-		count, err := models.GetAskserieVideoCount(uid, req.Id)
+		count, err := models.GetAskserieVideoCount(uid, sourceId)
 		if err != nil {
 			br.Msg = "获取数据失败!"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -603,7 +623,7 @@ func (this *MicroRoadShowController) Collect() {
 		resp := new(models.ArticleCollectResp)
 		if count <= 0 {
 			item := new(models.CygxAskserieVideoCollect)
-			item.AskserieVideoId = req.Id
+			item.AskserieVideoId = sourceId
 			item.UserId = uid
 			item.CreateTime = time.Now()
 			item.Mobile = user.Mobile
@@ -623,7 +643,7 @@ func (this *MicroRoadShowController) Collect() {
 			// 文章收藏消息发送
 			//go services.ArticleUserRemind(user, detail, 2)
 		} else {
-			err = models.RemoveAskserieVideoCollect(uid, req.Id)
+			err = models.RemoveAskserieVideoCollect(uid, sourceId)
 			if err != nil {
 				br.Msg = "取消收藏失败"
 				br.ErrMsg = "取消收藏失败,Err:" + err.Error()

+ 5 - 3
models/micro_roadshow.go

@@ -425,7 +425,8 @@ func GetMicroRoadShowVideoPageListIkWord(startSize, pageSize int, condition stri
 }
 
 type AddVideoHistoryReq struct {
-	VideoId     int `description:"视频ID"`
+	SourceId int `description:"资源ID"`
+	//VideoId     int `description:"视频ID"`
 	PlaySeconds int `description:"播放时长"`
 	//SourceType  int `description:"视频来源: 1-微路演; 2-活动 (不传默认为1)"`
 	SourceType int `description:"音视频来源: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"`
@@ -597,14 +598,15 @@ func GetMicroRoadshowVideoByIndustryId(industryId int) (item *MicroRoadshowVideo
 }
 
 type AddVideoCommnetReq struct {
-	Id         int    `description:"活动或产业ID"`
+	//Id         int    `description:"活动或产业ID"`
+	SourceId   int    `description:"资源ID"`
 	SourceType int    `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
 	Content    string `description:"内容"`
 	Title      string `description:"标题"`
 }
 
 type MicroRoadshowCollectReq struct {
-	Id         int `description:"音频或视频ID"`
+	SourceId   int `description:"音频或视频ID"`
 	SourceType int `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
 }