Переглянути джерело

Merge branch 'cygx_12.6.1' of http://8.136.199.33:3000/cxzhang/hongze_clpt into debug

xingzai 1 рік тому
батько
коміт
895b51a3e2
5 змінених файлів з 160 додано та 83 видалено
  1. 5 4
      controllers/tag.go
  2. 1 4
      models/cygx_tag.go
  3. 4 2
      services/article.go
  4. 145 69
      services/tag.go
  5. 5 4
      utils/constants.go

+ 5 - 4
controllers/tag.go

@@ -56,21 +56,22 @@ func (this *TagController) TagCustomizeList() {
 	}
 	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 v.TagType > 0 {
+			v.CheckList = []string{"A", "B", "C", "D"}
+		}
 	}
 	//var condition string
 	condition = ` AND permission_name IN ('医药','消费','科技','智造','策略') `

+ 1 - 4
models/cygx_tag.go

@@ -46,11 +46,8 @@ type CygxTagList struct {
 	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勾选了哪几列
+	TagType       int      `description:"1:热门活动、2:海外研究、3:路演回放、4:语音问答"`
 }
 
 // 列表

+ 4 - 2
services/article.go

@@ -452,8 +452,10 @@ func AnnotationHtml(bodyText string) (annotation string) {
 		pdText = strings.Replace(pdText, " ", "", -1)
 		if pdText != "" {
 			textLen := strings.Index(docText, pdText)
-			mapDoc[(strings.Index(docText, pdText))] = pdText
-			mapSort = append(mapSort, textLen)
+			if textLen >= 0 {
+				mapDoc[(strings.Index(docText, pdText))] = pdText
+				mapSort = append(mapSort, textLen)
+			}
 		}
 	})
 	li := doc.Find("li")

+ 145 - 69
services/tag.go

@@ -58,10 +58,11 @@ func GetConditionInitByTagIds(tagIds string) (conditionInit string, err error) {
 	pars = append(pars, tagslice)
 	listTag, e := models.GetCygxTagListCondition(condition, pars, 0, 0)
 	if e != nil {
-		err = errors.New("GetActivityListByCondition, Err: " + e.Error())
+		err = errors.New("GetCygxTagListCondition, Err: " + e.Error())
 		return
 	}
 
+	var tagType int // 定义特殊标签的类型,判断传过来的参数是否有固定标签的搜索
 	for _, tagInfo := range listTag {
 		//ActivityTypes 与 ArticleTypes 进行合并
 		if tagInfo.ActivityTypes != "" {
@@ -90,92 +91,167 @@ func GetConditionInitByTagIds(tagIds string) (conditionInit string, err error) {
 			}
 			//subjectNames = append(subjectNames, tagInfo.SubjectNames)
 		}
-	}
 
-	//拼接search_tag 搜索内容
-	if len(searchTag) > 0 {
-		//search_tag_two 兼容报告类型一对多的这种,时间不够,产品也有可能变先这么做
-		conditionInit += " AND ( search_tag IN  ('" + strings.Join(searchTag, "','") + "')  OR search_tag_two IN( '" + strings.Join(searchTag, "','") + "' )  )"
+		if tagType == 0 && tagInfo.TagType > 0 {
+			tagType = tagInfo.TagType
+		}
 	}
 
-	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)
+	switch tagType {
+	case 0: // 无固定标签
+		//拼接search_tag 搜索内容
+		if len(searchTag) > 0 {
+			//search_tag_two 兼容报告类型一对多的这种,时间不够,产品也有可能变先这么做
+			conditionInit += " AND ( search_tag IN  ('" + strings.Join(searchTag, "','") + "')  OR search_tag_two IN( '" + strings.Join(searchTag, "','") + "' )  )"
 		}
 
-		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
+		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("GetCygxResourceDataIndustrialGroupManagementList, Err: " + e.Error())
+				err = errors.New("GetTopOneMonthArtReadNumIndustryAll, Err: " + e.Error())
 				return
 			}
-			for _, v := range listResourceDataIndustrial {
-				resourceDataIds = append(resourceDataIds, v.ResourceDataId)
+			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)
+		//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("GetCygxResourceDataIndustrialGroupSubjectList, Err: " + e.Error())
+				err = errors.New("GetTopOneMonthArtReadNumIndustry, Err: " + e.Error())
 				return
 			}
-			for _, v := range listResourceDatasubject {
-				resourceDataIds = append(resourceDataIds, v.ResourceDataId)
+			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
+		//拼接 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
 			}
-			resourceDataIdStrs = append(resourceDataIdStrs, strconv.Itoa(v))
-			resourceDataIdMap[v] = true
+			conditionInit += " AND id IN  (" + strings.Join(resourceDataIdStrs, ",") + ") "
+		}
+	case 1: // 热门活动
+		conf, e := models.GetConfigByCode(utils.CYGX_TAG_HOT_ACTIVITY_ID)
+		if e != nil {
+			err = errors.New("GetConfigByCode, Err: " + e.Error())
+			return
 		}
-		conditionInit += " AND id IN  (" + strings.Join(resourceDataIdStrs, ",") + ") "
+		//主键ID赋值为0,进行空查询
+		if conf.ConfigValue == "" {
+			conditionInit += " AND id = 0  "
+			return
+		}
+		pars = make([]interface{}, 0)
+		condition = " AND activity_id IN ( " + conf.ConfigValue + ")  AND publish_status = 1   AND active_state  IN (1,2) "
+		listActivity, e := models.GetActivityListByCondition(condition, pars)
+		if e != nil {
+			err = errors.New("GetActivityListByCondition, Err: " + e.Error())
+			return
+		}
+		if len(listActivity) == 0 {
+			conditionInit += " AND id = 0  "
+			return
+		}
+
+		//拼接查询热门活动的SQL、
+		var activityIds []string
+		for _, v := range listActivity {
+			activityIds = append(activityIds, strconv.Itoa(v.ActivityId))
+		}
+		conditionInit = " AND source_id IN ( " + strings.Join(activityIds, ",") + ")  AND source = '" + utils.CYGX_OBJ_ACTIVITY + "'"
+
+	case 2: //海外研究 查询海外研究的文章,以及海外的活动
+		condition = " AND category_id IN ( SELECT category_id_celue FROM cygx_report_mapping_group WHERE id_cygx IN ( 35,39 ) ) AND publish_status = 1"
+		pars = make([]interface{}, 0)
+		articleList, e := models.GetArticleList(condition, pars)
+		if e != nil {
+			err = errors.New("GetArticleList, Err: " + e.Error())
+			return
+		}
+		//文章一定会有值,这里就不做为空判断了 。。。
+		var articleIds []string
+		for _, v := range articleList {
+			articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
+		}
+
+		//海外举办的活动查询
+		condition = " AND  area_type = 2  AND publish_status = 1   "
+		listActivity, e := models.GetActivityListByCondition(condition, pars)
+		if e != nil {
+			err = errors.New("GetActivityListByCondition, Err: " + e.Error())
+			return
+		}
+		//判断是否有海外活动,如果有就拼接,报告与活动的查询SQL
+		if len(listActivity) == 0 {
+			conditionInit = " AND source_id IN ( " + strings.Join(articleIds, ",") + ")  AND source = '" + utils.CYGX_OBJ_ARTICLE + "'"
+		} else {
+			var activityIds []string
+			for _, v := range listActivity {
+				activityIds = append(activityIds, strconv.Itoa(v.ActivityId))
+			}
+			conditionInit = " AND  ( source_id IN ( " + strings.Join(articleIds, ",") + ")  AND source = '" + utils.CYGX_OBJ_ARTICLE + "') OR   (source_id IN ( " + strings.Join(activityIds, ",") + ")  AND source = '" + utils.CYGX_OBJ_ACTIVITY + " ' )"
+		}
+
+	case 3: // 路演回放
+		conditionInit = "  AND source  IN('activityvoice','activityvideo')  AND  search_tag = '路演回放' "
+
+	case 4: // 语音问答
+		conditionInit = "   AND source = '" + utils.CYGX_OBJ_ASKSERIEVIDEO + "'"
 	}
+
 	return
 }

+ 5 - 4
utils/constants.go

@@ -213,10 +213,11 @@ const (
 )
 
 const (
-	TPL_MSG_WANG_YANG           = "tpl_msg_wang_yang"           //汪洋手机号地址参数
-	TPL_MSG_WANG_FANG_WANG_YANG = "tpl_msg_wang_fang_wang_yang" //权限模板消息接收人,王芳,汪洋
-	TPL_MSG                     = "tpl_msg"                     //王芳手机号地址参数
-	TPL_MSG_NEI_RONG_ZU         = "tpl_msg_nei_rong_zu"         //内容组四人
+	TPL_MSG_WANG_YANG                  = "tpl_msg_wang_yang"           //汪洋手机号地址参数
+	TPL_MSG_WANG_FANG_WANG_YANG        = "tpl_msg_wang_fang_wang_yang" //权限模板消息接收人,王芳,汪洋
+	TPL_MSG                            = "tpl_msg"                     //王芳手机号地址参数
+	TPL_MSG_NEI_RONG_ZU                = "tpl_msg_nei_rong_zu"         //内容组四人
+	CYGX_TAG_HOT_ACTIVITY_ID    string = "cygx_tag_hot_activity_id"    //标签管理自定义的热门活动ID
 )
 const (
 	MobileShenTao       = "18767183922" //沈涛手机号