Browse Source

Merge branch 'cygx_12.4' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 1 year ago
parent
commit
6dd22cc7ef

+ 1 - 1
controllers/micro_roadshow.go

@@ -734,7 +734,7 @@ func (this *MicroRoadShowController) Mycollect() {
 	activityVideoIdsStr := strings.Join(activityVideoIds, ",")
 	askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
 	// 微路演列表
-	list, total, e := services.GetMicroRoadShowMycollectV12(pageSize, currentIndex, audioIdstr, activityVideoIdsStr, ideoIdsStr, askserieVideoIdsStr)
+	list, total, e := services.GetMicroRoadShowMycollectV12(pageSize, currentIndex, audioIdstr, activityVideoIdsStr, ideoIdsStr, askserieVideoIdsStr, user)
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()

+ 3 - 3
models/micro_roadshow.go

@@ -172,7 +172,7 @@ func GetMicroRoadShowVideoPageListV12(startSize, pageSize int, audioAct string,
 			a.voice_play_seconds AS play_seconds,
 			a.background_img,
 			"" AS industry_name,
-			"",
+			0 AS  industry_id,
 			a.share_img,
 			a.activity_id 
 		FROM
@@ -197,7 +197,7 @@ func GetMicroRoadShowVideoPageListV12(startSize, pageSize int, audioAct string,
 			"" AS play_seconds,
 			a.background_img,
 			"" AS industry_name,
-			"",
+			0 AS  industry_id,
 			a.share_img,
 			a.activity_id
 		FROM
@@ -247,7 +247,7 @@ func GetMicroRoadShowVideoPageListV12(startSize, pageSize int, audioAct string,
 			a.video_duration AS play_seconds,
 			a.background_img,
 			"" AS industry_name,
-			"",
+			0 AS  industry_id,
 			a.share_img,
 			0  as activity_id 
 		FROM

+ 11 - 38
services/es_comprehensive.go

@@ -998,6 +998,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	var industrialResourceIdsHz []int // 弘则产业资源包
 	var industrialResourceIdsYx []int // 研选产业资源包
 	var yanxuanSpecialIds []int       // 研选专栏
+	var askserieVideoIds []string     //问答系列视频
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
 	for _, v := range list {
 		if v.Source == "article" {
@@ -1028,6 +1029,8 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 			industrialResourceIdsYx = append(industrialResourceIdsYx, v.SourceId)
 		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL {
 			yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
+		} else if v.Source == utils.CYGX_OBJ_ASKSERIEVIDEO {
+			askserieVideoIds = append(askserieVideoIds, strconv.Itoa(v.SourceId))
 		}
 	}
 	//处理文章
@@ -1339,51 +1342,19 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		}
 	}
 
-	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds) > 0 {
+	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds) > 0 {
 
 		audioIdstr := strings.Join(activityvoiceIds, ",")
-		ideoIdsStr := strings.Join(roadshowIds, ",")
 		activityVideoIdsStr := strings.Join(activityvideoIds, ",")
+		roadshowIdsStr := strings.Join(roadshowIds, ",")
+		askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
 
-		list, _, e := GetMicroRoadShowMycollect(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds), 0, audioIdstr, ideoIdsStr, activityVideoIdsStr)
+		list, _, e := GetMicroRoadShowMycollectV12(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds), 0, audioIdstr, activityVideoIdsStr, roadshowIdsStr, askserieVideoIdsStr, user)
 		if e != nil {
-			err = errors.New("GetMicroRoadShowMycollect, Err: " + e.Error())
+			err = errors.New("GetMicroRoadShowMycollectV12, Err: " + e.Error())
 			return
 		}
 
-		for _, item := range list {
-			if item.Type == 1 {
-				//音频
-				count, e := models.GetVoiceCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetVoiceCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			} else if item.Type == 2 {
-				//活动视频
-				count, e := models.GetActivityVideoCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetActivityVideoCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			} else if item.Type == 3 {
-				//微路演视频
-				count, e := models.GetVideoCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetVideoCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			}
-		}
 		// 用户权限
 		authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
 		if e != nil {
@@ -1454,6 +1425,8 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 				mapItems[fmt.Sprint("activityvideo", item.Id)].Activityvideo = item
 			} else if item.Type == 3 {
 				mapItems[fmt.Sprint("roadshow", item.Id)].Roadshow = item
+			} else if item.Type == 4 {
+				mapItems[fmt.Sprint(utils.CYGX_OBJ_ASKSERIEVIDEO, item.Id)].AskserieVideo = item
 			}
 		}
 	}
@@ -1483,7 +1456,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	for _, vList := range list {
 		for _, v := range mapItems {
 			//如果这些类型都为空,那么就不合并
-			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.YanxuanSpecial == nil {
+			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.YanxuanSpecial == nil && v.AskserieVideo == nil {
 				continue
 			}
 			if v.Article != nil && v.SourceId == vList.SourceId {

+ 57 - 1
services/micro_roadshow.go

@@ -694,7 +694,7 @@ func GetMicroRoadShowMycollect(pageSize, currentIndex int, audioIds, videoIds, a
 }
 
 // 我的收藏
-func GetMicroRoadShowMycollectV12(pageSize, currentIndex int, audioIds, activityVideoIds, roadshowIdsStr, askserieVideoIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+func GetMicroRoadShowMycollectV12(pageSize, currentIndex int, audioIds, activityVideoIds, roadshowIdsStr, askserieVideoIds string, user *models.WxUserItem) (respList []*models.MicroRoadShowPageList, total int, err error) {
 	//Type                int    `description:"类型: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"`
 	var e error
 	// 根据每页数据量获取音视频配比
@@ -753,6 +753,62 @@ func GetMicroRoadShowMycollectV12(pageSize, currentIndex int, audioIds, activity
 		err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
 		return
 	}
+	userId := user.UserId
+	listMycollect, e := models.GetUserMicroRoadshowCollectList(userId)
+	if e != nil {
+		err = errors.New("GetUserMicroRoadshowCollectList, Err: " + e.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.ActivityVoiceId] = item.ActivityVoiceId
+		}
+	}
+
+	listAskserieVideoCollect, e := models.GetUserCygxAskserieVideoCollectList(userId)
+	if e != nil {
+		err = errors.New("GetUserCygxAskserieVideoCollectList, Err: " + e.Error())
+		return
+	}
+
+	for _, v := range listAskserieVideoCollect {
+		if v.AskserieVideoId > 0 {
+			mapAskserieVideoIds[v.AskserieVideoId] = v.AskserieVideoId
+		}
+	}
+
+	for _, item := range videoList {
+		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
+			}
+		}
+	}
+
 	respList = videoList
 	return
 }

+ 1 - 34
services/resource_data.go

@@ -321,45 +321,12 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		roadshowIdsStr := strings.Join(roadshowIds, ",")
 		askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
 
-		list, _, e := GetMicroRoadShowMycollectV12(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds), 0, audioIdstr, activityVideoIdsStr, roadshowIdsStr, askserieVideoIdsStr)
+		list, _, e := GetMicroRoadShowMycollectV12(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds), 0, audioIdstr, activityVideoIdsStr, roadshowIdsStr, askserieVideoIdsStr, user)
 		if e != nil {
 			err = errors.New("GetMicroRoadShowMycollect, Err: " + e.Error())
 			return
 		}
 
-		for _, item := range list {
-			if item.Type == 1 {
-				//音频
-				count, e := models.GetVoiceCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetVoiceCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			} else if item.Type == 2 {
-				//活动视频
-				count, e := models.GetActivityVideoCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetActivityVideoCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			} else if item.Type == 3 {
-				//微路演视频
-				count, e := models.GetVideoCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetVideoCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			}
-		}
 		// 用户权限
 		authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
 		if e != nil {