Selaa lähdekoodia

Merge branch 'cygx_11.0' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 1 vuosi sitten
vanhempi
commit
3560efd0ee
5 muutettua tiedostoa jossa 38 lisäystä ja 1 poistoa
  1. 7 0
      controllers/search.go
  2. 2 1
      controllers/user.go
  3. 1 0
      models/report.go
  4. 1 0
      models/search.go
  5. 27 0
      services/article.go

+ 7 - 0
controllers/search.go

@@ -596,6 +596,7 @@ func (this *SearchController) ListHomeArtAndChartPage() {
 	resp.ChartList = chartList
 	var result []*models.SearchItem
 	var total int64
+	var articleIds []int
 	if listType == 1 || listType == 2 {
 		//添加映射关系
 		keyWord = strings.ToUpper(keyWord)
@@ -667,6 +668,7 @@ func (this *SearchController) ListHomeArtAndChartPage() {
 			}
 			result[k].Source = 1
 			v.PublishDate = utils.TimeRemoveHms(v.PublishDate)
+			articleIds = append(articleIds, v.ArticleId)
 		}
 	}
 	//记录用户搜索关键词
@@ -687,6 +689,11 @@ func (this *SearchController) ListHomeArtAndChartPage() {
 	}
 	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 - 1
controllers/user.go

@@ -568,10 +568,11 @@ 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

+ 1 - 0
models/report.go

@@ -1030,6 +1030,7 @@ type ArticleReportBillboardResp struct {
 	Source         int    `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
 	IsRoadShow     bool   `description:"是否是路演精华"`
 	CategoryId     int    `description:"分类ID"`
+	IsResearch     bool   `description:"是否属于研选"`
 	List           []*IndustrialManagementIdInt
 }
 

+ 1 - 0
models/search.go

@@ -15,6 +15,7 @@ type SearchItem struct {
 	CategoryId       string   `description:"文章分类"`
 	Source           int      `description:"来源  1:文章, 2:图表"`
 	IsNeedJump       bool     `description:"是否需要跳转链接地址"`
+	IsResearch       bool     `description:"是否属于研选"`
 }
 
 type CategoryItem struct {

+ 27 - 0
services/article.go

@@ -2166,3 +2166,30 @@ func GetArticleCoverByChartFirst(body string) (cover string) {
 	}
 	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
+}