Эх сурвалжийг харах

Merge branch 'cygx_11.1.1' of http://8.136.199.33:3000/hongze/hongze_cygx

xingzai 1 жил өмнө
parent
commit
5a2f6cab86

+ 33 - 28
controllers/article.go

@@ -209,7 +209,7 @@ func (this *ArticleController) Detail() {
 			}
 			goto Loop
 		} else {
-			var articlePermissionPermissionName string
+			var articlePermissionName string
 			if detail.CategoryId > 0 {
 				articlePermission, err := models.GetArticlePermission(detail.CategoryId)
 				if err != nil {
@@ -222,13 +222,13 @@ func (this *ArticleController) Detail() {
 					br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
 					return
 				}
-				articlePermissionPermissionName = articlePermission.PermissionName
+				articlePermissionName = articlePermission.PermissionName
 			} else {
-				articlePermissionPermissionName = detail.CategoryName
+				articlePermissionName = detail.CategoryName
 			}
 
 			var hasPersion bool
-			slice := strings.Split(articlePermissionPermissionName, ",")
+			slice := strings.Split(articlePermissionName, ",")
 			for _, v := range slice {
 				if strings.Contains(companyPermission, v) {
 					hasPersion = true
@@ -246,30 +246,35 @@ func (this *ArticleController) Detail() {
 			if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
 				hasPersion = false
 			}
-			if detail.IsReport == 1 {
-				detailCategory, err := models.GetdetailByCategoryIdSando(detail.CategoryId)
-				if err != nil && err.Error() != utils.ErrNoRow() {
-					br.Msg = "获取信息失败"
-					br.ErrMsg = "获取信息失败,Err:" + err.Error() + "categoryID 不存在:" + strconv.Itoa(detail.CategoryId)
-					return
-				}
-				permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
-				if err != nil {
-					br.Msg = "获取信息失败"
-					br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
-					return
-				}
-				if detailCategory != nil {
-					if detailCategory.PermissionType == 1 {
-						if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(主观)") {
-							hasPersion = false
-						}
-					} else if detailCategory.PermissionType == 2 {
-						if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(客观)") {
-							hasPersion = false
-						}
-					}
-				}
+			//if detail.IsReport == 1 {
+			//detailCategory, err := models.GetdetailByCategoryIdSando(detail.CategoryId)
+			//if err != nil && err.Error() != utils.ErrNoRow() {
+			//	br.Msg = "获取信息失败"
+			//	br.ErrMsg = "获取信息失败,Err:" + err.Error() + "categoryID 不存在:" + strconv.Itoa(detail.CategoryId)
+			//	return
+			//}
+			//permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
+			//if err != nil {
+			//	br.Msg = "获取信息失败"
+			//	br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+			//	return
+			//}
+			//if detailCategory != nil {
+			//	if detailCategory.PermissionType == 1 {
+			//		if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(主观)") {
+			//			hasPersion = false
+			//		}
+			//	} else if detailCategory.PermissionType == 2 {
+			//		if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(客观)") {
+			//			hasPersion = false
+			//		}
+			//	}
+			//}
+			//}
+
+			//大行业通过权限校验,再校验主客观权限。只有医药、消费、科技、智造,才会校验主客观权限
+			if hasPersion && utils.InArrayByStr([]string{utils.YI_YAO_NAME, utils.XIAO_FEI_NAME, utils.KE_JI_NAME, utils.ZHI_ZAO_NAME}, articlePermissionName) {
+				hasPersion = services.CheckArticlePermissionType(articleId, user)
 			}
 			if hasPersion {
 				hasPermission = 1

+ 243 - 232
controllers/home.go

@@ -625,212 +625,223 @@ func (this *HomeController) NewList() {
 		return
 	}
 
-	var articleTypes, activityTypes, industries, subjectNames string
-	articleTypeCondSlice := make([]string, 0)
-	activityTypesCondSlice := make([]string, 0)
-	industriesCondSlice := make([]string, 0)
-	subjectNamesSlice := make([]string, 0)
-	articleTypeSlice := make([]string, 0)
-	if tagIds != "" {
-		tags := strings.Split(tagIds, ",")
-		for _, tagIdStr := range tags {
-			tagId, err := strconv.Atoi(tagIdStr)
-			if err != nil {
-				br.Msg = "转换失败"
-				br.ErrMsg = "tagid转换失败,Err:" + err.Error()
-				return
-			}
-			tagInfo, err := models.GetCygxTagByTagId(tagId)
-			if err != nil && err.Error() != utils.ErrNoRow() {
-				br.Msg = "获取失败"
-				br.ErrMsg = "GetCygxTagByTagId,Err:" + err.Error()
-				return
-			}
-			// 只有AB或CD的情况
-			if (tagInfo.ActivityTypes == "" && tagInfo.ArticleTypes == "") || (tagInfo.Industries == "" && tagInfo.SubjectNames == "") {
-				if tagInfo.ActivityTypes != "" {
-					activityTypes += tagInfo.ActivityTypes + ","
-				}
-				if tagInfo.ArticleTypes != "" {
-					articleTypes += tagInfo.ArticleTypes + ","
-				}
-				if tagInfo.Industries != "" {
-					industries += tagInfo.Industries + ","
-				}
-				if tagInfo.SubjectNames != "" {
-					subjectNames += tagInfo.SubjectNames + ","
-				}
-			} else {
-				// ABCD都有的情况
-				// 每一个tag都单独处理
-				var articleType, activityType, industry, subjectName string
-
-				if tagInfo.ActivityTypes != "" {
-					activityType = tagInfo.ActivityTypes
-				}
-				if tagInfo.ArticleTypes != "" {
-					articleType = tagInfo.ArticleTypes
-				}
-				if tagInfo.Industries != "" {
-					industry = tagInfo.Industries
-				}
-				if tagInfo.SubjectNames != "" {
-					subjectName = tagInfo.SubjectNames
-				}
-				articleTypeCond := ``
-				var articleTypeStr string
-				if articleType != "" {
-					articleTypeSlice := strings.Split(articleType, ",")
-					newArticleTypeSlice := make([]string, 0)
-					for _, s := range articleTypeSlice {
-						newArticleTypeSlice = append(newArticleTypeSlice, "'"+s+"'")
-					}
-					articleTypeStr = strings.Join(newArticleTypeSlice, ",")
-					articleTypeStr = strings.TrimRight(articleTypeStr, ",")
-					articleTypeCond += ` AND (art.sub_category_name In (` + articleTypeStr + `) OR (art.article_type_name In (` + articleTypeStr + `) AND art.article_type_name <> '路演精华' AND art.article_type_id <> 0 ) ) `
-				}
-				activityTypesCond := ``
-				if activityType != "" {
-					activityTypeSlice := strings.Split(activityType, ",")
-					newActivityTypeSlice := make([]string, 0)
-					for _, s := range activityTypeSlice {
-						newActivityTypeSlice = append(newActivityTypeSlice, "'"+s+"'")
-					}
-					activityTypeStr := strings.Join(newActivityTypeSlice, ",")
-					activityTypeStr = strings.TrimRight(activityTypeStr, ",")
-					activityTypesCond += ` AND act.activity_type_name In (` + activityTypeStr + `) `
-				}
-				industriesCond := ``
-				var industryStr string
-				if industry != "" {
-					industrieSlice := strings.Split(industry, ",")
-					newIndustrieSlice := make([]string, 0)
-					for _, s := range industrieSlice {
-						newIndustrieSlice = append(newIndustrieSlice, "'"+s+"'")
-					}
-					industryStr = strings.Join(newIndustrieSlice, ",")
-					industryStr = strings.TrimRight(industryStr, ",")
-					industriesCond += ` AND im.industry_name In (` + industryStr + `) `
-				}
-				subjectNamesCond := ``
-				var subjectNameStr string
-				if subjectName != "" {
-					subjectNameSlice := strings.Split(subjectName, ",")
-					newSubjectNameSlice := make([]string, 0)
-					for _, s := range subjectNameSlice {
-						newSubjectNameSlice = append(newSubjectNameSlice, "'"+s+"'")
-					}
-					subjectNameStr = strings.Join(newSubjectNameSlice, ",")
-					subjectNameStr = strings.TrimRight(subjectNameStr, ",")
-					subjectNamesCond += ` AND cis.subject_name In (` + subjectNameStr + `) `
-				}
-				articleTypeCondSlice = append(articleTypeCondSlice, articleTypeCond)
-				activityTypesCondSlice = append(activityTypesCondSlice, activityTypesCond)
-				industriesCondSlice = append(industriesCondSlice, industryStr)
-				subjectNamesSlice = append(subjectNamesSlice, subjectNameStr)
-				articleTypeSlice = append(articleTypeSlice, articleType)
-			}
-
-		}
-	}
+	//var articleTypes, activityTypes, industries, subjectNames string
+	//articleTypeCondSlice := make([]string, 0)
+	//activityTypesCondSlice := make([]string, 0)
+	//industriesCondSlice := make([]string, 0)
+	//subjectNamesSlice := make([]string, 0)
+	//articleTypeSlice := make([]string, 0)
+	//if tagIds != "" {
+	//	tags := strings.Split(tagIds, ",")
+	//	for _, tagIdStr := range tags {
+	//		tagId, err := strconv.Atoi(tagIdStr)
+	//		if err != nil {
+	//			br.Msg = "转换失败"
+	//			br.ErrMsg = "tagid转换失败,Err:" + err.Error()
+	//			return
+	//		}
+	//		tagInfo, err := models.GetCygxTagByTagId(tagId)
+	//		if err != nil && err.Error() != utils.ErrNoRow() {
+	//			br.Msg = "获取失败"
+	//			br.ErrMsg = "GetCygxTagByTagId,Err:" + err.Error()
+	//			return
+	//		}
+	//		// 只有AB或CD的情况
+	//		if (tagInfo.ActivityTypes == "" && tagInfo.ArticleTypes == "") || (tagInfo.Industries == "" && tagInfo.SubjectNames == "") {
+	//			if tagInfo.ActivityTypes != "" {
+	//				activityTypes += tagInfo.ActivityTypes + ","
+	//			}
+	//			if tagInfo.ArticleTypes != "" {
+	//				articleTypes += tagInfo.ArticleTypes + ","
+	//			}
+	//			if tagInfo.Industries != "" {
+	//				industries += tagInfo.Industries + ","
+	//			}
+	//			if tagInfo.SubjectNames != "" {
+	//				subjectNames += tagInfo.SubjectNames + ","
+	//			}
+	//		} else {
+	//			// ABCD都有的情况
+	//			// 每一个tag都单独处理
+	//			var articleType, activityType, industry, subjectName string
+	//
+	//			if tagInfo.ActivityTypes != "" {
+	//				activityType = tagInfo.ActivityTypes
+	//			}
+	//			if tagInfo.ArticleTypes != "" {
+	//				articleType = tagInfo.ArticleTypes
+	//			}
+	//			if tagInfo.Industries != "" {
+	//				industry = tagInfo.Industries
+	//			}
+	//			if tagInfo.SubjectNames != "" {
+	//				subjectName = tagInfo.SubjectNames
+	//			}
+	//			articleTypeCond := ``
+	//			var articleTypeStr string
+	//			if articleType != "" {
+	//				articleTypeSlice := strings.Split(articleType, ",")
+	//				newArticleTypeSlice := make([]string, 0)
+	//				for _, s := range articleTypeSlice {
+	//					newArticleTypeSlice = append(newArticleTypeSlice, "'"+s+"'")
+	//				}
+	//				articleTypeStr = strings.Join(newArticleTypeSlice, ",")
+	//				articleTypeStr = strings.TrimRight(articleTypeStr, ",")
+	//				articleTypeCond += ` AND (art.sub_category_name In (` + articleTypeStr + `) OR (art.article_type_name In (` + articleTypeStr + `) AND art.article_type_name <> '路演精华' AND art.article_type_id <> 0 ) ) `
+	//			}
+	//			activityTypesCond := ``
+	//			if activityType != "" {
+	//				activityTypeSlice := strings.Split(activityType, ",")
+	//				newActivityTypeSlice := make([]string, 0)
+	//				for _, s := range activityTypeSlice {
+	//					newActivityTypeSlice = append(newActivityTypeSlice, "'"+s+"'")
+	//				}
+	//				activityTypeStr := strings.Join(newActivityTypeSlice, ",")
+	//				activityTypeStr = strings.TrimRight(activityTypeStr, ",")
+	//				activityTypesCond += ` AND act.activity_type_name In (` + activityTypeStr + `) `
+	//			}
+	//			industriesCond := ``
+	//			var industryStr string
+	//			if industry != "" {
+	//				industrieSlice := strings.Split(industry, ",")
+	//				newIndustrieSlice := make([]string, 0)
+	//				for _, s := range industrieSlice {
+	//					newIndustrieSlice = append(newIndustrieSlice, "'"+s+"'")
+	//				}
+	//				industryStr = strings.Join(newIndustrieSlice, ",")
+	//				industryStr = strings.TrimRight(industryStr, ",")
+	//				industriesCond += ` AND im.industry_name In (` + industryStr + `) `
+	//			}
+	//			subjectNamesCond := ``
+	//			var subjectNameStr string
+	//			if subjectName != "" {
+	//				subjectNameSlice := strings.Split(subjectName, ",")
+	//				newSubjectNameSlice := make([]string, 0)
+	//				for _, s := range subjectNameSlice {
+	//					newSubjectNameSlice = append(newSubjectNameSlice, "'"+s+"'")
+	//				}
+	//				subjectNameStr = strings.Join(newSubjectNameSlice, ",")
+	//				subjectNameStr = strings.TrimRight(subjectNameStr, ",")
+	//				subjectNamesCond += ` AND cis.subject_name In (` + subjectNameStr + `) `
+	//			}
+	//			articleTypeCondSlice = append(articleTypeCondSlice, articleTypeCond)
+	//			activityTypesCondSlice = append(activityTypesCondSlice, activityTypesCond)
+	//			industriesCondSlice = append(industriesCondSlice, industryStr)
+	//			subjectNamesSlice = append(subjectNamesSlice, subjectNameStr)
+	//			articleTypeSlice = append(articleTypeSlice, articleType)
+	//		}
+	//
+	//	}
+	//}
+	//
+	//// 先拿abdc都有的tag取合集的ids。。。
+	//soloTagArticleIds, soloTagActivityIds, soloMmIds, err := models.GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityTypesCondSlice, industriesCondSlice, subjectNamesSlice, articleTypeSlice)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	br.Msg = "获取失败"
+	//	br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
+	//	return
+	//}
+	//
+	//articleTypes = strings.TrimRight(articleTypes, ",")
+	//activityTypes = strings.TrimRight(activityTypes, ",")
+	//industries = strings.TrimRight(industries, ",")
+	//subjectNames = strings.TrimRight(subjectNames, ",")
+	//
+	//articleTypesCond := ``
+	//var articleTypeStr string
+	//if articleTypes != "" {
+	//	articleTypeSlice := strings.Split(articleTypes, ",")
+	//	newArticleTypeSlice := make([]string, 0)
+	//	for _, s := range articleTypeSlice {
+	//		newArticleTypeSlice = append(newArticleTypeSlice, "'"+s+"'")
+	//	}
+	//	articleTypeStr = strings.Join(newArticleTypeSlice, ",")
+	//	articleTypeStr = strings.TrimRight(articleTypeStr, ",")
+	//	articleTypesCond += ` AND (art.sub_category_name In (` + articleTypeStr + `) OR (art.article_type_name In (` + articleTypeStr + `) AND art.article_type_name <> '路演精华' AND art.article_type_id <> 0 ) ) `
+	//}
+	//activityTypesCond := ``
+	//if activityTypes != "" {
+	//	activityTypeSlice := strings.Split(activityTypes, ",")
+	//	newActivityTypeSlice := make([]string, 0)
+	//	for _, s := range activityTypeSlice {
+	//		newActivityTypeSlice = append(newActivityTypeSlice, "'"+s+"'")
+	//	}
+	//	activityTypeStr := strings.Join(newActivityTypeSlice, ",")
+	//	activityTypeStr = strings.TrimRight(activityTypeStr, ",")
+	//	activityTypesCond += ` AND act.activity_type_name In (` + activityTypeStr + `) `
+	//}
+	//industriesCond := ``
+	//var industryStr string
+	//if industries != "" {
+	//	industrieSlice := strings.Split(industries, ",")
+	//	newIndustrieSlice := make([]string, 0)
+	//	for _, s := range industrieSlice {
+	//		newIndustrieSlice = append(newIndustrieSlice, "'"+s+"'")
+	//	}
+	//	industryStr = strings.Join(newIndustrieSlice, ",")
+	//	industryStr = strings.TrimRight(industryStr, ",")
+	//	industriesCond += ` AND im.industry_name In (` + industryStr + `) `
+	//}
+	//subjectNamesCond := ``
+	//var subjectNameStr string
+	//if subjectNames != "" {
+	//	subjectNameSlice := strings.Split(subjectNames, ",")
+	//	newSubjectNameSlice := make([]string, 0)
+	//	for _, s := range subjectNameSlice {
+	//		newSubjectNameSlice = append(newSubjectNameSlice, "'"+s+"'")
+	//	}
+	//	subjectNameStr = strings.Join(newSubjectNameSlice, ",")
+	//	subjectNameStr = strings.TrimRight(subjectNameStr, ",")
+	//	subjectNamesCond += ` AND cis.subject_name In (` + subjectNameStr + `) `
+	//}
+	//
+	//var tagArticleIds, tagActivityIds, mmIds string
+	//if articleTypesCond != "" || activityTypesCond != "" || industryStr != "" || subjectNameStr != "" {
+	//	tagArticleIds, tagActivityIds, mmIds, err = models.GetCygxCygxArticleListByCondition(articleTypesCond, activityTypesCond, industryStr, subjectNameStr, articleTypeStr)
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		br.Msg = "获取失败"
+	//		br.ErrMsg = "获取单个标签ids失败,Err:" + err.Error()
+	//		return
+	//	}
+	//}
+	//
+	//if soloTagArticleIds != "" {
+	//	if tagArticleIds != "" {
+	//		tagArticleIds += "," + soloTagArticleIds
+	//	} else {
+	//		tagArticleIds = soloTagArticleIds
+	//	}
+	//}
+	//if soloTagActivityIds != "" {
+	//	if tagActivityIds != "" {
+	//		tagActivityIds += "," + soloTagActivityIds
+	//	} else {
+	//		tagActivityIds = soloTagActivityIds
+	//	}
+	//}
+	//if soloMmIds != "" {
+	//	if mmIds != "" {
+	//		mmIds += "," + soloMmIds
+	//	} else {
+	//		mmIds = soloMmIds
+	//	}
+	//}
 
-	// 先拿abdc都有的tag取合集的ids。。。
-	soloTagArticleIds, soloTagActivityIds, soloMmIds, err := models.GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityTypesCondSlice, industriesCondSlice, subjectNamesSlice, articleTypeSlice)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
-		return
-	}
+	//fmt.Println("condition:",condition)
 
-	articleTypes = strings.TrimRight(articleTypes, ",")
-	activityTypes = strings.TrimRight(activityTypes, ",")
-	industries = strings.TrimRight(industries, ",")
-	subjectNames = strings.TrimRight(subjectNames, ",")
-
-	articleTypesCond := ``
-	var articleTypeStr string
-	if articleTypes != "" {
-		articleTypeSlice := strings.Split(articleTypes, ",")
-		newArticleTypeSlice := make([]string, 0)
-		for _, s := range articleTypeSlice {
-			newArticleTypeSlice = append(newArticleTypeSlice, "'"+s+"'")
-		}
-		articleTypeStr = strings.Join(newArticleTypeSlice, ",")
-		articleTypeStr = strings.TrimRight(articleTypeStr, ",")
-		articleTypesCond += ` AND (art.sub_category_name In (` + articleTypeStr + `) OR (art.article_type_name In (` + articleTypeStr + `) AND art.article_type_name <> '路演精华' AND art.article_type_id <> 0 ) ) `
-	}
-	activityTypesCond := ``
-	if activityTypes != "" {
-		activityTypeSlice := strings.Split(activityTypes, ",")
-		newActivityTypeSlice := make([]string, 0)
-		for _, s := range activityTypeSlice {
-			newActivityTypeSlice = append(newActivityTypeSlice, "'"+s+"'")
-		}
-		activityTypeStr := strings.Join(newActivityTypeSlice, ",")
-		activityTypeStr = strings.TrimRight(activityTypeStr, ",")
-		activityTypesCond += ` AND act.activity_type_name In (` + activityTypeStr + `) `
-	}
-	industriesCond := ``
-	var industryStr string
-	if industries != "" {
-		industrieSlice := strings.Split(industries, ",")
-		newIndustrieSlice := make([]string, 0)
-		for _, s := range industrieSlice {
-			newIndustrieSlice = append(newIndustrieSlice, "'"+s+"'")
-		}
-		industryStr = strings.Join(newIndustrieSlice, ",")
-		industryStr = strings.TrimRight(industryStr, ",")
-		industriesCond += ` AND im.industry_name In (` + industryStr + `) `
-	}
-	subjectNamesCond := ``
-	var subjectNameStr string
-	if subjectNames != "" {
-		subjectNameSlice := strings.Split(subjectNames, ",")
-		newSubjectNameSlice := make([]string, 0)
-		for _, s := range subjectNameSlice {
-			newSubjectNameSlice = append(newSubjectNameSlice, "'"+s+"'")
-		}
-		subjectNameStr = strings.Join(newSubjectNameSlice, ",")
-		subjectNameStr = strings.TrimRight(subjectNameStr, ",")
-		subjectNamesCond += ` AND cis.subject_name In (` + subjectNameStr + `) `
-	}
-
-	var tagArticleIds, tagActivityIds, mmIds string
-	if articleTypesCond != "" || activityTypesCond != "" || industryStr != "" || subjectNameStr != "" {
-		tagArticleIds, tagActivityIds, mmIds, err = models.GetCygxCygxArticleListByCondition(articleTypesCond, activityTypesCond, industryStr, subjectNameStr, articleTypeStr)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+	if tagIds != "" {
+		conditionTagIdsInit, err := services.GetConditionInitByTagIds(tagIds)
+		if err != nil {
 			br.Msg = "获取失败"
-			br.ErrMsg = "获取单个标签ids失败,Err:" + err.Error()
+			br.ErrMsg = "获取活动权限数据失败,GetConditionInitByTagIds Err:" + err.Error()
 			return
 		}
+		conditionInit += conditionTagIdsInit
+	} else {
+		//查询近一个月的数据
+		conditionInit = " AND publish_date  >   '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"
 	}
 
-	if soloTagArticleIds != "" {
-		if tagArticleIds != "" {
-			tagArticleIds += "," + soloTagArticleIds
-		} else {
-			tagArticleIds = soloTagArticleIds
-		}
-	}
-	if soloTagActivityIds != "" {
-		if tagActivityIds != "" {
-			tagActivityIds += "," + soloTagActivityIds
-		} else {
-			tagActivityIds = soloTagActivityIds
-		}
-	}
-	if soloMmIds != "" {
-		if mmIds != "" {
-			mmIds += "," + soloMmIds
-		} else {
-			mmIds = soloMmIds
-		}
-	}
-
-	//fmt.Println("condition:",condition)
-
-	//查询近一个月的数据
-	conditionInit = " AND publish_date  >   '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"
 	//conditionInit += `  AND source IN ('newchart')`
 	if user.CompanyId <= 1 || totalRai == 0 {
 		condition += " AND source IN ('roadshow','article') "
@@ -879,44 +890,44 @@ func (this *HomeController) NewList() {
 		}
 		lenActivityspecialIds := len(activityspecialIds)
 
-		if tagIds != "" {
-			if tagArticleIds != "" {
-				condition = ` AND ((source = 'article' AND source_id IN (` + tagArticleIds + `) ) `
-				if mmIds != "" {
-					condition += ` OR ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) )   `
-				}
-				if tagActivityIds != "" && lenActivityIds > 0 {
-					condition += ` OR (source = 'activity' AND source_id IN (` + tagActivityIds + `) AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `) )) `
-					pars = append(pars, activityIds)
-				} else {
-					// 无可见活动
-					condition += ` OR (source = 'activity' AND source_id IN (0))) `
-				}
-			} else if tagActivityIds != "" {
-				condition = ` AND ((source = 'article' AND source_id IN (0))  `
-				if mmIds != "" {
-					condition += ` OR ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) )   `
-				}
-				if tagActivityIds != "" && lenActivityIds > 0 {
-					condition += ` OR (source = 'activity' AND source_id IN (` + tagActivityIds + `) AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `))) `
-					pars = append(pars, activityIds)
-				} else {
-					// 无可见活动
-					condition += ` OR (source = 'activity' AND source_id IN (0))) `
-				}
-			} else if mmIds != "" {
-				condition = ` AND ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) )   `
-			} else {
-				condition += ` AND ((source = 'article' AND source_id IN (0)) OR (source = 'activity' AND source_id IN (0))) `
-			}
-		}
+		//if tagIds != "" {
+		//	if tagArticleIds != "" {
+		//		condition = ` AND ((source = 'article' AND source_id IN (` + tagArticleIds + `) ) `
+		//		if mmIds != "" {
+		//			condition += ` OR ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) )   `
+		//		}
+		//		if tagActivityIds != "" && lenActivityIds > 0 {
+		//			condition += ` OR (source = 'activity' AND source_id IN (` + tagActivityIds + `) AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `) )) `
+		//			pars = append(pars, activityIds)
+		//		} else {
+		//			// 无可见活动
+		//			condition += ` OR (source = 'activity' AND source_id IN (0))) `
+		//		}
+		//	} else if tagActivityIds != "" {
+		//		condition = ` AND ((source = 'article' AND source_id IN (0))  `
+		//		if mmIds != "" {
+		//			condition += ` OR ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) )   `
+		//		}
+		//		if tagActivityIds != "" && lenActivityIds > 0 {
+		//			condition += ` OR (source = 'activity' AND source_id IN (` + tagActivityIds + `) AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `))) `
+		//			pars = append(pars, activityIds)
+		//		} else {
+		//			// 无可见活动
+		//			condition += ` OR (source = 'activity' AND source_id IN (0))) `
+		//		}
+		//	} else if mmIds != "" {
+		//		condition = ` AND ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) )   `
+		//	} else {
+		//		condition += ` AND ((source = 'article' AND source_id IN (0)) OR (source = 'activity' AND source_id IN (0))) `
+		//	}
+		//}
 
-		if lenActivityIds > 0 && tagIds == "" {
+		if lenActivityIds > 0 {
 			condition += ` OR ( source = 'activity' AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `) ` + conditionInit + ` )    `
 			pars = append(pars, activityIds)
 		}
 
-		if lenActivityspecialIds > 0 && tagIds == "" {
+		if lenActivityspecialIds > 0 {
 			condition += ` OR ( source = 'activityspecial' AND source_id IN (` + utils.GetOrmInReplace(lenActivityspecialIds) + `) ` + conditionInit + ` )   `
 			pars = append(pars, activityspecialIds)
 		}

+ 19 - 3
controllers/tag.go

@@ -10,7 +10,6 @@ type TagController struct {
 	BaseAuthController
 }
 
-
 // @Title 获取标签列表-自定义顺序
 // @Description 获取标签列表-自定义顺序接口
 // @Success 200 {object} cygx.ChartPermissionResp
@@ -47,8 +46,25 @@ func (this *TagController) TagCustomizeList() {
 		return
 	}
 
-
 	list, err := models.GetCygxTagList(condition)
+	for _, v := range list {
+		if v.ArticleTypes != "" {
+			v.Atag = true
+			v.CheckList = append(v.CheckList, "A")
+		}
+		if v.ActivityTypes != "" {
+			v.Btag = true
+			v.CheckList = append(v.CheckList, "B")
+		}
+		if v.Industries != "" {
+			v.Ctag = true
+			v.CheckList = append(v.CheckList, "C")
+		}
+		if v.SubjectNames != "" {
+			v.Dtag = true
+			v.CheckList = append(v.CheckList, "D")
+		}
+	}
 	if err != nil {
 		br.Msg = "获取标签失败"
 		br.ErrMsg = "获取标签信息失败,Err:" + err.Error()
@@ -96,4 +112,4 @@ func (this *TagController) History() {
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "记录成功"
-}
+}

+ 3 - 0
models/article.go

@@ -177,7 +177,10 @@ type ArticleDetail struct {
 	IsRoadShow               bool   `description:"是否是路演精华"`
 	ReportType               int    `description:"报告类型,1行业报告,2产业报告,0无"`
 	FieldName                string `description:"策略平台的领域字段名称"`
+	TypeName                 string `description:"策略平台类型字段名称"`
 	IsApplyAppointmentExpert bool   `description:"是否属于专家访谈"`
+	ArticleTypeName          string `description:"权限名称"`
+	MatchTypeName            string `description:"匹配类型"`
 }
 
 type ArticleDetailFileLink struct {

+ 0 - 16
models/article_category_mapping.go

@@ -2,7 +2,6 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
-	"time"
 	//"time"
 )
 
@@ -30,21 +29,6 @@ func AddCygxArticleCategoryMapping(item *CygxArticleCategoryMapping) (lastId int
 	return
 }
 
-type CygxReportMappingGroup struct {
-	Id              int       `orm:"column(id);pk" description:"id"`
-	IdCygx          int       `description:"分类ID"`
-	CategoryIdCelue int       `description:"分类ID"`
-	CreateTime      time.Time `description:"创建时间"`
-	ModifyTime      time.Time `description:"更新时间"`
-}
-
-// 添加
-func AddCygxReportMappingGroup(item *CygxReportMappingGroup) (lastId int64, err error) {
-	o := orm.NewOrm()
-	lastId, err = o.Insert(item)
-	return
-}
-
 // 添加
 func AddCygxReportMappingCygx(item *CygxReportMappingCygx) (lastId int64, err error) {
 	o := orm.NewOrm()

+ 33 - 12
models/cygx_tag.go

@@ -34,20 +34,41 @@ func (m *CygxTag) Update(cols []string) (err error) {
 }
 
 type CygxTagList struct {
-	TagId         int64  `orm:"column(tag_id);pk"`
-	TagName       string `orm:"column(tag_name);NOT NULL"`       // 标签名
-	ArticleTypes  string `orm:"column(article_types);NOT NULL"`  // 报告系列
-	ActivityTypes string `orm:"column(activity_types);NOT NULL"` // 活动类型
-	Industries    string `orm:"column(industries);NOT NULL"`     // 产业
-	SubjectNames  string `orm:"column(subject_names);NOT NULL"`  // 标的
-	Sort          int    `orm:"column(sort);"`                   // 优先级
-	ModifyTime    string `orm:"column(modify_time)"`             // 修改时间
-	CreateTime    string `orm:"column(create_time)"`             // 创建时间
-	OnlineTime    string `orm:"column(online_time)"`             // 上线时间
-	OfflineTime   string `orm:"column(offline_time)"`            // 下线时间
-	Status        int    `orm:"column(status);NOT NULL"`         // 状态:0-禁用 1-启用
+	TagId         int64    `orm:"column(tag_id);pk"`
+	TagName       string   `orm:"column(tag_name);NOT NULL"`       // 标签名
+	ArticleTypes  string   `orm:"column(article_types);NOT NULL"`  // 报告系列
+	ActivityTypes string   `orm:"column(activity_types);NOT NULL"` // 活动类型
+	Industries    string   `orm:"column(industries);NOT NULL"`     // 产业
+	SubjectNames  string   `orm:"column(subject_names);NOT NULL"`  // 标的
+	Sort          int      `orm:"column(sort);"`                   // 优先级
+	ModifyTime    string   `orm:"column(modify_time)"`             // 修改时间
+	CreateTime    string   `orm:"column(create_time)"`             // 创建时间
+	OnlineTime    string   `orm:"column(online_time)"`             // 上线时间
+	OfflineTime   string   `orm:"column(offline_time)"`            // 下线时间
+	Status        int      `orm:"column(status);NOT NULL"`         // 状态:0-禁用 1-启用
+	Atag          bool     // A标签是否有值
+	Btag          bool     // A标签是否有值
+	Ctag          bool     // A标签是否有值
+	Dtag          bool     // A标签是否有值
+	CheckList     []string // ABCD勾选了哪几列
 }
 
+// 列表
+func GetCygxTagListCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxTagList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_tag as a WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	if startSize+pageSize > 0 {
+		sql += ` LIMIT ?,?  `
+		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	} else {
+		_, err = o.Raw(sql, pars).QueryRows(&items)
+	}
+
+	return
+}
 
 // 获取tag列表
 func GetCygxTagList(cond string) (items []*CygxTagList, err error) {

+ 3 - 0
models/db.go

@@ -156,11 +156,14 @@ func init() {
 		new(CygxActivityPointsBill),
 		new(CygxActivityPointsCompany),
 		new(CygxTagHistory),
+		new(CygxReportMappingCategoryGroup),
 		new(CygxActivitySpecialInheritPointsCompany),
 		new(CygxApplyCollection),
 		new(CygxArticleApplyAppointmentExpert),
 		new(CygxBannerYxSurvey),
 		new(CygxReportSelectionLogApply),
+		new(CygxResourceDataIndustrialGroupManagement),
+		new(CygxResourceDataIndustrialGroupSubject),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 18 - 0
models/industrial_article_group_management.go

@@ -78,3 +78,21 @@ func GetIndustrialArticleGroupManagementList(condition string, pars []interface{
 	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
 	return
 }
+
+// 列表
+func GetIndustrialArticleGroupManagementListByArticleId(articleId int) (items []*CygxIndustrialArticleGroupManagement, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			p.permission_name,
+			p.chart_permission_id,
+			m.industrial_management_id,
+			m.industry_name 
+			FROM
+			cygx_industrial_article_group_management AS am
+			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = am.industrial_management_id
+			INNER JOIN chart_permission AS p ON p.chart_permission_id = m.chart_permission_id 
+			WHERE
+			am.article_id = ?`
+	_, err = o.Raw(sql, articleId).QueryRows(&items)
+	return
+}

+ 15 - 0
models/industrial_article_group_subject.go

@@ -64,3 +64,18 @@ func GetIndustrialArticleGroupSubjectListByHz(IndustrialManagementId int) (items
 	_, err = o.Raw(sql, IndustrialManagementId).QueryRows(&items)
 	return
 }
+
+// 列表
+func GetSubjectArticleGroupManagementListByArtcileId(articleId int) (items []*SubjectActivityGroupManagementRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			s.subject_name,
+			s.industrial_subject_id 
+			FROM
+			cygx_industrial_article_group_subject AS ag
+			INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = ag.industrial_subject_id 
+			WHERE
+			ag.article_id = ?`
+	_, err = o.Raw(sql, articleId).QueryRows(&items)
+	return
+}

+ 2 - 2
models/report.go

@@ -122,7 +122,7 @@ func GetReportAndproductInteriorIndustrialList(pars []interface{}, categoryId, i
 			INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id 
 		WHERE
 			art.publish_status = 1 
-			AND category_id IN ( SELECT category_id_celue FROM cygx_report_mapping_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` ) 
+			AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` ) 
 			AND art.is_class = 1 
 			AND man_g.industrial_management_id =` + strconv.Itoa(industrialManagementId) + ` 
 		GROUP BY
@@ -164,7 +164,7 @@ func GetReportAndproductIndustrylList(categoryId, startSize, pageSize int) (item
 			cygx_article AS art 
 		WHERE
 			art.publish_status = 1 
-			AND category_id IN ( SELECT category_id_celue FROM cygx_report_mapping_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` ) UNION ALL
+			AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` ) UNION ALL
 		SELECT
 			art.product_interior_id AS article_id,
 			art.title,

+ 64 - 0
models/report_mapping_category_group.go

@@ -0,0 +1,64 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxReportMappingCategoryGroup struct {
+	Id                int       `orm:"column(id);pk" description:"id"`
+	ChartPermissionId int       `description:"行业ID"`
+	IdCygx            int       `description:"表cygx_report_mapping_cygx 主键ID"`
+	ArticleId         int       `description:"报告Id"`
+	CreateTime        time.Time `description:"创建时间"`
+	ModifyTime        time.Time `description:"更新时间"`
+	PermissionType    int       `description:"1主观,2客观 ,0不限制"`
+}
+
+type CygxReportMappingCategoryGroupResp struct {
+	Id                int       `orm:"column(id);pk" description:"id"`
+	ChartPermissionId int       `description:"行业ID"`
+	IdCygx            int       `description:"表cygx_report_mapping_cygx 主键ID"`
+	ArticleId         int       `description:"报告Id"`
+	CreateTime        time.Time `description:"创建时间"`
+	ModifyTime        time.Time `description:"更新时间"`
+	PermissionType    int       `description:"1主观,2客观 ,0不限制"`
+}
+
+// AddCygxReportMappingCategoryGroupMulti 批量添加
+func AddCygxReportMappingCategoryGroupMulti(items []*CygxReportMappingCategoryGroup, articleId int) (err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	//删除原有数据
+	sql := ` DELETE FROM cygx_report_mapping_category_group WHERE article_id = ? AND is_by_hand = 0  `
+	_, err = o.Raw(sql, articleId).Exec()
+	if err != nil {
+		return
+	}
+	//批量插入新的关联数据
+	if len(items) > 0 {
+		//批量添加流水信息
+		_, err = o.InsertMulti(len(items), items)
+	}
+	return
+}
+
+// 列表
+func GetCygxReportMappingCategoryGroupList(condition string, pars []interface{}) (items []*CygxReportMappingCategoryGroupResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_mapping_category_group as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 1 - 2
models/report_mapping_cygx.go

@@ -19,13 +19,12 @@ type CygxReportMappingCygx struct {
 }
 
 // 列表
-func GetCygxReportMappingCygxByCon(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportMappingCygx, err error) {
+func GetCygxReportMappingCygxByCon(condition string, pars []interface{}) (items []*CygxReportMappingCygx, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_report_mapping_cygx as art WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
 	}
-	//sql += ` LIMIT ?,?  `
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }

+ 32 - 0
models/report_mapping_group.go

@@ -0,0 +1,32 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxReportMappingGroup struct {
+	Id              int       `orm:"column(id);pk" description:"id"`
+	IdCygx          int       `description:"分类ID"`
+	CategoryIdCelue int       `description:"分类ID"`
+	CreateTime      time.Time `description:"创建时间"`
+	ModifyTime      time.Time `description:"更新时间"`
+}
+
+// 添加
+func AddCygxReportMappingGroup(item *CygxReportMappingGroup) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 列表
+func GetCygxReportMappingGroupList(condition string, pars []interface{}) (items []*CygxReportMappingGroup, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_mapping_group  WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 2 - 0
models/report_selection.go

@@ -16,6 +16,8 @@ type CygxReportSelectionRep struct {
 	IsRed             bool   `description:"是否标记红点"`
 	ReadNum           int    `description:"阅读次数"`
 	SubjectName       string `description:"标的名称"`
+	Periods           string `description:"期数"`
+	MarketStrategy    string `description:"市场策略核心逻辑汇总"`
 }
 
 type CygxReportSelectionListPublicRep struct {

+ 37 - 0
models/resource_data.go

@@ -15,6 +15,7 @@ type CygxResourceData struct {
 	CreateTime  time.Time `description:"创建时间"`
 	PublishDate string    `description:"发布时间"`
 	Abstract    string    `description:"摘要"`
+	SearchTag   string    `description:"搜索标签"`
 }
 
 type CygxResourceDataResp struct {
@@ -36,6 +37,7 @@ type CygxResourceDataResp struct {
 	Meetingreviewchapt *CygxMorningMeetingGatherDetailListResp `description:"晨会精华"`
 	ProductInterior    *CygxProductInteriorResp                `description:"产品内测"`
 	IndustrialResource *IndustrialManagementHotResp            `description:"产业资源包"`
+	ReportSelection    *CygxReportSelectionRep                 `description:"重点公司(原报告精选)"`
 }
 
 // Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
@@ -87,6 +89,25 @@ func UpdateResourceData(sourceId int, source, publishDate string) (err error) {
 	return
 }
 
+// 修改
+func UpdateResourceDataByItem(item *CygxResourceData) (err error) {
+	o := orm.NewOrm()
+	updateParams := make(map[string]interface{})
+	updateParams["PublishDate"] = item.PublishDate
+	updateParams["SearchTag"] = item.SearchTag
+	ptrStructOrTableName := "cygx_resource_data"
+	whereParam := map[string]interface{}{"source_id": item.SourceId, "source": item.Source}
+	qs := o.QueryTable(ptrStructOrTableName)
+	for expr, exprV := range whereParam {
+		qs = qs.Filter(expr, exprV)
+	}
+	_, err = qs.Update(updateParams)
+	if err != nil {
+		return
+	}
+	return
+}
+
 // 批量删除
 func DeleteResourceDataList(condition string, pars []interface{}) (err error) {
 	if condition == "" {
@@ -97,3 +118,19 @@ func DeleteResourceDataList(condition string, pars []interface{}) (err error) {
 	_, err = o.Raw(sql, pars).Exec()
 	return
 }
+
+// 获取数量
+func GetCygxReportSelectionBySourceAndId(sourceId int, source string) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_resource_data  WHERE  source_id = ? AND source =?  `
+	err = o.Raw(sqlCount, sourceId, source).QueryRow(&count)
+	return
+}
+
+// 通过ID跟资源获取详情
+func GetCygxResourceDataByIdAndSource(sourceId int, source string) (item *CygxResourceData, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_resource_data WHERE  source_id = ? AND source =?  `
+	err = o.Raw(sql, sourceId, source).QueryRow(&item)
+	return
+}

+ 136 - 0
models/resource_data_industrial_group_management.go

@@ -0,0 +1,136 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// 首页资源表与产业的关系
+type CygxResourceDataIndustrialGroupManagement struct {
+	Id                     int       `orm:"column(id);pk" description:"主键ID"`
+	ResourceDataId         int       `description:"cygx_resource_data 主键ID"`
+	SourceId               int       `description:"资源ID"`
+	Source                 string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	IndustrialManagementId int       `description:"cygx_industrial_management表的主键ID"`
+	CreateTime             time.Time `description:"创建时间"`
+}
+
+// 首页资源表与产业的关系
+type CygxResourceDataIndustrialGroupSubject struct {
+	Id                  int       `orm:"column(id);pk" description:"主键ID"`
+	ResourceDataId      int       `description:"cygx_resource_data 主键ID"`
+	SourceId            int       `description:"资源ID"`
+	Source              string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	IndustrialSubjectId int       `description:"cygx_industrial_subject表的主键ID"`
+	CreateTime          time.Time `description:"创建时间"`
+}
+
+// 关联产业列表
+func GetCygxResourceDataIndustrialGroupManagementList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResourceDataIndustrialGroupManagement, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_resource_data_industrial_group_management as a WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	if startSize+pageSize > 0 {
+		sql += ` LIMIT ?,?  `
+		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	} else {
+		_, err = o.Raw(sql, pars).QueryRows(&items)
+	}
+
+	return
+}
+
+// 关联标的列表
+func GetCygxResourceDataIndustrialGroupSubjectList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResourceDataIndustrialGroupSubject, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_resource_data_industrial_group_subject as a WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	if startSize+pageSize > 0 {
+		sql += ` LIMIT ?,?  `
+		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	} else {
+		_, err = o.Raw(sql, pars).QueryRows(&items)
+	}
+
+	return
+}
+
+// 添加
+func AddCygxResourceDataGroup(sourceId int, source string, industrialItems []*CygxResourceDataIndustrialGroupManagement, subjectItems []*CygxResourceDataIndustrialGroupSubject) (err error) {
+	o := orm.NewOrm()
+	to, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = to.Rollback()
+		} else {
+			_ = to.Commit()
+		}
+	}()
+	//删除关联产业
+	sql := `	DELETE FROM cygx_resource_data_industrial_group_management WHERE source_id = ? AND source =? `
+	_, err = to.Raw(sql, sourceId, source).Exec()
+	if err != nil {
+		return
+	}
+	//删除关联标的
+	sql = `	DELETE FROM cygx_resource_data_industrial_group_subject WHERE source_id = ? AND source =? `
+	_, err = to.Raw(sql, sourceId, source).Exec()
+	if err != nil {
+		return
+	}
+
+	//批量插入关联产业
+	if len(industrialItems) > 0 {
+		_, err = to.InsertMulti(len(industrialItems), industrialItems)
+		if err != nil {
+			return
+		}
+	}
+
+	//批量插入关联标的
+	if len(subjectItems) > 0 {
+		_, err = to.InsertMulti(len(subjectItems), subjectItems)
+		if err != nil {
+			return
+		}
+	}
+
+	return
+}
+
+// 删除
+func DeleteCygxResourceDataGroup(sourceId int, source string) (err error) {
+	o := orm.NewOrm()
+	to, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = to.Rollback()
+		} else {
+			_ = to.Commit()
+		}
+	}()
+	//删除关联产业
+	sql := `	DELETE FROM cygx_resource_data_industrial_group_management WHERE source_id = ? AND source =? `
+	_, err = to.Raw(sql, sourceId, source).Exec()
+	if err != nil {
+		return
+	}
+	//删除关联标的
+	sql = `	DELETE FROM cygx_resource_data_industrial_group_subject WHERE source_id = ? AND source =? `
+	_, err = to.Raw(sql, sourceId, source).Exec()
+	if err != nil {
+		return
+	}
+
+	return
+}

+ 18 - 4
services/article.go

@@ -841,7 +841,8 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			fmt.Println("UpdateArticlePublish Err:", err.Error())
 			return err
 		}
-		go UpdateResourceData(artcleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
+		go UpdateArticleResourceData(artcleId) //把数据写入 cygx_resource_data 表
+		//go UpdateResourceData(artcleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
 		return err
 	}
 
@@ -971,7 +972,8 @@ func HandleArticleListByApi(artcleId int) (err error) {
 				//fmt.Println("触发推送规则")
 				//更新字数大于一百字触发推送规则
 				go DoArticleOnenIdWxTemplateMsg(v.ArticleId)
-				go UpdateResourceData(v.ArticleId, "article", "update", time.Now().Format(utils.FormatDateTime))
+				go UpdateArticleResourceData(v.ArticleId) //把数据写入 cygx_resource_data 表
+				//go UpdateResourceData(v.ArticleId, "article", "update", time.Now().Format(utils.FormatDateTime))
 			}
 			var isCustom bool
 			updateParams := make(map[string]interface{})
@@ -1065,8 +1067,8 @@ func HandleArticleListByApi(artcleId int) (err error) {
 				fmt.Println("AddCygxArticle Err:", err.Error())
 				return err
 			}
-			go UpdateResourceData(v.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
-
+			//go UpdateResourceData(v.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
+			go UpdateArticleResourceData(v.ArticleId) //把数据写入 cygx_resource_data 表
 			//fmt.Println(newId)
 			//报告自动归类,以及推送相关模板消息
 			if v.ReportType == 2 {
@@ -1189,6 +1191,8 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			//}
 		}
 	}
+
+	AddCygxReportMappingCategoryGroupByArticleId(artcleId)
 	return err
 }
 
@@ -1583,6 +1587,16 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
 
 // GetSpecialArticleDetailUserPower 处理用户查看专项调研文章详情的权限
 func GetSpecialArticleDetailUserPower(user *models.WxUserItem, articleInfo *models.ArticleDetail) (havePower bool, err error) {
+	userType, _, e := GetUserType(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetSpecialUserType, Err: " + e.Error())
+		return
+	}
+	// 永续客户、大套餐客户可以查看行业升级套餐客户 权限
+	if userType == 1 || userType == 2 {
+		havePower = true
+		return
+	}
 	permissionStr, e := GetCompanyPermissionUpgrade(user.CompanyId)
 	if e != nil {
 		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())

+ 1 - 1
services/init_10.5.1.go

@@ -69,7 +69,7 @@ func init123() {
 
 	var topCond string
 	var topPars []interface{}
-	toplist, err := models.GetCygxReportMappingCygxByCon(topCond, topPars, 0, 0)
+	toplist, err := models.GetCygxReportMappingCygxByCon(topCond, topPars)
 	if err != nil {
 		return
 	}

+ 147 - 0
services/report_mapping_category_group.go

@@ -0,0 +1,147 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strings"
+	"time"
+)
+
+//func init() {
+//	var condition string
+//	var pars []interface{}
+//	condition += ` AND publish_status  = 1 `
+//
+//	list, err := models.GetArticleList(condition, pars)
+//	fmt.Println(err)
+//	for _, v := range list {
+//		AddCygxReportMappingCategoryGroupByArticleId(v.ArticleId)
+//	}
+//}
+
+// AddCygxReportMappingCategoryGroupByArticleId  根据文章ID建立分类分组,主客观权限分组
+func AddCygxReportMappingCategoryGroupByArticleId(articleId int) {
+	fmt.Println(articleId)
+	time.Sleep(5 * time.Second)
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("根据文章ID建立分类分组,主客观权限分组,失败"+err.Error(), 2)
+		}
+	}()
+	detail, e := models.GetArticleDetailById(articleId)
+	if e != nil {
+		err = errors.New("GetArticleDetailById, Err: " + e.Error())
+		return
+	}
+	categoryId := detail.CategoryId
+
+	var condition string
+	var pars []interface{}
+	condition += ` AND category_id_celue = ? `
+	pars = append(pars, categoryId)
+	list, e := models.GetCygxReportMappingGroupList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxReportMappingGroupList, Err: " + e.Error())
+		return
+	}
+	pars = make([]interface{}, 0)
+	var idCygxs []int
+	for _, v := range list {
+		idCygxs = append(idCygxs, v.IdCygx)
+		fmt.Println(v)
+	}
+	condition = ` AND id  IN (` + utils.GetOrmInReplace(len(idCygxs)) + `)`
+	pars = append(pars, idCygxs)
+	cygxlist, e := models.GetCygxReportMappingCygxByCon(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxReportMappingCygxByCon, Err: " + e.Error())
+		return
+	}
+	var items []*models.CygxReportMappingCategoryGroup
+	for _, v := range cygxlist {
+		item := new(models.CygxReportMappingCategoryGroup)
+		item.IdCygx = v.Id
+		item.ChartPermissionId = v.ChartPermissionId
+		//如果类型是报告就是主观,类型是纪要就是客观
+		if detail.TypeName == "报告" {
+			item.PermissionType = 1
+		}
+		if detail.TypeName == "纪要" {
+			item.PermissionType = 2
+		}
+		item.ArticleId = articleId
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		items = append(items, item)
+	}
+	e = models.AddCygxReportMappingCategoryGroupMulti(items, articleId)
+	fmt.Println(items)
+	return
+
+}
+
+// 校验文章主客观权限
+func CheckArticlePermissionType(articleId int, user *models.WxUserItem) (checkPermissionType bool) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("记录用户文章浏览记录,失败"+err.Error(), 2)
+		}
+	}()
+	permissionStr, e := models.GetCompanyPermissionByUser(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyPermissionByUser, Err: " + e.Error())
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition += ` AND article_id = ? `
+	pars = append(pars, articleId)
+	list, e := models.GetCygxReportMappingCategoryGroupList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxReportMappingCategoryGroupList, Err: " + e.Error())
+		return
+	}
+	if len(list) == 0 {
+		checkPermissionType = true
+		return
+	}
+	var chartPermissionId int
+	var chartPermissionName string
+	var permissionTypeZg bool
+	var permissionTypeKg bool
+	for _, v := range list {
+		chartPermissionId = v.ChartPermissionId
+		if v.PermissionType == 1 || v.PermissionType == 0 {
+			permissionTypeZg = true
+		}
+		if v.PermissionType == 2 || v.PermissionType == 0 {
+			permissionTypeKg = true
+		}
+	}
+
+	categoryinfo, e := models.GetChartPermissionById(chartPermissionId)
+	if e != nil {
+		err = errors.New("GetChartPermissionById, Err: " + e.Error())
+		return
+	}
+
+	if permissionTypeZg {
+		chartPermissionName = categoryinfo.PermissionName + "(主观)"
+	}
+	if permissionTypeKg {
+		chartPermissionName = categoryinfo.PermissionName + "(客观)"
+	}
+
+	if permissionTypeKg && permissionTypeZg {
+		chartPermissionName = categoryinfo.PermissionName
+	}
+
+	if strings.Contains(permissionStr, chartPermissionName) {
+		checkPermissionType = true
+	}
+	return
+}

+ 151 - 0
services/resource_data.go

@@ -40,6 +40,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 	var minutessummaryIds []int
 	var meetingreviewchaptIds []int
 	var productinteriorIds []int
+	var reportselectionIds []int // 报告精选
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
 	for _, v := range list {
 		if v.Source == "article" {
@@ -64,6 +65,8 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			meetingreviewchaptIds = append(meetingreviewchaptIds, v.SourceId)
 		} else if v.Source == "productinterior" {
 			productinteriorIds = append(productinteriorIds, v.SourceId)
+		} else if v.Source == "reportselection" {
+			reportselectionIds = append(reportselectionIds, v.SourceId)
 		}
 
 	}
@@ -418,8 +421,31 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		}
 	}
 
+	//处理报告精选
+	lenreportselectionIds := len(reportselectionIds)
+	if lenreportselectionIds > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenreportselectionIds) + `)`
+		pars = append(pars, reportselectionIds)
+		listreportselection, e := models.GetReportSelectionList(condition, pars, 0, lenreportselectionIds)
+		if e != nil {
+			err = errors.New("GetReportSelectionList, Err: " + e.Error())
+			return
+		}
+		for _, v := range listreportselection {
+			v.Title += "(第" + v.Periods + "期)"
+			v.MarketStrategy = AnnotationHtml(v.MarketStrategy)
+			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
+			mapItems[fmt.Sprint("reportselection", v.ArticleId)].ReportSelection = v
+		}
+	}
+
 	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.ReportSelection == nil {
+				continue
+			}
 			if v.SourceId == vList.SourceId {
 				items = append(items, v)
 			}
@@ -469,3 +495,128 @@ func Deletenewchart(chartIdsDelete []int) (err error) {
 	err = models.DeleteResourceDataList(condition, pars)
 	return
 }
+
+//func init() {
+//	UpdateArticleResourceData(9050)
+//}
+
+// 更新文章
+func UpdateArticleResourceData(sourceId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg("更新文章 失败,UpdateArticleResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
+		}
+	}()
+	var source = utils.CYGX_OBJ_ARTICLE
+	var condition string
+	var pars []interface{}
+	condition = ` AND publish_status = 1  AND  article_id = ?  `
+	pars = append(pars, sourceId)
+	total, e := models.GetCygxArticleCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxReportSelection, Err: " + err.Error())
+		return
+	}
+	//如果取消发布了就做删除处理
+	if total == 0 {
+		e = models.DeleteResourceData(sourceId, source)
+		if e != nil {
+			err = errors.New("DeleteResourceData, Err: " + e.Error())
+			return
+		}
+		//删除 cygx_resource_data 表关联的产业ID,标的ID
+		e = models.DeleteCygxResourceDataGroup(sourceId, source)
+		if e != nil {
+			err = errors.New("DeleteCygxResourceDataGroup, Err: " + e.Error())
+			return
+		}
+	} else {
+		//判断是否存在,如果不存在就新增,存在就更新
+		totalData, e := models.GetCygxReportSelectionBySourceAndId(sourceId, source)
+		if e != nil {
+			err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
+			return
+		}
+		detail, e := models.GetArticleDetailById(sourceId)
+		if e != nil {
+			err = errors.New("GetCygxReportSelectionInfoById, Err: " + e.Error())
+			return
+		}
+		var resourceDataId int
+		publishDate := time.Now().Format(utils.FormatDateTime)
+		item := new(models.CygxResourceData)
+		if detail.ArticleTypeId > 0 {
+			item.SearchTag = detail.ArticleTypeName // 研选类型名称
+		} else {
+			item.SearchTag = detail.MatchTypeName
+		}
+		item.SourceId = sourceId
+		item.Source = source
+		item.PublishDate = publishDate
+		item.CreateTime = time.Now()
+		if totalData == 0 {
+			newId, e := models.AddCygxResourceData(item)
+			if e != nil {
+				err = errors.New("AddCygxResourceData, Err: " + e.Error())
+				return
+			}
+			resourceDataId = int(newId)
+		} else {
+			e = models.UpdateResourceDataByItem(item)
+			if e != nil {
+				err = errors.New("UpdateResourceData, Err: " + e.Error())
+				return
+			}
+			sourceDetail, e := models.GetCygxResourceDataByIdAndSource(sourceId, source)
+			if e != nil {
+				err = errors.New("UpdateResourceData, Err: " + e.Error())
+				return
+			}
+			resourceDataId = sourceDetail.Id
+		}
+
+		//建立首页资源表,与产业的关系
+		industrialList, e := models.GetIndustrialArticleGroupManagementListByArticleId(sourceId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+		var industrialItems []*models.CygxResourceDataIndustrialGroupManagement
+		for _, v := range industrialList {
+			var industrialItem = new(models.CygxResourceDataIndustrialGroupManagement)
+			industrialItem.SourceId = sourceId
+			industrialItem.Source = source
+			industrialItem.IndustrialManagementId = v.IndustrialManagementId
+			industrialItem.ResourceDataId = resourceDataId
+			industrialItem.CreateTime = time.Now()
+			industrialItems = append(industrialItems, industrialItem)
+		}
+
+		//建立首页资源表,与标的 的关系
+		subjectList, e := models.GetSubjectArticleGroupManagementListByArtcileId(sourceId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+		var subjectItems []*models.CygxResourceDataIndustrialGroupSubject
+		for _, v := range subjectList {
+			var subjectItem = new(models.CygxResourceDataIndustrialGroupSubject)
+			subjectItem.SourceId = sourceId
+			subjectItem.Source = source
+			subjectItem.IndustrialSubjectId = v.IndustrialSubjectId
+			subjectItem.ResourceDataId = resourceDataId
+			subjectItem.CreateTime = time.Now()
+			subjectItems = append(subjectItems, subjectItem)
+		}
+
+		//插入关联信息
+		e = models.AddCygxResourceDataGroup(sourceId, source, industrialItems, subjectItems)
+		if e != nil {
+			err = errors.New("AddCygxResourceDataGroup, Err: " + e.Error())
+			return
+		}
+	}
+	return
+}

+ 144 - 0
services/tag.go

@@ -1,9 +1,11 @@
 package services
 
 import (
+	"errors"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -36,3 +38,145 @@ func AddCygxTagHistory(user *models.WxUserItem, tagId int) (err error) {
 	_, err = models.AddCygxTagHistory(historyRecord)
 	return
 }
+
+//func init() {
+//	conditionInit, err := GetConditionInitByTagIds("20,21,26")
+//	fmt.Println(err)
+//	fmt.Println()
+//	fmt.Println(conditionInit)
+//}
+
+func GetConditionInitByTagIds(tagIds string) (conditionInit string, err error) {
+	if tagIds == "" {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	var searchTag, industries, subjectNames []string
+	tagslice := strings.Split(tagIds, ",")
+	condition = ` AND tag_id IN (` + utils.GetOrmInReplace(len(tagslice)) + `)`
+	pars = append(pars, tagslice)
+	listTag, e := models.GetCygxTagListCondition(condition, pars, 0, 0)
+	if e != nil {
+		err = errors.New("GetActivityListByCondition, Err: " + e.Error())
+		return
+	}
+
+	for _, tagInfo := range listTag {
+		//ActivityTypes 与 ArticleTypes 进行合并
+		if tagInfo.ActivityTypes != "" {
+			sliceObj := strings.Split(tagInfo.ActivityTypes, ",")
+			for _, v := range sliceObj {
+				searchTag = append(searchTag, v)
+			}
+		}
+		if tagInfo.ArticleTypes != "" {
+			sliceObj := strings.Split(tagInfo.ArticleTypes, ",")
+			for _, v := range sliceObj {
+				searchTag = append(searchTag, v)
+			}
+		}
+		if tagInfo.Industries != "" {
+			sliceObj := strings.Split(tagInfo.Industries, ",")
+			for _, v := range sliceObj {
+				industries = append(industries, v)
+			}
+			//industries = append(industries, tagInfo.Industries)
+		}
+		if tagInfo.SubjectNames != "" {
+			sliceObj := strings.Split(tagInfo.SubjectNames, ",")
+			for _, v := range sliceObj {
+				subjectNames = append(subjectNames, v)
+			}
+			//subjectNames = append(subjectNames, tagInfo.SubjectNames)
+		}
+	}
+
+	//拼接search_tag 搜索内容
+	if len(searchTag) > 0 {
+		conditionInit += " AND search_tag IN  ('" + strings.Join(searchTag, "','") + "')"
+	}
+
+	var resourceDataIds []int //cygx_resource_data 主键ID
+	//如果产业有组合,那么就去捞产业相关的内容
+	if len(industries) > 0 {
+		// 获取近一个月产业报告阅读次数最多的产业
+		var conditionIndustry string
+		var parsIndustry []interface{}
+		conditionIndustry += " AND industry_name IN  ('" + strings.Join(industries, "','") + "')"
+		listIndustry, e := models.GetTopOneMonthArtReadNumIndustryAll(conditionIndustry, parsIndustry)
+		if e != nil {
+			err = errors.New("GetTopOneMonthArtReadNumIndustryAll, Err: " + e.Error())
+			return
+		}
+		var industrialManagementIds []int // 产业ID合集
+		for _, v := range listIndustry {
+			industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
+		}
+
+		var conditionIndustryResource string
+		var parsIndustryResource []interface{}
+		lenArrindustrial := len(industrialManagementIds)
+		conditionIndustryResource = ` AND industrial_management_id IN (` + utils.GetOrmInReplace(lenArrindustrial) + `)`
+		parsIndustryResource = append(parsIndustryResource, industrialManagementIds)
+
+		if lenArrindustrial > 0 {
+			listResourceDataIndustrial, e := models.GetCygxResourceDataIndustrialGroupManagementList(conditionIndustryResource, parsIndustryResource, 0, 0)
+			//return
+			if e != nil {
+				err = errors.New("GetCygxResourceDataIndustrialGroupManagementList, Err: " + e.Error())
+				return
+			}
+			for _, v := range listResourceDataIndustrial {
+				resourceDataIds = append(resourceDataIds, v.ResourceDataId)
+			}
+		}
+	}
+	//return
+	//如果标的有组合,那么就去捞标的相关的内容
+	if len(subjectNames) > 0 {
+		// 获取近一个月产业报告阅读次数最多的产业
+		var conditionsubject string
+		var parssubject []interface{}
+		conditionsubject += " AND subject_name IN  ('" + strings.Join(subjectNames, "','") + "')"
+		listsubject, e := models.GetCygxIndustrialSubjectListCondition(conditionsubject, parssubject)
+		if e != nil {
+			err = errors.New("GetTopOneMonthArtReadNumIndustry, Err: " + e.Error())
+			return
+		}
+		var industrialsubjectIds []int // 标的ID集合
+		for _, v := range listsubject {
+			industrialsubjectIds = append(industrialsubjectIds, v.IndustrialSubjectId)
+		}
+		var conditionsubjectResource string
+		var parssubjectResource []interface{}
+		lenArrsubject := len(industrialsubjectIds)
+		conditionsubjectResource = ` AND industrial_subject_id IN (` + utils.GetOrmInReplace(lenArrsubject) + `)`
+		parssubjectResource = append(parssubjectResource, industrialsubjectIds)
+		if lenArrsubject > 0 {
+			listResourceDatasubject, e := models.GetCygxResourceDataIndustrialGroupSubjectList(conditionsubjectResource, parssubjectResource, 0, 0)
+			if e != nil {
+				err = errors.New("GetCygxResourceDataIndustrialGroupSubjectList, Err: " + e.Error())
+				return
+			}
+			for _, v := range listResourceDatasubject {
+				resourceDataIds = append(resourceDataIds, v.ResourceDataId)
+			}
+		}
+	}
+
+	//拼接 cygx_resource_data 表主键查询ID
+	if len(resourceDataIds) > 0 {
+		var resourceDataIdStrs []string
+		resourceDataIdMap := make(map[int]bool)
+		for _, v := range resourceDataIds {
+			if resourceDataIdMap[v] {
+				continue
+			}
+			resourceDataIdStrs = append(resourceDataIdStrs, strconv.Itoa(v))
+			resourceDataIdMap[v] = true
+		}
+		conditionInit += " AND id IN  (" + strings.Join(resourceDataIdStrs, ",") + ") "
+	}
+	return
+}

+ 14 - 0
utils/constants.go

@@ -225,3 +225,17 @@ const (
 	MobileWangFang      = "18621268829" // 王芳手机号
 	MobileWuAngDi       = "18701809782" // 吴昂迪手机号
 )
+
+const (
+	CYGX_OBJ_ARTICLE            string = "article"            // 对象类型:文章
+	CYGX_OBJ_ACTIVITY           string = "activity"           // 对象类型:活动
+	CYGX_OBJ_ACTIVITYVIDEO      string = "activityvideo"      // 对象类型:活动视频
+	CYGX_OBJ_ACTIVITYVOICE      string = "activityvoice"      // 对象类型:活动音频
+	CYGX_OBJ_ACTIVITYSPECIAL    string = "activityspecial"    // 对象类型:专项调研活动
+	CYGX_OBJ_MEETINGREVIEWCHAPT string = "meetingreviewchapt" // 对象类型:晨会精华
+	CYGX_OBJ_ROADSHOW           string = "roadshow"           // 对象类型:路演
+	CYGX_OBJ_REPORTSELECTION    string = "reportselection"    // 对象类型:报告精选(重点公司)
+	CYGX_OBJ_PRODUCTINTERIOR    string = "productinterior"    // 对象类型:产品内测
+	CYGX_OBJ_RESEARCHSUMMARY    string = "researchsummary"    // 对象类型:本周研究汇总
+	CYGX_OBJ_MINUTESSUMMARY     string = "minutessummary"     // 对象类型:本周研究汇总
+)