瀏覽代碼

Merge branch 'cygx_11.1.1' of http://8.136.199.33:3000/cxzhang/hongze_clpt

xingzai 1 年之前
父節點
當前提交
8a531bc4cd

+ 32 - 28
controllers/article.go

@@ -153,7 +153,7 @@ func (this *ArticleController) Detail() {
 		} else {
 			hasPermission = 1
 			hasFree = 1
-			var articlePermissionPermissionName string
+			var articlePermissionName string
 			if detail.CategoryId > 0 {
 				articlePermission, err := models.GetArticlePermission(detail.CategoryId)
 				if err != nil {
@@ -166,12 +166,12 @@ 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
@@ -186,30 +186,34 @@ 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 {
 				if applyCount == 0 {

+ 251 - 235
controllers/home.go

@@ -282,212 +282,224 @@ func (this *MobileHomeController) NewList() {
 	var conditionInit string
 	var pars []interface{}
 	var total int
+	var err error
 	resp := new(models.HomeResourceDataListNewResp)
 
-	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
-	}
-
-	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
-		}
-	}
-
-	//查询近一个月的数据
-	conditionInit = " AND publish_date  >   '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"
+	//return
 	//conditionInit += `  AND source IN ('newchart')`
 	if user.CompanyId <= 1 {
 		condition += " AND source IN ('roadshow','article') "
@@ -536,56 +548,57 @@ func (this *MobileHomeController) 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 lenActivityIds > 0 && tagIds == "" {
+		//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)
 		}
 	}
-
+	//return
 	total, err = models.GetResourceDataCount(condition, pars)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据总数失败,Err:" + err.Error()
 		return
 	}
-
+	//return
 	if user.CompanyId <= 1 {
 		total = utils.PageSize5
 	}
@@ -598,6 +611,9 @@ func (this *MobileHomeController) NewList() {
 		br.ErrMsg = "获取数据列表失败,Err:" + err.Error()
 		return
 	}
+	if len(list) == 0 {
+		list = make([]*models.CygxResourceDataNewResp, 0)
+	}
 	page = paging.GetPaging(currentIndex, pageSize, total)
 	resp.Paging = page
 	resp.List = list

+ 0 - 56
controllers/report.go

@@ -541,52 +541,6 @@ func (this *MobileReportController) List() {
 			imgUrlChart = vslice[len(vslice)-1]
 			mapCategoryUrl[categoryIdStr] = imgUrlChart
 		}
-		//if detail.CeLueFieldId != "" {
-		//	condition = ` AND ce_lue_field_id IN(` + detail.CeLueFieldId + `)`
-		//} else if detail.PolymerizationId != "" {
-		//	condition = ` AND category_id IN(` + detail.PolymerizationId + `)`
-		//} else {
-		//	categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(categoryId)
-		//	if errCategory != nil {
-		//		br.Msg = "获取信息失败"
-		//		br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
-		//		return
-		//	}
-		//	if categoryIdSet != "" {
-		//		condition = ` AND category_id IN(` + categoryIdSet + `)`
-		//	} else {
-		//		condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
-		//	}
-		//}
-		//
-		//if industrialManagementId > 0 {
-		//	industrialManageentList, err := models.GetIndustrialArticleGroupManagementByIndustrialManagementId(industrialManagementId)
-		//	if err != nil {
-		//		br.Msg = "获取信息失败"
-		//		br.Msg = "获取产业关联的文章ID失败,GetIndustrialArticleGroupManagementByIndustrialManagementIdErr:" + err.Error()
-		//		return
-		//	}
-		//	articleIdList := make([]string, 0)
-		//	for _, v := range industrialManageentList {
-		//		articleIdList = append(articleIdList, strconv.Itoa(v.ArticleId))
-		//	}
-		//	condition += ` AND a.article_id IN (  ` + utils.GetOrmInReplace(len(articleIdList)) + ` )  `
-		//	pars = append(pars, articleIdList)
-		//}
-
-		//total, err = models.GetHomeCount(condition, pars)
-		//if err != nil {
-		//	br.Msg = "获取信息失败"
-		//	br.Msg = "获取帖子总数失败,Err:" + err.Error()
-		//	return
-		//}
-		//
-		//list, err = models.GetHomeListNew(condition, pars, startSize, pageSize)
-		//if err != nil {
-		//	br.Msg = "获取信息失败"
-		//	br.Msg = "获取帖子数据失败,Err:" + err.Error()
-		//	return
-		//}
 
 		list, total, err = models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
 		if err != nil {
@@ -607,16 +561,6 @@ func (this *MobileReportController) List() {
 				list[k].IsRed = true
 			}
 		}
-		//if categoryId > 0 {
-		//	detail, errCategory := models.GetdetailByCategoryId(categoryId)
-		//	if errCategory != nil {
-		//		br.Msg = "获取信息失败"
-		//		br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
-		//		return
-		//	}
-		//	resp.MatchTypeName = detail.MatchTypeName
-		//}
-		//resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
 	}
 
 	listPublic, err := services.HandleArticleCategoryImg(list, user)

+ 19 - 2
controllers/tag.go

@@ -10,7 +10,6 @@ type TagController struct {
 	BaseAuthController
 }
 
-
 // @Title 获取标签列表-自定义顺序
 // @Description 获取标签列表-自定义顺序接口
 // @Success 200 {object} cygx.ChartPermissionResp
@@ -55,6 +54,24 @@ func (this *TagController) TagCustomizeList() {
 		br.ErrMsg = "获取标签信息失败,Err:" + err.Error()
 		return
 	}
+	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")
+		}
+	}
 	resp.List = list
 	br.Ret = 200
 	br.Success = true
@@ -97,4 +114,4 @@ func (this *TagController) History() {
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "记录成功"
-}
+}

+ 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) {

+ 1 - 47
models/industrial_activity_group_management.go

@@ -21,52 +21,6 @@ type CygxIndustrialActivityGroupSubject struct {
 	CreateTime          time.Time `description:"创建时间"`
 }
 
-type CygxIndustrialSubject struct {
-	IndustrialSubjectId    int       `orm:"column(industrial_subject_id);pk" description:"标的id"`
-	IndustrialManagementId int       `description:"产业id"`
-	SubjectName            string    `description:"标的名称"`
-	CreateTime             time.Time `description:"创建时间"`
-	Source                 int       `description:"来源,1正常添加,2:通过文章添加,3通过活动添加(默认为1)"`
-}
-
-//获取标的列表
-func GetCygxIndustrialSubjectList(subjectName string) (items []*CygxIndustrialSubject, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-				s.*
-			FROM
-				cygx_industrial_subject as s 
-				INNER JOIN  cygx_industrial_management as m ON  m.industrial_management_id = s.industrial_management_id
-			WHERE
-				subject_name = ? `
-	_, err = o.Raw(sql, subjectName).QueryRows(&items)
-	return
-}
-
-// AddCygxActiuvityGroupMulti 批量添加
-func AddCygxActiuvityGroupMulti(items []*CygxIndustrialActivityGroupManagement, itemsSubject []*CygxIndustrialActivityGroupSubject) (err error) {
-	o, err := orm.NewOrm().Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err == nil {
-			o.Commit()
-		} else {
-			o.Rollback()
-		}
-	}()
-	if len(items) > 0 {
-		//批量添加关联的产业
-		_, err = o.InsertMulti(len(items), items)
-	}
-	if len(itemsSubject) > 0 {
-		//批量添加关联的标的
-		_, err = o.InsertMulti(len(itemsSubject), itemsSubject)
-	}
-	return
-}
-
 // GetActivityIndustryRelationList 获取活动与产业关联列表
 func GetActivityIndustryRelationList(condition string, pars []interface{}) (list []*CygxIndustrialActivityGroupManagement, err error) {
 	sql := `SELECT
@@ -84,7 +38,7 @@ func GetActivityIndustryRelationList(condition string, pars []interface{}) (list
 	return
 }
 
-//列表
+// 列表
 func GetIndustrialActivityGroupManagementList(activityId int) (items []*IndustrialManagementRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT

+ 19 - 0
models/industrial_subject.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"time"
 )
 
 type IndustrialSubjectByArticle struct {
@@ -17,6 +18,14 @@ type SubjectArticlGroupList struct {
 	IndustrialSubjectId int    `description:"cygx_industrial_subject表的文章ID"`
 }
 
+type CygxIndustrialSubject struct {
+	IndustrialSubjectId    int       `orm:"column(industrial_subject_id);pk" description:"标的id"`
+	IndustrialManagementId int       `description:"产业id"`
+	SubjectName            string    `description:"标的名称"`
+	CreateTime             time.Time `description:"创建时间"`
+	Source                 int       `description:"来源,1正常添加,2:通过文章添加,3通过活动添加(默认为1)"`
+}
+
 // 获取标的列表
 func GetArticleGroupSubjectList(pars []interface{}, condition string) (items []*IndustrialSubjectByArticle, err error) {
 	o := orm.NewOrm()
@@ -55,3 +64,13 @@ func GetcygxIndustrialSubject(industrialManagementId int) (items []*IndustrialSu
 	_, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
 	return
 }
+
+// GetCygxIndustrialSubjectList 获取标的列表
+func GetCygxIndustrialSubjectListCondition(condition string, pars []interface{}) (items []*CygxIndustrialSubject, err error) {
+	sql := `SELECT * FROM cygx_industrial_subject WHERE 1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 4 - 4
models/report.go

@@ -169,7 +169,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,
@@ -351,7 +351,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
@@ -703,10 +703,10 @@ FROM
 		cam.industrial_management_id = ? AND cam.source = 1 
 	) AS t`
 	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
-	err = o.Raw(totalSql, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId,industrialManagementId).QueryRow(&total)
+	err = o.Raw(totalSql, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId).QueryRow(&total)
 	sql += ` ORDER BY 
 	t.publish_date DESC LIMIT ?,? `
-	_, err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId,industrialManagementId, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 27 - 0
models/report_mapping_category_group.go

@@ -0,0 +1,27 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+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不限制"`
+}
+
+// 列表
+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
+}

+ 14 - 0
models/report_selection.go

@@ -15,6 +15,8 @@ type CygxReportSelectionRep struct {
 	UpdateDescription string `description:"更新说明"`
 	IsRed             bool   `description:"是否标记红点"`
 	ReadNum           int    `description:"阅读次数"`
+	Periods           string `description:"期数"`
+	MarketStrategy    string `description:"市场策略核心逻辑汇总"`
 }
 
 type CygxReportSelectionListPublicRep struct {
@@ -181,3 +183,15 @@ type AddReportSelectionStopTimeRep struct {
 	OutType   int `description:"退出方式,1正常退出,2强制关闭"`
 	Source    int `description:"来源,1:深度研究、2:本周研究汇总、3:上周纪要汇总"`
 }
+
+// 列表
+func GetReportSelectionList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_selection  as art WHERE 1= 1 AND art.publish_status = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `   LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 1 - 0
models/resource_data.go

@@ -104,6 +104,7 @@ type CygxResourceDataNewResp struct {
 	Meetingreviewchapt *CygxMorningMeetingGatherDetailListResp `description:"晨会精华"`
 	ProductInterior    *CygxProductInteriorResp                `description:"产品内测"`
 	IndustrialResource *IndustrialManagement                   `description:"产业资源包"`
+	ReportSelection    *CygxReportSelectionRep                 `description:"重点公司(原报告精选)"`
 }
 
 // 列表

+ 60 - 0
models/resource_data_industrial_group_management.go

@@ -0,0 +1,60 @@
+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
+}

+ 11 - 1
services/article.go

@@ -279,7 +279,17 @@ func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
 
 // GetSpecialArticleDetailUserPower 处理用户查看专项调研文章详情的权限
 func GetSpecialArticleDetailUserPower(user *models.WxUserItem, articleInfo *models.ArticleDetail) (havePower bool, err error) {
-	permissionStr, e := GetCompanyPermission(user.CompanyId)
+	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())
 		return

+ 72 - 0
services/report_mapping_category_group.go

@@ -0,0 +1,72 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"strings"
+)
+
+// 校验文章主客观权限
+func CheckArticlePermissionType(articleId int, user *models.WxUserItem) (checkPermissionType bool) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("校验文章主客观权限,失败"+err.Error()+fmt.Sprint("uid:", user.UserId, "articleId", articleId), 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
+}

+ 26 - 91
services/resource_data.go

@@ -43,6 +43,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  、 产品内测:productinterior
 	for _, v := range list {
 		if v.Source == "article" {
@@ -67,6 +68,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)
 		}
 	}
 	detail, e := models.GetConfigByCode("city_img_url")
@@ -297,97 +300,6 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		}
 	}
 
-	////处理路演
-	//if len(roadshowIds) > 0 {
-	//	pars = make([]interface{}, 0)
-	//	condition = ` AND video_id IN (` + utils.GetOrmInReplace(len(roadshowIds)) + `)`
-	//	pars = append(pars, roadshowIds)
-	//	roadshowVideoList, e := models.GetMicroRoadshowVideoListBycondition(condition, pars, 0, len(roadshowIds))
-	//	if e != nil {
-	//		err = errors.New("GetResourceDataList, Err: " + e.Error())
-	//		return
-	//	}
-	//	for _, v := range roadshowVideoList {
-	//		mapItems[fmt.Sprint("roadshow", v.VideoId)].Title = v.VideoName
-	//		mapItems[fmt.Sprint("roadshow", v.VideoId)].ImgUrl = v.ImgUrl
-	//		mapItems[fmt.Sprint("roadshow", v.VideoId)].PublishDate = v.CreateTime.Format(utils.FormatDateTime)
-	//	}
-	//}
-	////处理路活动视频
-	//if len(activityvideoIds) > 0 {
-	//	pars = make([]interface{}, 0)
-	//	condition = ` AND video_id IN (` + utils.GetOrmInReplace(len(activityvideoIds)) + `)`
-	//	pars = append(pars, activityvideoIds)
-	//	activityVideoList, e := models.GetActivityVideoList(condition, pars, 0, len(activityvideoIds))
-	//	if e != nil {
-	//		err = errors.New("GetResourceDataList, Err: " + e.Error())
-	//		return
-	//	}
-	//	//// 获取默认图配置
-	//	_, videoMap, _, _, e := GetMicroRoadShowDefaultImgConfig()
-	//	if e != nil {
-	//		err = errors.New("GetMicroRoadShowDefaultImgConfig, Err: " + e.Error())
-	//		return
-	//	}
-	//	for _, v := range activityVideoList {
-	//		mapItems[fmt.Sprint("activityvideo", v.VideoId)].Title = v.VideoName
-	//		mapItems[fmt.Sprint("activityvideo", v.VideoId)].ImgUrl = videoMap[v.ChartPermissionId]
-	//		mapItems[fmt.Sprint("activityvideo", v.VideoId)].ChartPermissionId = v.ChartPermissionId
-	//	}
-	//}
-	////处理路活音频
-	//if len(activityvoiceIds) > 0 {
-	//	pars = make([]interface{}, 0)
-	//	condition = ` AND activity_voice_id IN (` + utils.GetOrmInReplace(len(activityvoiceIds)) + `)`
-	//	pars = append(pars, activityvoiceIds)
-	//	activityVoiceList, e := models.GetActivityVoiceList(condition, pars, 0, len(activityvoiceIds))
-	//	if e != nil {
-	//		err = errors.New("GetResourceDataList, Err: " + e.Error())
-	//		return
-	//	}
-	//
-	//	// 用户权限
-	//	authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
-	//	if e != nil {
-	//		err = errors.New("GetUserRaiPermissionInfo, Err: " + e.Error())
-	//		return
-	//	}
-	//
-	//	// 获取默认图配置
-	//	audioMap, _, _, _, e := GetMicroRoadShowDefaultImgConfig()
-	//	if e != nil {
-	//		err = errors.New("GetMicroRoadShowDefaultImgConfig, Err: " + e.Error())
-	//		return
-	//	}
-	//	for i, v := range activityVoiceList {
-	//		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 activityVoiceList[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, activityVoiceList[i].ChartPermissionName) {
-	//				au.HasPermission = 2
-	//			}
-	//		}
-	//		// 无权限的弹框提示
-	//		if au.HasPermission != 1 {
-	//			if au.OperationMode == UserPermissionOperationModeCall {
-	//				au.PopupMsg = UserPermissionPopupMsgCallActivity
-	//			} else {
-	//				au.PopupMsg = UserPermissionPopupMsgApplyActivity
-	//			}
-	//		}
-	//		mapItems[fmt.Sprint("activityvoice", v.ActivityVoiceId)].AuthInfo = au
-	//		mapItems[fmt.Sprint("activityvoice", v.ActivityVoiceId)].Title = v.VoiceName
-	//		mapItems[fmt.Sprint("activityvoice", v.ActivityVoiceId)].ImgUrl = audioMap[v.ChartPermissionId]
-	//		if au.HasPermission == 1 {
-	//			mapItems[fmt.Sprint("activityvoice", v.ActivityVoiceId)].ResourceUrl = v.VoiceUrl
-	//		}
-	//	}
-	//}
-
 	//处理路演 处理路活动视频 处理路活音频
 	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds) > 0 {
 
@@ -508,8 +420,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)
 			}

+ 142 - 0
services/tag.go

@@ -1,9 +1,11 @@
 package services
 
 import (
+	"errors"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -36,3 +38,143 @@ func AddCygxTagHistory(user *models.WxUserItem, tagId int) (err error) {
 	_, err = models.AddCygxTagHistory(historyRecord)
 	return
 }
+
+//func init() {
+//	conditionInit, err := GetConditionInitByTagIds("43")
+//	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
+}