Ver código fonte

查研观向8.0

xingzai 2 anos atrás
pai
commit
7940d31374

+ 1 - 1
controllers/activity.go

@@ -949,7 +949,7 @@ func (this *ActivityCoAntroller) Detail() {
 				var condition string
 				var condition string
 				condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
 				condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
 				condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
 				condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
-				listIndustrialGrop, err := models.GetSearchResourceList(condition)
+				listIndustrialGrop, err := models.GetSearchResourceList(condition, 0, 0)
 				if err != nil && err.Error() != utils.ErrNoRow() {
 				if err != nil && err.Error() != utils.ErrNoRow() {
 					br.Msg = "获取信息失败"
 					br.Msg = "获取信息失败"
 					br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
 					br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)

+ 186 - 6
controllers/report.go

@@ -357,7 +357,7 @@ func (this *ReportController) ArticleCategoryList() {
 		br.ErrMsg = "获取信息失败,Err:" + err.Error()
 		br.ErrMsg = "获取信息失败,Err:" + err.Error()
 		return
 		return
 	}
 	}
-	list, err := models.IndustrialToArticleCategory(industrialManagementId, detail.ChartPermissionId)
+	list, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
 	if err != nil {
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -1210,11 +1210,17 @@ func (this *ReportController) IsShow() {
 		return
 		return
 	}
 	}
 	var resp models.IsShow
 	var resp models.IsShow
-
+	IsShowFreeButton, err := services.GetfreeButtonIsShow(user)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,GetfreeButtonIsShow Err:" + err.Error()
+		return
+	}
 	resp.IsShowChart = true
 	resp.IsShowChart = true
 	resp.IsShowResearch = true
 	resp.IsShowResearch = true
 	resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
 	resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
 	resp.YanXuan_Explain = true
 	resp.YanXuan_Explain = true
+	resp.IsShowFreeButton = IsShowFreeButton
 	mobile := user.Mobile
 	mobile := user.Mobile
 	if mobile == "" {
 	if mobile == "" {
 		br.Ret = 200
 		br.Ret = 200
@@ -1226,6 +1232,11 @@ func (this *ReportController) IsShow() {
 	if total > 0 {
 	if total > 0 {
 		resp.IsShowList = true
 		resp.IsShowList = true
 	}
 	}
+	resp.SearchTxtList.SummarySearch = "全局搜索"
+	resp.SearchTxtList.ReportSearch = "全局搜索"
+	resp.SearchTxtList.YanXuanSearch = "全局搜索"
+	resp.SearchTxtList.ActivitySearch = "全局搜索"
+	resp.SearchTxtList.TabSearch = "请输入关键词"
 	resp.IsShow = true
 	resp.IsShow = true
 	br.Ret = 200
 	br.Ret = 200
 	br.Success = true
 	br.Success = true
@@ -2339,8 +2350,6 @@ func (this *ReportController) SearchReport() {
 	condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
 	condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
 	sqlGroup = ` GROUP BY  a.article_id  ORDER BY a.publish_date DESC  `
 	sqlGroup = ` GROUP BY  a.article_id  ORDER BY a.publish_date DESC  `
 	//对应产业名称、标的名称。
 	//对应产业名称、标的名称。
-	//OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_subject WHERE industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_subject WHERE subject_name LIKE '%` + keyWord + `%' ) )
-	//OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE industry_name LIKE '%` + keyWord + `%' ) )
 	listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
 	listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
 	if err != nil {
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.Msg = "获取信息失败"
@@ -2426,7 +2435,7 @@ func (this *ReportController) SearchResource() {
 	conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
 	conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
 	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
 	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
 
 
-	listHz, err := models.GetSearchResourceList(condition)
+	listHz, err := models.GetSearchResourceList(condition, 0, 0)
 	if err != nil {
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -2436,7 +2445,7 @@ func (this *ReportController) SearchResource() {
 	conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
 	conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
 	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
 	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
 
 
-	listYx, err := models.GetSearchResourceList(condition)
+	listYx, err := models.GetSearchResourceList(condition, 0, 0)
 	if err != nil {
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
 		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
@@ -2516,3 +2525,174 @@ func (this *ReportController) SearchResource() {
 	br.Msg = "获取成功"
 	br.Msg = "获取成功"
 	br.Data = resp
 	br.Data = resp
 }
 }
+
+// @Title 报告搜索、资源包搜索接口
+// @Description 报告搜索、资源包搜索接口接口
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Success 200 {object} models.SearchReportAndResourceResp
+// @router /searchReportAndResource [get]
+func (this *ReportController) SearchReportAndResource() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	keyWord := this.GetString("KeyWord")
+	pageSize, _ := this.GetInt("PageSize")
+	var condition string
+	var sqlGroup string
+	//匹配报告标题、
+	condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
+	sqlGroup = ` GROUP BY  a.article_id  ORDER BY a.publish_date DESC  `
+	if pageSize > 0 {
+		sqlGroup += ` LIMIT 5 `
+	}
+	ListYxReport, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range ListYxReport {
+		ListYxReport[k].Source = 2
+		if v.MyCollectNum > 0 {
+			ListYxReport[k].IsCollect = true
+		}
+	}
+	ListHzReport, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range ListHzReport {
+		ListHzReport[k].Source = 1
+		if v.MyCollectNum > 0 {
+			ListHzReport[k].IsCollect = true
+		}
+	}
+
+	if len(ListYxReport) == 0 {
+		ListYxReport = make([]*models.ArticleCollectionResp, 0)
+	}
+	if len(ListHzReport) == 0 {
+		ListHzReport = make([]*models.ArticleCollectionResp, 0)
+	}
+
+	fllowList, err := models.GetUserFllowIndustrialList(uid)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
+		return
+	}
+	fllowMap := make(map[int]int)
+	if len(fllowList) > 0 {
+		for _, v := range fllowList {
+			fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
+		}
+	}
+
+	var conditionOr string
+	conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
+	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
+
+	listHzResource, err := models.GetSearchResourceList(condition, 0, pageSize)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+
+	conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
+	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
+
+	listYxResource, err := models.GetSearchResourceList(condition, 0, pageSize)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
+		return
+	}
+	//合并产业关联的标的
+	listSubjcet, err := models.GetThemeHeatSubjectList("")
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
+		return
+	}
+	industrialIdArr := make([]int, 0)
+	for k, v := range listHzResource {
+		listHzResource[k].Source = 1
+		if fllowMap[v.IndustrialManagementId] > 0 {
+			listHzResource[k].IsFollw = true
+		}
+		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
+	}
+
+	for k, v := range listYxResource {
+		listYxResource[k].Source = 2
+		if fllowMap[v.IndustrialManagementId] > 0 {
+			listYxResource[k].IsFollw = true
+		}
+		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
+	}
+
+	if len(industrialIdArr) > 0 {
+		//合并产业关联的标的
+		listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
+			return
+		}
+		mapIndustrial := make(map[string]int)
+		for _, v := range listSubjcet {
+			for k2, v2 := range listYxResource {
+				if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
+					listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
+					mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
+				}
+			}
+			for k2, v2 := range listHzResource {
+				if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
+					listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
+					mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
+				}
+			}
+		}
+	}
+
+	resp := new(models.SearchReportAndResourceResp)
+	if len(listYxResource) == 0 {
+		listYxResource = make([]*models.IndustrialManagementHotResp, 0)
+	}
+	if len(listHzResource) == 0 {
+		listHzResource = make([]*models.IndustrialManagementHotResp, 0)
+	}
+
+	if keyWord != "" {
+		keyWordItem := new(models.CygxUserSearchKeyWord)
+		keyWordItem.UserId = user.UserId
+		keyWordItem.KeyWord = keyWord
+		keyWordItem.PageType = "ReortSearch"
+		keyWordItem.CreateTime = time.Now()
+		go models.AddUserSearchKeyWord(keyWordItem)
+		go services.AddUserSearchLog(user, keyWord, 5)
+	}
+
+	resp.ListHzResource = listHzResource
+	resp.ListYxResource = listYxResource
+	resp.ListYxReport = ListYxReport
+	resp.ListHzReport = ListHzReport
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 171 - 0
controllers/search.go

@@ -471,6 +471,177 @@ func (this *SearchController) ListHomeArtAndChart() {
 	if listType == 1 {
 	if listType == 1 {
 		total = total + int64(chartTotal)
 		total = total + int64(chartTotal)
 	}
 	}
+	if len(result) == 0 {
+		result = make([]*models.SearchItem, 0)
+	}
+	page := paging.GetPaging(currentIndex, pageSize, int(total))
+	resp.Paging = page
+	resp.List = result
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 搜索接口
+// @Description 搜索接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Param   OrderColumn   query   int  true       "排序字段 ,Comprehensive综合 ,Matching匹配度 ,PublishDate 发布时间 "
+// @Success 200 {object} models.SearchItem
+// @router /artAndChart/listPage [get]
+func (this *SearchController) ListHomeArtAndChartPage() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	// @Param   ListType   query   int  true       "列表类型,1最新/全部,2 纪要 ,3图表 默认1"
+	listType, _ := this.GetInt("ListType")
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	listType = 1
+	startSize = paging.StartIndex(currentIndex, pageSize)
+	keyWord := this.GetString("KeyWord")
+	orderColumn := this.GetString("OrderColumn")
+	if keyWord == "" {
+		br.Msg = "请输入搜索词"
+		br.ErrMsg = "请输入搜索词"
+		return
+	}
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+
+	//研选的五张图片
+	detailResearch, errConfig := models.GetConfigByCode("category_research_img_url")
+	if errConfig != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据研选分类图片失败,Err:" + errConfig.Error()
+		return
+	}
+	researchList := strings.Split(detailResearch.ConfigValue, "{|}")
+	//对应分类的所图片
+	detailCategoryUrl, errConfig := models.GetConfigByCode("category_map_img_url")
+	if errConfig != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "行业配置信息失败,Err:" + errConfig.Error()
+		return
+	}
+	categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
+	mapCategoryUrl := make(map[string]string)
+	var categoryId string
+	var imgUrlChart string
+	for _, v := range categoryUrlList {
+		vslice := strings.Split(v, "_")
+		categoryId = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapCategoryUrl[categoryId] = imgUrlChart
+	}
+	if orderColumn == "" {
+		orderColumn = "Matching"
+	}
+	var chartTotal int
+	resp := new(models.SearchResp)
+	var chartList []*models.HomeChartListResp
+	var err error
+	var condition string
+	var pars []interface{}
+	if listType == 1 || listType == 3 {
+		if currentIndex <= 2 {
+			condition = ` AND title LIKE '%` + keyWord + `%'`
+			chartList, err = models.GetChartList(condition, pars, startSize, pageSize)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+				return
+			}
+			chartTotal, err = models.GetChartCount(condition, pars)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.Msg = "获取帖子总数失败,Err:" + err.Error()
+				return
+			}
+		}
+	}
+	for k, v := range chartList {
+		chartList[k].IsNeedJump = true
+		chartList[k].Source = 2
+		if v.PtagName != "" {
+			chartList[k].CtagNamePc = v.PtagName
+		}
+		if v.CtagName != "" {
+			chartList[k].CtagNamePc += "," + v.CtagName
+		}
+		if v.PtagNameTwo != "" {
+			chartList[k].CtagNamePc += "," + v.PtagNameTwo
+		}
+		if v.CtagNameTwo != "" {
+			chartList[k].CtagNamePc += "," + v.CtagNameTwo
+		}
+	}
+	if len(chartList) == 0 {
+		chartList = make([]*models.HomeChartListResp, 0)
+	}
+	resp.ChartList = chartList
+	var result []*models.SearchItem
+	var total int64
+	if listType == 1 || listType == 2 {
+		tmpResult, tmpTotal, tmpErr := services.EsArticleSearch(keyWord, startSize, pageSize, orderColumn)
+		result = tmpResult
+		total = tmpTotal
+		err = tmpErr
+		if err != nil {
+			br.Msg = "检索失败"
+			br.ErrMsg = "检索失败,Err:" + err.Error()
+			return
+		}
+		if len(result) == 0 {
+			result = make([]*models.SearchItem, 0)
+		}
+
+		for k, v := range result {
+			//如果是研选系列的任意取五张图片的中的一张
+			if v.CategoryId == "0" {
+				knum := v.ArticleId % 5
+				result[k].ImgUrlPc = researchList[knum]
+			} else {
+				result[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+			}
+			result[k].Source = 1
+		}
+	}
+	//记录用户搜索关键词
+	var source int
+	if listType == 1 {
+		source = 3
+	} else if listType == 2 {
+		source = 1
+	} else {
+		source = 2
+	}
+	go services.AddSearchKeyWord(user, keyWord, source)
+
+	if chartTotal > int(total) {
+		total = int64(chartTotal)
+	}
+	if listType == 1 {
+		total = total + int64(chartTotal)
+	}
+	if len(result) == 0 {
+		result = make([]*models.SearchItem, 0)
+	}
 	page := paging.GetPaging(currentIndex, pageSize, int(total))
 	page := paging.GetPaging(currentIndex, pageSize, int(total))
 	resp.Paging = page
 	resp.Paging = page
 	resp.List = result
 	resp.List = result

+ 3 - 2
models/article.go

@@ -263,8 +263,9 @@ func GetArticleAll() (item []*ArticleDetail, err error) {
 }
 }
 func GetArticleAllDate(endDate string) (item []*ArticleDetail, err error) {
 func GetArticleAllDate(endDate string) (item []*ArticleDetail, err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_article WHERE is_summary=1 AND publish_date >= ?  `
-	_, err = o.Raw(sql, endDate).QueryRows(&item)
+	sql := `SELECT * FROM cygx_article WHERE is_summary=1 AND publish_date >= ? AND  article_id = 7297  `
+	sql = `SELECT * FROM cygx_article WHERE article_id = ?  `
+	_, err = o.Raw(sql, 7297).QueryRows(&item)
 	return
 	return
 }
 }
 
 

+ 46 - 7
models/report.go

@@ -109,6 +109,23 @@ func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int)
 	return
 	return
 }
 }
 
 
+//产业下所关联的文章分类列表 2022-10-13
+func IndustrialToArticleCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT map.match_type_name,map.category_id
+    FROM cygx_report_mapping AS map
+	INNER JOIN cygx_article AS art ON art.category_id = map.category_id
+	INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
+	WHERE map.report_type = 2
+	AND map.is_report = 1
+    AND art.is_report = 1
+    AND art.publish_status = 1
+	AND man_g.industrial_management_id =?
+	GROUP BY map.match_type_name`
+	_, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
+	return
+}
+
 //判断用户是否阅读该产业下,某一分类的文章
 //判断用户是否阅读该产业下,某一分类的文章
 func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
 func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()
@@ -208,12 +225,22 @@ func GetWhichDepartmentCount(condition string) (count int, err error) {
 }
 }
 
 
 type IsShow struct {
 type IsShow struct {
-	IsShow          bool   `description:"绝密内参按钮是否展示"`
-	IsShowResearch  bool   `description:"研选是否展示限免"`
-	IsShowChart     bool   `description:"图表是否展示限免"`
-	IsShowList      bool   `description:"榜单是否展示"`
-	LinkWxExplain   string `description:"关注微信公众号链接说明地址"`
-	YanXuan_Explain bool   `description:"研选说明"`
+	IsShow           bool      `description:"绝密内参按钮是否展示"`
+	IsShowFreeButton bool      `description:"免费送月卡按钮是否展示"`
+	IsShowResearch   bool      `description:"研选是否展示限免"`
+	IsShowChart      bool      `description:"图表是否展示限免"`
+	IsShowList       bool      `description:"榜单是否展示"`
+	LinkWxExplain    string    `description:"关注微信公众号链接说明地址"`
+	YanXuan_Explain  bool      `description:"研选说明"`
+	SearchTxtList    SearchTxt `description:"搜索栏回显内容说明"`
+}
+
+type SearchTxt struct {
+	SummarySearch  string `description:"素材库搜索说明"`
+	ReportSearch   string `description:"报告搜索说明"`
+	YanXuanSearch  string `description:"研选搜索说明"`
+	ActivitySearch string `description:"活动搜索说明"`
+	TabSearch      string `description:"素材库搜索说明"`
 }
 }
 
 
 //获取用户是否有查看权限
 //获取用户是否有查看权限
@@ -664,8 +691,16 @@ type SearchResourceResp struct {
 	ListYx []*IndustrialManagementHotResp `description:"研选"`
 	ListYx []*IndustrialManagementHotResp `description:"研选"`
 }
 }
 
 
+//搜索资源包 start
+type SearchReportAndResourceResp struct {
+	ListHzResource []*IndustrialManagementHotResp `description:"弘则资源包"`
+	ListYxResource []*IndustrialManagementHotResp `description:"研选资源包"`
+	ListYxReport   []*ArticleCollectionResp       `description:"研选报告"`
+	ListHzReport   []*ArticleCollectionResp       `description:"弘则报告"`
+}
+
 //产业列表
 //产业列表
-func GetSearchResourceList(condition string) (items []*IndustrialManagementHotResp, err error) {
+func GetSearchResourceList(condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()
 	sql := `SELECT
 	sql := `SELECT
 			m.industry_name,
 			m.industry_name,
@@ -679,6 +714,10 @@ func GetSearchResourceList(condition string) (items []*IndustrialManagementHotRe
 		WHERE
 		WHERE
 			1 = 1
 			1 = 1
 			AND publish_status = 1 ` + condition + `  GROUP BY m.industrial_management_id  ORDER BY publish_date_order DESC `
 			AND publish_status = 1 ` + condition + `  GROUP BY m.industrial_management_id  ORDER BY publish_date_order DESC `
+
+	if startSize > 0 || pageSize > 0 {
+		sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
+	}
 	_, err = o.Raw(sql).QueryRows(&items)
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 	return
 }
 }

+ 18 - 0
routers/commentsRouter.go

@@ -781,6 +781,15 @@ func init() {
             Filters: nil,
             Filters: nil,
             Params: nil})
             Params: nil})
 
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "SearchReportAndResource",
+            Router: `/searchReportAndResource`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
         beego.ControllerComments{
         beego.ControllerComments{
             Method: "SearchResource",
             Method: "SearchResource",
@@ -898,6 +907,15 @@ func init() {
             Filters: nil,
             Filters: nil,
             Params: nil})
             Params: nil})
 
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"],
+        beego.ControllerComments{
+            Method: "ListHomeArtAndChartPage",
+            Router: `/artAndChart/listPage`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"],
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"],
         beego.ControllerComments{
         beego.ControllerComments{
             Method: "SearchList",
             Method: "SearchList",

+ 154 - 494
services/elastic.go

@@ -425,491 +425,6 @@ func EsDeleteData(indexName, docId string) (err error) {
 	return
 	return
 }
 }
 
 
-func MappingModify(indexName, mappingJson string) {
-	client := utils.Client
-	//if err != nil {
-	//	return
-	//}
-	result, err := client.PutMapping().Index(indexName).BodyString(mappingJson).Do(context.Background())
-	fmt.Println(err)
-	fmt.Println(result)
-	return
-}
-
-func EsMatchQuery(indexName, keyWord string) (result []*models.SearchItem, err error) {
-	client := utils.Client
-	pageSize := 20
-	keyWordArr, err := GetIndustryMapNameSliceV2(keyWord)
-	fmt.Println(keyWordArr)
-	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-	fmt.Println("-------------------------------")
-	fmt.Println(keyWordArr)
-	searchMap := make(map[int]int)
-	boolquery := elastic.NewBoolQuery()
-	keyLen := len(keyWordArr)
-	n := 5.0 * float64(keyLen)
-	matchArr := make([]elastic.Query, 0)
-	//
-	//matchq1 := elastic.NewMatchQuery("Title", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	//matchq2 := elastic.NewMatchQuery("BodyText", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	//
-	//matchArr = append(matchArr, matchq1)
-	//matchArr = append(matchArr, matchq2)
-	for _, v := range keyWordArr {
-		if v != "" {
-			matchq1 := elastic.NewMatchQuery("Title", v).Boost(n).Analyzer("ik_smart")
-			matchq2 := elastic.NewMatchQuery("BodyText", v).Boost(n).Analyzer("ik_smart")
-			matchArr = append(matchArr, matchq1)
-			matchArr = append(matchArr, matchq2)
-		}
-		n = n - 5
-	}
-	boolquery.Should(matchArr...)
-	highlight := elastic.NewHighlight()
-	highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-	highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-	request := client.Search(indexName).Highlight(highlight).Size(pageSize).Query(boolquery)
-	searchByMatch, err := request.Do(context.Background())
-	if searchByMatch.Hits != nil {
-		for _, v := range searchByMatch.Hits.Hits {
-			articleJson, err := v.Source.MarshalJSON()
-			if err != nil {
-				return nil, err
-			}
-			article := new(models.CygxArticle)
-			err = json.Unmarshal(articleJson, &article)
-			if err != nil {
-				return nil, err
-			}
-			if _, ok := searchMap[article.ArticleId]; !ok {
-				searchItem := new(models.SearchItem)
-				searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-				if len(v.Highlight["BodyText"]) > 0 {
-					searchItem.Body = v.Highlight["BodyText"]
-				} else {
-					bodyRune := []rune(article.BodyText)
-					bodyRuneLen := len(bodyRune)
-					if bodyRuneLen > 100 {
-						bodyRuneLen = 100
-					}
-					body := string(bodyRune[:bodyRuneLen])
-					fmt.Println(body)
-					searchItem.Body = []string{body}
-				}
-				var title string
-				if len(v.Highlight["Title"]) > 0 {
-					title = v.Highlight["Title"][0]
-				} else {
-					title = article.Title
-				}
-				searchItem.Title = title
-				searchItem.PublishDate = article.PublishDate
-				result = append(result, searchItem)
-				searchMap[article.ArticleId] = article.ArticleId
-			}
-		}
-	}
-	return
-}
-
-func EsMatchPhraseQuery(indexName, keyWord string) (result []*models.SearchItem, err error) {
-	client := utils.Client
-	pageSize := 20
-	keyWordArr, err := GetIndustryMapNameSliceV2(keyWord)
-	fmt.Println(keyWordArr)
-	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-	fmt.Println("-------------------------------")
-	fmt.Println(keyWordArr)
-	searchMap := make(map[int]int)
-	boolquery := elastic.NewBoolQuery()
-	//keyLen := len(keyWordArr)
-	//n := float64(keyLen)
-	matchArr := make([]elastic.Query, 0)
-	//matchq1 := elastic.NewMatchQuery("Title", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	//matchq2 := elastic.NewMatchQuery("BodyText", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	matchq1 := elastic.NewMatchPhraseQuery("Title", keyWord) //.Analyzer("ik_smart")
-	matchq2 := elastic.NewMatchPhraseQuery("BodyText", keyWord)
-	matchArr = append(matchArr, matchq1)
-	matchArr = append(matchArr, matchq2)
-	//matchArr = append(matchArr, matchq2)
-	//for _, v := range keyWordArr {
-	//	if v != "" {
-	//		matchq1 := elastic.NewMatchQuery("Title", v).Boost(n).Analyzer("ik_smart")
-	//		matchq2 := elastic.NewMatchQuery("BodyText", v).Boost(n).Analyzer("ik_smart")
-	//		matchArr = append(matchArr, matchq1)
-	//		matchArr = append(matchArr, matchq2)
-	//	}
-	//	n--
-	//}
-	//boolquery.Should(matchArr...)
-
-	boolquery.Should(matchArr...)
-
-	highlight := elastic.NewHighlight()
-	highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-	highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-	request := client.Search(indexName).Highlight(highlight).Size(pageSize).Query(boolquery)
-	searchByMatch, err := request.Do(context.Background())
-	fmt.Println("err:", err, searchByMatch)
-	return
-	if searchByMatch.Hits != nil {
-		for _, v := range searchByMatch.Hits.Hits {
-			articleJson, err := v.Source.MarshalJSON()
-			if err != nil {
-				return nil, err
-			}
-			article := new(models.CygxArticle)
-			err = json.Unmarshal(articleJson, &article)
-			if err != nil {
-				return nil, err
-			}
-			if _, ok := searchMap[article.ArticleId]; !ok {
-				searchItem := new(models.SearchItem)
-				searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-				searchItem.Body = v.Highlight["BodyText"]
-				var title string
-				if len(v.Highlight["Title"]) > 0 {
-					title = v.Highlight["Title"][0]
-				} else {
-					title = article.Title
-				}
-				searchItem.Title = title
-				searchItem.PublishDate = article.PublishDate
-				result = append(result, searchItem)
-				searchMap[article.ArticleId] = article.ArticleId
-			}
-		}
-	}
-	return
-}
-
-func EsMatchFunctionScoreQuery(indexName, keyWord string, startSize, pageSize int) (result []*models.SearchItem, total int64, err error) {
-	client := utils.Client
-	keyWordArr, err := GetIndustryMapNameSliceV2(keyWord)
-	fmt.Println(keyWordArr)
-	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-	fmt.Println("-------------------------------")
-	fmt.Println(keyWordArr)
-
-	searchMap := make(map[int]int)
-	boolquery := elastic.NewBoolQuery()
-	matchArr := make([]elastic.Query, 0)
-	//
-	//matchq1 := elastic.NewMatchQuery("Title", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	//matchq2 := elastic.NewMatchQuery("BodyText", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	//
-	//matchArr = append(matchArr, matchq1)
-	//matchArr = append(matchArr, matchq2)
-	n := 0
-	keyWordLen := len(keyWordArr)
-	if keyWordLen <= 0 {
-		keyWordArr = append(keyWordArr, keyWord)
-		keyWordLen = len(keyWordArr)
-	}
-	keyWordWeight := GetWeight(keyWordLen)
-
-	fmt.Println(keyWordArr)
-	fmt.Println(keyWordWeight)
-	for k, v := range keyWordArr {
-		if v != "" {
-			weight := float64(keyWordWeight[k])
-			titleMatchq := elastic.NewMatchQuery("Title", v).Analyzer("ik_smart")
-
-			bodyMatchq := elastic.NewMatchQuery("BodyText", v).Analyzer("ik_smart")
-
-			titleFunctionQuery := elastic.NewFunctionScoreQuery()
-			titleFunctionQuery.Query(titleMatchq)
-			titleFunctions := elastic.NewWeightFactorFunction(weight)
-			titleFunctionQuery.AddScoreFunc(titleFunctions)
-			titleFunctionQuery.BoostMode("replace")
-
-			bodyFunctionQuery := elastic.NewFunctionScoreQuery()
-			bodyFunctionQuery.Query(bodyMatchq)
-			bodyFunctions := elastic.NewWeightFactorFunction(weight)
-			bodyFunctionQuery.AddScoreFunc(bodyFunctions)
-			bodyFunctionQuery.BoostMode("replace")
-
-			matchArr = append(matchArr, titleFunctionQuery)
-			matchArr = append(matchArr, bodyFunctionQuery)
-		}
-		n++
-	}
-	boolquery.Should(matchArr...)
-	highlight := elastic.NewHighlight()
-	highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-	highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-	request := client.Search(indexName).Highlight(highlight).From(startSize).Size(pageSize).Query(boolquery)
-	searchByMatch, err := request.Do(context.Background())
-	//searchJson, err := json.Marshal(searchByMatch)
-	if searchByMatch != nil {
-		if searchByMatch.Hits != nil {
-			for _, v := range searchByMatch.Hits.Hits {
-				articleJson, err := v.Source.MarshalJSON()
-				if err != nil {
-					return nil, 0, err
-				}
-				article := new(models.CygxArticle)
-				err = json.Unmarshal(articleJson, &article)
-				if err != nil {
-					return nil, 0, err
-				}
-				if _, ok := searchMap[article.ArticleId]; !ok {
-					searchItem := new(models.SearchItem)
-					searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-					if len(v.Highlight["BodyText"]) > 0 {
-						searchItem.Body = v.Highlight["BodyText"]
-					} else {
-						bodyRune := []rune(article.BodyText)
-						bodyRuneLen := len(bodyRune)
-						if bodyRuneLen > 100 {
-							bodyRuneLen = 100
-						}
-						body := string(bodyRune[:bodyRuneLen])
-						fmt.Println(body)
-						searchItem.Body = []string{body}
-					}
-					var title string
-					if len(v.Highlight["Title"]) > 0 {
-						title = v.Highlight["Title"][0]
-					} else {
-						title = article.Title
-					}
-					searchItem.Title = title
-					searchItem.PublishDate = article.PublishDate
-					result = append(result, searchItem)
-					searchMap[article.ArticleId] = article.ArticleId
-				}
-			}
-		}
-	}
-	total = searchByMatch.Hits.TotalHits.Value
-	return
-}
-
-func EsMultiMatchFunctionScoreQuery(indexName, keyWord string, startSize, pageSize, userId int) (result []*models.SearchItem, total int64, err error) {
-	client := utils.Client
-	keyWordArr, err := GetIndustryMapNameSliceV3(keyWord)
-	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-	//artidArr := make([]elastic.Query, 0)
-	//matchArr := make([]elastic.Query, 0)
-	n := 0
-	keyWordLen := len(keyWordArr)
-	if keyWordLen <= 0 {
-		keyWordArr = append(keyWordArr, keyWord)
-		keyWordLen = len(keyWordArr)
-	}
-	utils.FileLog.Info("SearchKeyWord:%s, userId:%s", keyWordArr, strconv.Itoa(userId))
-	//keyWordWeight := GetWeight(keyWordLen)
-	for _, v := range keyWordArr {
-		if v != "" {
-			matchArr := make([]elastic.Query, 0)
-			boolquery := elastic.NewBoolQuery()
-			//weight := float64(keyWordWeight[k])
-			//multiMatch := elastic.NewMultiMatchQuery(v, "Title", "BodyText").Analyzer("ik_smart")
-			//bodyFunctionQuery := elastic.NewFunctionScoreQuery()
-			//bodyFunctionQuery.Query(multiMatch)
-			//bodyFunctions := elastic.NewWeightFactorFunction(weight)
-			//bodyFunctionQuery.AddScoreFunc(bodyFunctions)
-			//bodyFunctionQuery.BoostMode("replace")
-			//matchArr = append(matchArr, bodyFunctionQuery)
-			//weight := float64(keyWordWeight[k])
-			multiMatch := elastic.NewMultiMatchQuery(v, "Title", "BodyText").Analyzer("ik_smart")
-			bodyFunctionQuery := elastic.NewFunctionScoreQuery()
-			bodyFunctionQuery.Query(multiMatch)
-			//bodyFunctions := elastic.NewWeightFactorFunction(weight)
-			//bodyFunctionQuery.AddScoreFunc(bodyFunctions)
-			//bodyFunctionQuery.BoostMode("replace")
-			matchArr = append(matchArr, bodyFunctionQuery)
-			boolquery.Should(matchArr...)
-			highlight := elastic.NewHighlight()
-			highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-			highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-			request := client.Search(indexName).Highlight(highlight).From(startSize).Size(pageSize).Query(boolquery)
-			searchByMatch, err := request.Do(context.Background())
-			if err != nil {
-				return nil, 0, err
-			}
-			if searchByMatch != nil {
-				if searchByMatch.Hits != nil {
-					for _, v := range searchByMatch.Hits.Hits {
-						var isAppend bool
-						articleJson, err := v.Source.MarshalJSON()
-						if err != nil {
-							return nil, 0, err
-						}
-						article := new(models.CygxArticle)
-						err = json.Unmarshal(articleJson, &article)
-						if err != nil {
-							return nil, 0, err
-						}
-						searchItem := new(models.SearchItem)
-						searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-						if len(v.Highlight["BodyText"]) > 0 {
-							searchItem.Body = v.Highlight["BodyText"]
-						} else {
-							bodyRune := []rune(article.BodyText)
-							bodyRuneLen := len(bodyRune)
-							if bodyRuneLen > 100 {
-								bodyRuneLen = 100
-							}
-							body := string(bodyRune[:bodyRuneLen])
-							searchItem.Body = []string{body}
-						}
-						var title string
-						if len(v.Highlight["Title"]) > 0 {
-							title = v.Highlight["Title"][0]
-						} else {
-							title = article.Title
-						}
-						searchItem.Title = title
-						searchItem.PublishDate = article.PublishDate
-						for _, v_result := range result {
-							if v_result.ArticleId == searchItem.ArticleId {
-								isAppend = true
-							}
-						}
-						if !isAppend {
-							result = append(result, searchItem)
-						}
-					}
-				}
-				//total += searchByMatch.Hits.TotalHits.Value
-			}
-		}
-		n++
-	}
-	total = int64(len(result))
-	//fmt.Println(result)
-	//boolquery.Should(matchArr...)
-	//highlight := elastic.NewHighlight()
-	//highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-	//highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-	//request := client.Search(indexName).Highlight(highlight).From(startSize).Size(pageSize).Query(boolquery)
-	//searchByMatch, err := request.Do(context.Background())
-	//if searchByMatch != nil {
-	//	if searchByMatch.Hits != nil {
-	//		for _, v := range searchByMatch.Hits.Hits {
-	//			articleJson, err := v.Source.MarshalJSON()
-	//			if err != nil {
-	//				return nil, 0, err
-	//			}
-	//			article := new(models.CygxArticle)
-	//			err = json.Unmarshal(articleJson, &article)
-	//			if err != nil {
-	//				return nil, 0, err
-	//			}
-	//			searchItem := new(models.SearchItem)
-	//			searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-	//			if len(v.Highlight["BodyText"]) > 0 {
-	//				searchItem.Body = v.Highlight["BodyText"]
-	//			} else {
-	//				bodyRune := []rune(article.BodyText)
-	//				bodyRuneLen := len(bodyRune)
-	//				if bodyRuneLen > 100 {
-	//					bodyRuneLen = 100
-	//				}
-	//				body := string(bodyRune[:bodyRuneLen])
-	//				searchItem.Body = []string{body}
-	//			}
-	//			var title string
-	//			if len(v.Highlight["Title"]) > 0 {
-	//				title = v.Highlight["Title"][0]
-	//			} else {
-	//				title = article.Title
-	//			}
-	//			searchItem.Title = title
-	//			searchItem.PublishDate = article.PublishDate
-	//
-	//			result = append(result, searchItem)
-	//		}
-	//	}
-	//	total = searchByMatch.Hits.TotalHits.Value
-	//}
-	return
-}
-
-func EsMultiMatchFunctionScoreQueryFix(indexName, keyWord string, startSize, pageSize int) (result []*models.SearchItem, total int64, err error) {
-	client := utils.Client
-	keyWordArr, err := GetIndustryMapNameSliceV2(keyWord)
-
-	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-	boolquery := elastic.NewBoolQuery()
-	matchArr := make([]elastic.Query, 0)
-
-	n := 0
-	keyWordLen := len(keyWordArr)
-	if keyWordLen <= 0 {
-		keyWordArr = append(keyWordArr, keyWord)
-		keyWordLen = len(keyWordArr)
-	}
-	fmt.Println(keyWordArr)
-
-	keyWordWeight := GetWeight(keyWordLen)
-	for k, v := range keyWordArr {
-		if v != "" {
-			weight := float64(keyWordWeight[k])
-			multiMatch := elastic.NewMultiMatchQuery(v, "Title", "BodyText").Analyzer("ik_smart")
-			bodyFunctionQuery := elastic.NewFunctionScoreQuery()
-			bodyFunctionQuery.Query(multiMatch)
-			bodyFunctions := elastic.NewWeightFactorFunction(weight)
-			bodyFunctionQuery.AddScoreFunc(bodyFunctions)
-			bodyFunctionQuery.BoostMode("replace")
-			matchArr = append(matchArr, bodyFunctionQuery)
-		}
-		n++
-	}
-	boolquery.Should(matchArr...)
-	highlight := elastic.NewHighlight()
-	highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-	highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-	request := client.Search(indexName).Highlight(highlight).From(startSize).Size(pageSize).Query(boolquery)
-	searchByMatch, err := request.Do(context.Background())
-	if searchByMatch != nil {
-
-		matchResult, _ := json.Marshal(searchByMatch)
-		utils.FileLog.Info("%s", string(matchResult))
-
-		if searchByMatch.Hits != nil {
-			for _, v := range searchByMatch.Hits.Hits {
-				articleJson, err := v.Source.MarshalJSON()
-				utils.FileLog.Info("%s", string(articleJson))
-				if err != nil {
-					return nil, 0, err
-				}
-				article := new(models.CygxArticle)
-				err = json.Unmarshal(articleJson, &article)
-				if err != nil {
-					return nil, 0, err
-				}
-				searchItem := new(models.SearchItem)
-				searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-				if len(v.Highlight["BodyText"]) > 0 {
-					searchItem.Body = v.Highlight["BodyText"]
-				} else {
-					bodyRune := []rune(article.BodyText)
-					bodyRuneLen := len(bodyRune)
-					if bodyRuneLen > 100 {
-						bodyRuneLen = 100
-					}
-					body := string(bodyRune[:bodyRuneLen])
-					searchItem.Body = []string{body}
-				}
-				var title string
-				if len(v.Highlight["Title"]) > 0 {
-					title = v.Highlight["Title"][0]
-				} else {
-					title = article.Title
-				}
-				searchItem.Title = title
-				searchItem.PublishDate = article.PublishDate
-				result = append(result, searchItem)
-			}
-		}
-		total = searchByMatch.Hits.TotalHits.Value
-	}
-	return
-}
-
 func GetWeight(length int) []int {
 func GetWeight(length int) []int {
 	steep := 10
 	steep := 10
 	intArr := make([]int, 0)
 	intArr := make([]int, 0)
@@ -937,15 +452,6 @@ func GetArrSum(intArr []int) (sum int) {
 	return
 	return
 }
 }
 
 
-//func init() {
-//	fmt.Println("start")
-//	keyWord:="阿里巴巴"
-//	keyWordArr, _ := GetIndustryMapNameSliceV2(keyWord)
-//	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-//	fmt.Println(keyWordArr)
-//	fmt.Println("end")
-//}
-
 func EsMultiMatchFunctionScoreQuerySort(indexName, keyWord string, startSize, pageSize, userId int, orderColumn string) (result []*models.SearchItem, total int64, err error) {
 func EsMultiMatchFunctionScoreQuerySort(indexName, keyWord string, startSize, pageSize, userId int, orderColumn string) (result []*models.SearchItem, total int64, err error) {
 	client := utils.Client
 	client := utils.Client
 	keyWordArr, err := GetIndustryMapNameSliceV3(keyWord)
 	keyWordArr, err := GetIndustryMapNameSliceV3(keyWord)
@@ -1378,3 +884,157 @@ func EsMultiMatchFunctionScoreQuerySortPage(indexName, keyWord string, startSize
 	total += searchByMatch.Hits.TotalHits.Value
 	total += searchByMatch.Hits.TotalHits.Value
 	return
 	return
 }
 }
+
+func init23423() {
+	EsArticleSearch("立高食品", 0, 10, "34")
+}
+
+func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string) (result []*models.SearchItem, total int64, err error) {
+	indexName := utils.IndexName
+	client := utils.Client
+	keyWordArr, err := GetIndustryMapNameSliceV3(keyWord)
+	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
+	keyWordLen := len(keyWordArr)
+	if keyWordLen <= 0 {
+		keyWordArr = append(keyWordArr, keyWord)
+		keyWordLen = len(keyWordArr)
+	}
+	//fmt.Println(keyWordArr)
+	mustMap := make([]interface{}, 0)
+	shouldMap := make(map[string]interface{}, 0)
+	//shouldMapquery := make(map[string]interface{}, 0)
+	shouldMapquery := make([]interface{}, 0)
+	// @Param   OrderColumn   query   int  true       "排序字段 ,Comprehensive综合 ,Matching匹配度 ,PublishDate 发布时间 "
+	//keyWordWeight := GetWeight(keyWordLen)
+	var boost int
+	lenkeyWordArr := len(keyWordArr)
+	for k, v := range keyWordArr {
+		if k == 0 {
+			boost = 2 * 1000
+		} else {
+			boost = 1000
+		}
+		if v != "" {
+			shouldMapquery = append(shouldMapquery, map[string]interface{}{
+				"function_score": map[string]interface{}{
+					"query": map[string]interface{}{
+						"multi_match": map[string]interface{}{
+							"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
+							"fields": []interface{}{"Title"},
+							"query":  v,
+						},
+					},
+				},
+			})
+
+			shouldMapquery = append(shouldMapquery, map[string]interface{}{
+				"function_score": map[string]interface{}{
+					"query": map[string]interface{}{
+						"multi_match": map[string]interface{}{
+							"boost":  (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
+							"fields": []interface{}{"BodyText"},
+							"query":  v,
+						},
+					},
+				},
+			})
+		}
+	}
+	shouldMap = map[string]interface{}{
+		"should": shouldMapquery,
+	}
+	//排序
+	sortMap := make([]interface{}, 0)
+	//时间
+	sortMap = append(sortMap, map[string]interface{}{
+		"PublishDate": map[string]interface{}{
+			"order": "desc",
+		},
+	})
+	//高亮
+	highlightMap := make(map[string]interface{}, 0)
+	highlightMap = map[string]interface{}{
+		"fields": map[string]interface{}{
+			"BodyText": map[string]interface{}{},
+			"Title":    map[string]interface{}{},
+		},
+		//样式 红色
+		"post_tags": []interface{}{"</font>"},
+		"pre_tags":  []interface{}{"<font color='red'>"},
+	}
+
+	mustMap = append(mustMap, map[string]interface{}{
+		"bool": shouldMap,
+	})
+	queryMap := map[string]interface{}{
+		"query": map[string]interface{}{
+			"bool": map[string]interface{}{
+				"must": mustMap,
+			},
+		},
+	}
+	if orderColumn == "PublishDate" {
+		queryMap["sort"] = sortMap
+	}
+	queryMap["from"] = startSize
+	queryMap["size"] = pageSize
+	queryMap["highlight"] = highlightMap
+	jsonBytes, _ := json.Marshal(queryMap)
+	fmt.Println(string(jsonBytes))
+	//utils.FileLog.Info(string(jsonBytes))
+	request := client.Search(indexName).Source(queryMap) // sets the JSON request
+	searchByMatch, err := request.Do(context.Background())
+	if searchByMatch != nil {
+		if searchByMatch.Hits != nil {
+			for _, v := range searchByMatch.Hits.Hits {
+				var isAppend bool
+				articleJson, err := v.Source.MarshalJSON()
+				if err != nil {
+					return nil, 0, err
+				}
+				article := new(models.CygxArticleEs)
+				err = json.Unmarshal(articleJson, &article)
+				if err != nil {
+					return nil, 0, err
+				}
+				searchItem := new(models.SearchItem)
+				searchItem.ArticleId, _ = strconv.Atoi(v.Id)
+				if len(v.Highlight["BodyText"]) > 0 {
+					searchItem.Body = v.Highlight["BodyText"]
+				} else {
+					bodyRune := []rune(article.BodyText)
+					bodyRuneLen := len(bodyRune)
+					if bodyRuneLen > 100 {
+						bodyRuneLen = 100
+					}
+					body := string(bodyRune[:bodyRuneLen])
+					searchItem.Body = []string{body}
+				}
+				var title string
+				if len(v.Highlight["Title"]) > 0 {
+					title = v.Highlight["Title"][0]
+				} else {
+					title = article.Title
+				}
+				searchItem.Title = title
+				searchItem.PublishDate = article.PublishDate
+				searchItem.ExpertBackground = article.ExpertBackground
+				searchItem.CategoryId = article.CategoryId
+				for _, v_result := range result {
+					if v_result.ArticleId == searchItem.ArticleId {
+						isAppend = true
+					}
+				}
+				if !isAppend {
+					result = append(result, searchItem)
+				}
+			}
+		}
+		total = searchByMatch.Hits.TotalHits.Value
+	}
+	//fmt.Println(result)
+	//for _, v := range result {
+	//	fmt.Println(v)
+	//}
+	return
+}

+ 1 - 0
services/tactics.go

@@ -745,6 +745,7 @@ func GetSummarytoEs(cont context.Context) (err error) {
 		item.ArticleId = v.ArticleId
 		item.ArticleId = v.ArticleId
 		item.Title = v.Title
 		item.Title = v.Title
 		item.PublishDate = v.PublishDate
 		item.PublishDate = v.PublishDate
+		bodyText, _ = GetReportContentTextSub(v.Body)
 		item.BodyText = bodyText
 		item.BodyText = bodyText
 		item.CategoryId = strconv.Itoa(v.CategoryId)
 		item.CategoryId = strconv.Itoa(v.CategoryId)
 		item.ExpertBackground = v.ExpertBackground
 		item.ExpertBackground = v.ExpertBackground

+ 28 - 0
services/user_freee_button.go

@@ -0,0 +1,28 @@
+package services
+
+import (
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+)
+
+// GetfreeButtonIsShow 用户免费分享按钮是否回显
+func GetfreeButtonIsShow(user *models.WxUserItem) (isShow bool, err error) {
+	detail, err := models.GetConfigByCode("free_trial_card")
+	if err != nil {
+		return
+	}
+	companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	count, err := models.CountCygxUserFreeeButton(user.UserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	if companyDetail != nil && companyDetail.IsSuspend == 0 {
+		if detail.ConfigValue == "1" && (companyDetail.Status == "正式" || companyDetail.Status == "试用" || companyDetail.Status == "永续") && count == 0 {
+			isShow = true
+		}
+	}
+	return
+}