소스 검색

no message

xingzai 1 년 전
부모
커밋
1fc7232b34
5개의 변경된 파일40개의 추가작업 그리고 8개의 파일을 삭제
  1. 8 0
      controllers/search.go
  2. 2 8
      controllers/user.go
  3. 2 0
      models/report.go
  4. 1 0
      models/search.go
  5. 27 0
      services/article.go

+ 8 - 0
controllers/search.go

@@ -170,6 +170,7 @@ func (this *MobileSearchController) ListHomeArtAndChart() {
 	resp.ChartList = chartList
 	var result []*models.SearchItem
 	var total int64
+	var articleIds []int
 	if listType == 1 || listType == 2 {
 		//if orderColumn == "PublishDate" {
 		//	tmpResult, tmpTotal, tmpErr := services.EsMultiMatchFunctionScoreQueryTimeSort(indexName, keyWord, startSize, 100, user.UserId)
@@ -246,8 +247,10 @@ func (this *MobileSearchController) ListHomeArtAndChart() {
 				result[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
 			}
 			result[k].Source = 1
+			articleIds = append(articleIds, v.ArticleId)
 		}
 	}
+
 	//ListType   query   int  true       "列表类型,1最新/全部,2 纪要 ,3图表 默认1"
 	//记录用户搜索关键词
 	//var source int
@@ -270,6 +273,11 @@ func (this *MobileSearchController) ListHomeArtAndChart() {
 	}
 	if len(result) == 0 {
 		result = make([]*models.SearchItem, 0)
+	} else {
+		yxArticleIdMap := services.GetYxArticleIdMap(articleIds)
+		for _, v := range result {
+			v.IsResearch = yxArticleIdMap[v.ArticleId] // 添加是否属于研选的标识
+		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, int(total))
 	resp.Paging = page

+ 2 - 8
controllers/user.go

@@ -906,23 +906,17 @@ func (this *UserController) CollectList() {
 		list[i].DepartmentId = article.DepartmentId
 		list[i].NickName = article.NickName
 		list[i].PublishDate = article.PublishDate
-		if article.ArticleId < utils.SummaryArticleId {
+		if article.ArticleTypeId < 0 {
 			list[i].Source = 1
 		} else {
 			list[i].Source = 2
+			list[i].IsResearch = true
 		}
 		if mapArticleCollectNum[article.ArticleId] != nil {
 			list[i].CollectNum = mapArticleCollectNum[article.ArticleId].CollectNum
 			list[i].Pv = mapArticleCollectNum[article.ArticleId].Pv
 			list[i].IsCollect = mapArticleCollectNum[article.ArticleId].IsCollect
 		}
-		//list[i].TitleEn = article.TitleEn
-		//list[i].UpdateFrequency = article.UpdateFrequency
-		//list[i].CreateDate = article.CreateDate
-		//list[i].Body, _ = services.GetReportContentTextSub(article.Body)
-		//list[i].Abstract = article.Abstract
-		//list[i].CategoryName = article.CategoryName
-		//list[i].SubCategoryName = article.SubCategoryName
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp.List = list

+ 2 - 0
models/report.go

@@ -735,6 +735,8 @@ type ArticleReportBillboardResp struct {
 	Pv             int    `description:"PV"`
 	CollectNum     int    `description:"收藏人数"`
 	Source         int    `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	ArticleTypeId  int    `description:"文章类型ID判断是否是研选使用"`
+	IsResearch     bool   `description:"是否属于研选"`
 	List           []*IndustrialManagementIdInt
 }
 

+ 1 - 0
models/search.go

@@ -14,6 +14,7 @@ type SearchItem struct {
 	ImgUrlPc         string   `description:"图片链接"`
 	CategoryId       string   `description:"文章分类"`
 	Source           int      `description:"来源  1:文章, 2:图表"`
+	IsResearch       bool     `description:"是否属于研选"`
 }
 
 type CategoryItem struct {

+ 27 - 0
services/article.go

@@ -720,3 +720,30 @@ func GetAiQianYanArtilceList(startSize, pageSize int) (items []*models.HomeArtic
 	}
 	return
 }
+
+// GetYxArticleIdMap 获取研选文章ID
+func GetYxArticleIdMap(articleIds []int) (mapResp map[int]bool) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("获取研选文章ID失败,GetYxArticleIdMap"+err.Error(), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition = ` AND  article_type_id > 0 `
+	if len(articleIds) > 0 {
+		condition += ` AND article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
+		pars = append(pars, articleIds)
+	}
+	articleList, e := models.GetArticleList(condition, pars)
+	if e != nil {
+		err = errors.New("GetArticleList, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int]bool, 0)
+	for _, v := range articleList {
+		mapResp[v.ArticleId] = true
+	}
+	return
+}