Parcourir la source

Merge branch 'need_article_chanye_list' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_9.1

xingzai il y a 2 ans
Parent
commit
e8a1cac599
2 fichiers modifiés avec 65 ajouts et 11 suppressions
  1. 48 1
      controllers/report.go
  2. 17 10
      models/report.go

+ 48 - 1
controllers/report.go

@@ -2727,6 +2727,54 @@ func (this *ReportController) SearchReportAndResource() {
 		}
 	}
 
+	var articleIds string
+	for _, v := range ListHzReport {
+		articleIds += strconv.Itoa(v.ArticleId) + ","
+	}
+	for _, v := range ListYxReport {
+		articleIds += strconv.Itoa(v.ArticleId) + ","
+	}
+	articleIds = strings.TrimRight(articleIds, ",")
+	silcearticleIds := strings.Split(articleIds, ",")
+	var parsindustrial []interface{}
+	parsindustrial = make([]interface{}, 0)
+	articleIdList := make([]string, 0)
+	for _, v := range silcearticleIds {
+		articleIdList = append(articleIdList, v)
+	}
+	conditionindustrial := ` AND mg.article_id IN (  ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` )  `
+	parsindustrial = append(parsindustrial, articleIdList)
+	industrialList, err := models.GetIndustrialListByarticleId(parsindustrial, conditionindustrial)
+	if err != nil {
+		return
+	}
+	industrialMap := make(map[int][]*models.IndustrialManagementResp)
+	if len(industrialList) > 0 {
+		for _, v := range industrialList {
+			item := new(models.IndustrialManagementResp)
+			//item.ArticleId = v.ArticleId
+			item.IndustrialManagementId = v.IndustrialManagementId
+			item.IndustryName = v.IndustryName
+			item.ChartPermissionId = v.ChartPermissionId
+			industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
+		}
+	}
+	for k, v := range ListHzReport {
+		if len(industrialMap[v.ArticleId]) > 0 {
+			ListHzReport[k].List = industrialMap[v.ArticleId]
+		} else {
+			ListHzReport[k].List = make([]*models.IndustrialManagementResp, 0)
+		}
+	}
+	for k, v := range ListYxReport {
+		if len(industrialMap[v.ArticleId]) > 0 {
+			ListYxReport[k].List = industrialMap[v.ArticleId]
+		} else {
+			ListYxReport[k].List = make([]*models.IndustrialManagementResp, 0)
+		}
+	}
+	//获取文章关联的产业
+
 	if len(ListYxReport) == 0 {
 		ListYxReport = make([]*models.ArticleCollectionResp, 0)
 	}
@@ -2789,7 +2837,6 @@ func (this *ReportController) SearchReportAndResource() {
 			listYxResource[k].IsFollw = true
 		}
 		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
-
 	}
 
 	if len(industrialIdArr) > 0 {

+ 17 - 10
models/report.go

@@ -349,18 +349,25 @@ func GetArticleIdsBySubId(subjectId string) (articleIds string, err error) {
 
 //用户收藏榜start
 type ArticleCollectionResp struct {
-	ArticleId              int    `description:"文章id"`
-	Title                  string `description:"标题"`
-	PublishDate            string `description:"发布时间"`
+	ArticleId              int                         `description:"文章id"`
+	Title                  string                      `description:"标题"`
+	PublishDate            string                      `description:"发布时间"`
+	IndustrialManagementId int                         `description:"产业Id"`
+	IndustryName           string                      `description:"产业名称"`
+	DepartmentId           int                         `description:"作者Id"`
+	NickName               string                      `description:"作者昵称"`
+	MyCollectNum           int                         `description:"本人是否收藏"`
+	IsCollect              bool                        `description:"本人是否收藏"`
+	Pv                     int                         `description:"PV"`
+	CollectNum             int                         `description:"收藏人数"`
+	Source                 int                         `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	List                   []*IndustrialManagementResp `description:"产业列表"`
+}
+
+type IndustrialManagementResp struct {
 	IndustrialManagementId int    `description:"产业Id"`
 	IndustryName           string `description:"产业名称"`
-	DepartmentId           int    `description:"作者Id"`
-	NickName               string `description:"作者昵称"`
-	MyCollectNum           int    `description:"本人是否收藏"`
-	IsCollect              bool   `description:"本人是否收藏"`
-	Pv                     int    `description:"PV"`
-	CollectNum             int    `description:"收藏人数"`
-	Source                 int    `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	ChartPermissionId      int    `description:"权限id"`
 }
 
 type ArticleCollectionLIstResp struct {