Browse Source

查研观向9.5

xingzai 2 years ago
parent
commit
cf25ebeeba

+ 47 - 22
controllers/report.go

@@ -422,7 +422,7 @@ func (this *ReportController) ArticleCategoryList() {
 		timeLineRed := false
 		if count < 2 {
 			timeLineRed = true
-		} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)){
+		} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)) {
 			timeLineRed = true
 		}
 		if !timeLineItem.IsRed && timeLineRed && haveMorningMeeting {
@@ -689,7 +689,7 @@ func (this *ReportController) List() {
 			timeLineRed := false
 			if count < 2 && v.SubCategoryName == "时间线" {
 				timeLineRed = true
-			} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishTime)){
+			} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishTime)) {
 				timeLineRed = true
 			}
 			if v.SubCategoryName == "时间线" && timeLineRed {
@@ -2736,6 +2736,17 @@ func (this *ReportController) SearchReportAndResource() {
 	pageSize, _ := this.GetInt("PageSize")
 	var condition string
 	var sqlGroup string
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+		return
+	}
+	if articleTypeIds == "" {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "研选分类ID不能为空"
+		return
+	}
 	//匹配报告标题、
 	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  `
@@ -2744,14 +2755,13 @@ func (this *ReportController) SearchReportAndResource() {
 	} else {
 		sqlGroup += ` LIMIT 100 `
 	}
-	ListYxReport, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+condition+sqlGroup, user.UserId)
+	ListYxReport, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+articleTypeIds+`) `+condition+sqlGroup, user.UserId)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取研选文章列表失败,Err:" + err.Error()
 		return
 	}
-
-	ListHzReport, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+condition+sqlGroup, user.UserId)
+	ListHzReport, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+articleTypeIds+`) `+condition+sqlGroup, user.UserId)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取弘则报告文章列表失败,Err:" + err.Error()
@@ -2777,8 +2787,9 @@ func (this *ReportController) SearchReportAndResource() {
 		} else {
 			sqlGroupIk += ` LIMIT 20 `
 		}
+		conditionIk += ` AND ( a.title NOT LIKE '%` + keyWord + `%' AND  a.body NOT LIKE '%` + keyWord + `%' AND  a.annotation NOT LIKE '%` + keyWord + `%' AND  a.abstract NOT LIKE '%` + keyWord + `%') `
 		//研选的联想词列表
-		ListYxReportIk, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+conditionIk+sqlGroupIk, user.UserId)
+		ListYxReportIk, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
@@ -2790,7 +2801,7 @@ func (this *ReportController) SearchReportAndResource() {
 			}
 		}
 		//弘则的联想词列表
-		ListHzReportIk, err := models.GetReoprtSearchList(`  AND a.article_type_id NOT IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+conditionIk+sqlGroupIk, user.UserId)
+		ListHzReportIk, err := models.GetReoprtSearchList(`  AND a.article_type_id NOT IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
@@ -2883,7 +2894,7 @@ func (this *ReportController) SearchReportAndResource() {
 		}
 	}
 
-	condition = `  AND a.publish_status = 1 AND a.article_type_id NOT IN (` + utils.YAN_XUAN_ARTICLE_TYPE_IDS + `)  AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%'  )  `
+	condition = `  AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `)  AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%'  )  `
 
 	listHzResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
 	if err != nil {
@@ -2892,7 +2903,7 @@ func (this *ReportController) SearchReportAndResource() {
 		return
 	}
 
-	condition = `  AND a.publish_status = 1 AND a.article_type_id IN (` + utils.YAN_XUAN_ARTICLE_TYPE_IDS + `)  AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%'  )  `
+	condition = `  AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `)  AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%'  )  `
 
 	listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
 	if err != nil {
@@ -2910,18 +2921,25 @@ func (this *ReportController) SearchReportAndResource() {
 	industrialIdArr := make([]int, 0)
 	nowTime := time.Now().Local()
 	threeMonBefore := nowTime.AddDate(0, -3, 0)
-	mapHot := make(map[string]int)
+	mapHot := make(map[int]bool)
 
-	hotCondition := ` ORDER BY sum_num DESC  `
-	listHot, err := models.GetThemeHeatList(user.UserId, hotCondition, 0, 3)
+	//if themeType == 2 {
+	mapHot, err = services.GetYanXuanIndustrialManagementIdHotMap(articleTypeIds)
 	if err != nil {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
 		return
 	}
-	for _, v := range listHot {
-		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
-		mapHot[v.IndustryName] = v.IndustrialManagementId
+
+	//conditionOrder := ` ORDER BY sum_num DESC  `
+	//listHot, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, 0, 3)
+	//if err != nil {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+	//	return
+	//}
+	for k, _ := range mapHot {
+		industrialIdArr = append(industrialIdArr, k)
 	}
 	orderSrt := "man.recommended_index DESC,update_time DESC"
 	for k, v := range listHzResource {
@@ -2985,6 +3003,8 @@ func (this *ReportController) SearchReportAndResource() {
 		//	maptimelineUPdateTime := make(map[int]string)
 		listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
 		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "GetTimeLineReportIndustrialPublishdateList,Err:" + err.Error()
 			return
 		}
 		for _, v := range listtimelinePublishdate {
@@ -3013,6 +3033,11 @@ func (this *ReportController) SearchReportAndResource() {
 		}
 		industrialIds = strings.TrimRight(industrialIds, ",")
 		articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "GetReportIndustrialReadNumList,Err:" + err.Error()
+			return
+		}
 		mapHistroyindustrialId := make(map[int]int)
 		for _, v := range articleList {
 			mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
@@ -3025,17 +3050,19 @@ func (this *ReportController) SearchReportAndResource() {
 		//var morningMeetingTime string
 		recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
 		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "GetTimeLineRecordAllCount,Err:" + err.Error()
 			return
 		}
 		var industrialManagementIdstr string
 		industrialIdMap := make(map[string]time.Time)
 		for _, v := range recrodList {
 			industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
-			if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok{
+			if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
 				if createTime.Before(v.CreateTime) {
 					industrialIdMap[industrialManagementIdstr] = v.CreateTime
 				}
-			}else {
+			} else {
 				industrialIdMap[industrialManagementIdstr] = v.CreateTime
 			}
 		}
@@ -3051,7 +3078,7 @@ func (this *ReportController) SearchReportAndResource() {
 		timeLineRedMap := make(map[int]bool, 0)
 
 		for _, industrialId := range industrialIdArr {
-			if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok{
+			if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
 				if createTime.Before(morningMeetingTimeMap[industrialId]) {
 					timeLineRedMap[industrialId] = true
 				}
@@ -3105,9 +3132,7 @@ func (this *ReportController) SearchReportAndResource() {
 				listYxResource[k].IsNew = true
 			}
 		}
-		if mapHot[v.IndustryName] > 0 {
-			listYxResource[k].IsHot = true
-		}
+		listYxResource[k].IsHot = mapHot[v.IndustrialManagementId]
 		listYxResource[k].Source = 2
 		if fllowMap[v.IndustrialManagementId] > 0 {
 			listYxResource[k].IsFollw = true

+ 357 - 135
controllers/research.go

@@ -1,15 +1,17 @@
 package controllers
 
 import (
-	"errors"
+	"encoding/json"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
-//研选
+// 研选
 type ResearchController struct {
 	BaseAuthController
 }
@@ -31,12 +33,21 @@ func (this *ResearchController) NewList() {
 		br.Ret = 408
 		return
 	}
-	//chartPermissionId, _ := this.GetInt("ChartPermissionId")
-	//if chartPermissionId < 1 {
-	//	br.Msg = "请输入分类ID"
-	//	return
-	//}
-	list, err := models.GetIndustrialManagementNewList("")
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+		return
+	}
+	if articleTypeIds == "" {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "研选分类ID不能为空"
+		return
+	}
+	var condition string
+	var conditionOrder string
+	condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
+	list, err := models.GetIndustrialManagementNewList(condition)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -44,8 +55,8 @@ func (this *ResearchController) NewList() {
 	}
 	mapHot := make(map[string]int)
 
-	condition := ` ORDER BY sum_num DESC  `
-	listHot, err := models.GetThemeHeatList(user.UserId, condition, 0, 3)
+	conditionOrder = ` ORDER BY sum_num DESC  `
+	listHot, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, 0, 3)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -84,17 +95,33 @@ func (this *ResearchController) CollectionList() {
 		br.Ret = 408
 		return
 	}
-	//chartPermissionId, _ := this.GetInt("ChartPermissionId")
-	//if chartPermissionId < 1 {
-	//	br.Msg = "请输入分类ID"
-	//	return
-	//}
+
+	pageSize, _ := this.GetInt("PageSize", 15)
 	var condition string
-	condition = `   AND a.article_type_id > 0  AND publish_status = 1 GROUP BY a.article_id ORDER BY collect_num_order DESC, publish_date DESC LIMIT 15 `
-	list, err := models.GetArticleCollectionList(condition, user.UserId)
+	var pars []interface{}
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
 	if err != nil {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+		return
+	}
+	if articleTypeIds != "" {
+		condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
+	} else {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "研选分类ID不能为空"
+		return
+	}
+	// 根据关注时间一个月前至昨日的增量数据排序
+	nowTime := time.Now().Local()
+	startTime := nowTime.AddDate(0, -1, 0)
+	endTime := nowTime.AddDate(0, 0, -1)
+	condition += ` AND ac.create_time BETWEEN ? AND ? `
+	pars = append(pars, startTime, endTime)
+	list, err := models.GetReportCollectionBillboardListYx(pageSize, pars, condition)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取报告阅读增量排行榜失败, Err:" + err.Error()
 		return
 	}
 	for k, v := range list {
@@ -130,11 +157,6 @@ func (this *ResearchController) HotList() {
 		br.Ret = 408
 		return
 	}
-	//chartPermissionId, _ := this.GetInt("ChartPermissionId")
-	//if chartPermissionId < 1 {
-	//	br.Msg = "请输入分类ID"
-	//	return
-	//}
 	themeType, _ := this.GetInt("ThemeType")
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
@@ -147,70 +169,61 @@ func (this *ResearchController) HotList() {
 	}
 	startSize = utils.StartIndex(currentIndex, pageSize)
 	var condition string
-	if themeType != 2 {
-		condition = `ORDER BY sum_num DESC `
+	var conditionOrder string
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+		return
+	}
+	if articleTypeIds == "" {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "研选分类ID不能为空"
+		return
+	}
+	condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
+	if themeType == 2 {
+		conditionOrder = `ORDER BY publish_date DESC  `
 	} else {
-		condition = `ORDER BY publish_date DESC `
+		conditionOrder = `ORDER BY sum_num DESC   `
 	}
 
-	total, err := models.GetThemeHeatListCount("")
+	total, err := models.GetThemeHeatListCount(condition)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-	list, err := models.GetThemeHeatList(user.UserId, condition, startSize, pageSize)
+	list, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-	//newMap := make(map[int]string)
-	//listNew, err := models.GetIndustrialManagementNewList("")
-	//if err != nil {
-	//	br.Msg = "获取信息失败"
-	//	br.ErrMsg = "获取产业最新信息失败,Err:" + err.Error()
-	//	return
-	//}
-	//for _, v := range listNew {
-	//	newMap[v.IndustrialManagementId] = v.IndustryName
-	//}
-	condition = ` AND a.article_type_id > 0  `
 	listSubjcet, err := models.GetThemeHeatSubjectList(condition)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
 		return
 	}
-	mapHot := make(map[string]int)
-
-	condition = ` ORDER BY sum_num DESC `
-	listHot, err := models.GetThemeHeatList(user.UserId, condition, 0, 3)
+	mapHot := make(map[int]bool)
+	mapNew, err := services.GetYanXuanIndustrialManagementIdNewMap(articleTypeIds)
 	if err != nil {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
 		return
 	}
-	for _, v := range listHot {
-		mapHot[v.IndustryName] = v.IndustrialManagementId
+	//if themeType == 2 {
+	mapHot, err = services.GetYanXuanIndustrialManagementIdHotMap(articleTypeIds)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
+		return
 	}
-	nowTime := time.Now().Local()
-	threeMonBefore := nowTime.AddDate(0, -3, 0)
+	//}
 	for k, v := range list {
-		//if newMap[v.IndustrialManagementId] != "" {
-		//	list[k].IsNew = true
-		//}
-		// 关联报告发布时间均在3个月内则标记New
-		if v.MinReportTime != "" {
-			t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
-			if e != nil {
-				err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
-				return
-			}
-			if t.After(threeMonBefore) {
-				list[k].IsNew = true
-			}
-		}
+		list[k].IsNew = mapNew[v.IndustrialManagementId]
+		list[k].IsHot = mapHot[v.IndustrialManagementId]
 		if v.FllowNum > 0 {
 			list[k].IsFollw = true
 		}
@@ -219,9 +232,6 @@ func (this *ResearchController) HotList() {
 				list[k].IndustrialSubjectList = append(list[k].IndustrialSubjectList, v2)
 			}
 		}
-		if mapHot[v.IndustryName] > 0 {
-			list[k].IsHot = true
-		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := new(models.IndustrialManagementHotListResp)
@@ -236,6 +246,9 @@ func (this *ResearchController) HotList() {
 // @Title KOL榜列表
 // @Description KOL榜列表接口
 // @Param   ChartPermissionId   query   int  true       "分类ID"
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   ThemeType   query   int  true       "主题类型,1关注度、2更新时间 "
 // @Success 200 {object} models.DepartmentListResp
 // @router /kolList [get]
 func (this *ResearchController) KolList() {
@@ -250,16 +263,62 @@ func (this *ResearchController) KolList() {
 		br.Ret = 408
 		return
 	}
-	//chartPermissionId, _ := this.GetInt("ChartPermissionId")
-	//if chartPermissionId < 1 {
-	//	br.Msg = "请输入分类ID"
-	//	return
+	themeType, _ := this.GetInt("ThemeType")
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize15
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+		return
+	}
+	if articleTypeIds == "" {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "研选分类ID不能为空"
+		return
+	}
+	var condition string
+	var conditionOrder string
+	condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
+
+	total, err := models.GetDepartmentlistCount(condition)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	if themeType == 2 {
+		conditionOrder = `ORDER BY publish_date DESC  `
+	} else {
+		conditionOrder = `ORDER BY sum_num DESC `
+	}
+	mapHot := make(map[int]bool)
+	//if themeType == 2 {
+	conditionHot := `ORDER BY sum_num DESC `
+	listhot, err := models.GetDepartmentList(condition, conditionHot, user.UserId, 0, 3)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range listhot {
+		mapHot[v.DepartmentId] = true
+	}
 	//}
 
-	list, err := models.GetDepartmentList(user.UserId)
+	list, err := models.GetDepartmentList(condition, conditionOrder, user.UserId, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
 		return
 	}
 	listIndustrial, err := models.GetIndustrialDepartmentList()
@@ -281,8 +340,13 @@ func (this *ResearchController) KolList() {
 				}
 			}
 		}
+		//if themeType == 2 {
+		v.IsHot = mapHot[v.DepartmentId]
+		//}
 	}
 	resp := new(models.DepartmentListResp)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
 	resp.List = list
 	br.Ret = 200
 	br.Success = true
@@ -318,11 +382,22 @@ func (this *ResearchController) ThemeDetail() {
 		source = 1
 	}
 
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+		return
+	}
+	if articleTypeIds == "" {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "研选分类ID不能为空"
+		return
+	}
 	var condition string
 	if source == 1 {
-		condition = `  AND a.category_name LIKE '%研选%' `
+		condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
 	} else {
-		condition = `  AND a.category_name  NOT LIKE '%研选%' `
+		condition = ` AND a.article_type_id  NOT IN (` + articleTypeIds + `)  `
 	}
 	resp := new(models.GetThemeDetailResp)
 	list, err := models.GetThemeDetail(user.UserId, industrialManagementId, condition)
@@ -331,75 +406,52 @@ func (this *ResearchController) ThemeDetail() {
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-
-	var itemsNull []*models.GetThemeAericleListResp
-	subjectMap := make(map[string]string)
-	articleMap := make(map[int]int)
+	var articleIds []int
 	for _, v := range list {
 		resp.IndustryName = v.IndustryName
 		resp.IndustrialManagementId = v.IndustrialManagementId
-		itemSubJect := new(models.IndustrialSubject)
-		itemSubJect.SubjectName = v.SubjectName
-		itemSubJect.IndustrialSubjectId = v.IndustrialSubjectId
-		if subjectMap[v.SubjectName] == "" && v.SubjectName != "" {
-			resp.ListSubject = append(resp.ListSubject, itemSubJect)
-		}
-
-		subjectMap[v.SubjectName] = v.IndustryName
 		if v.FllowNum > 0 {
 			resp.IsFollw = true
 		}
-
-		if v.SubjectName == "" {
-			item := new(models.GetThemeAericleListResp)
-			item.ArticleId = v.ArticleId
-			item.Title = v.Title
-			item.PublishDate = v.PublishDate
-			item.SubjectName = v.SubjectName
-			item.DepartmentId = v.DepartmentId
-			item.NickName = v.NickName
-			item.Pv = v.Pv
-			item.CollectNum = v.CollectNum
-			itemsNull = append(itemsNull, item)
-
-		}
+		articleIds = append(articleIds, v.ArticleId)
 	}
-
-	for _, v := range resp.ListSubject {
-		subjetcGroup := new(models.GetThemeAericleListBuSubjectResp)
-		for _, v2 := range list {
-			if v2.IndustrialSubjectId == v.IndustrialSubjectId && articleMap[v2.ArticleId] == 0 {
-				item := new(models.GetThemeAericleListResp)
-				item.ArticleId = v2.ArticleId
-				item.Title = v2.Title
-				item.PublishDate = v2.PublishDate
-				item.SubjectName = v2.SubjectName
-				item.IndustrialSubjectId = v2.IndustrialSubjectId
-				for _, v3 := range list {
-					if v3.ArticleId == v2.ArticleId && v3.SubjectName != v2.SubjectName && v3.SubjectName != "" {
-						item.SubjectName += "/" + v3.SubjectName
-					}
-				}
-				item.DepartmentId = v2.DepartmentId
-				item.NickName = v2.NickName
-				item.Pv = v2.Pv
-				item.CollectNum = v2.CollectNum
-				item.MyCollectNum = v2.MyCollectNum
-				if v2.MyCollectNum > 0 {
-					item.IsCollect = true
-				}
-				resp.List = append(resp.List, item)
-				articleMap[v2.ArticleId] = v2.ArticleId
-				//subjetcGroup.List = append(subjetcGroup.List, item)
-			}
-			subjetcGroup.SubjectName = v.SubjectName
+	mapArticleSubjectName, subjectMap, err := services.GetArticleSubjectName(articleIds)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	for _, v2 := range list {
+		item := new(models.GetThemeAericleListResp)
+		item.ArticleId = v2.ArticleId
+		item.Title = v2.Title
+		item.PublishDate = v2.PublishDate
+		item.SubjectName = v2.SubjectName
+		item.IndustrialSubjectId = v2.IndustrialSubjectId
+		item.DepartmentId = v2.DepartmentId
+		item.NickName = v2.NickName
+		item.Pv = v2.Pv
+		item.CollectNum = v2.CollectNum
+		item.MyCollectNum = v2.MyCollectNum
+		if v2.MyCollectNum > 0 {
+			item.IsCollect = true
 		}
+		item.SubjectName = mapArticleSubjectName[v2.ArticleId]
+		resp.List = append(resp.List, item)
+	}
 
+	listSub, err := models.GetcygxIndustrialSubject(industrialManagementId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
 	}
-	//当标的为空时进行合并
-	if len(itemsNull) > 0 {
-		for _, v := range itemsNull {
-			resp.List = append(resp.List, v)
+	for _, v := range listSub {
+		itemSubJect := new(models.IndustrialSubject)
+		itemSubJect.SubjectName = v.SubjectName
+		itemSubJect.IndustrialSubjectId = v.IndustrialSubjectId
+		if subjectMap[v.IndustrialSubjectId] != "" {
+			resp.ListSubject = append(resp.ListSubject, itemSubJect)
 		}
 	}
 	br.Ret = 200
@@ -430,8 +482,21 @@ func (this *ResearchController) DepartmentIdDetail() {
 		br.Msg = "请输入作者ID"
 		return
 	}
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+		return
+	}
+	if articleTypeIds == "" {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "研选分类ID不能为空"
+		return
+	}
+	var condition string
+	condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
 	resp := new(models.DepartmentDetailResp)
-	detail, err := models.GetDepartmentDetail(user.UserId, departmentId)
+	detail, err := models.GetDepartmentDetail(user.UserId, departmentId, condition)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取作者信息失败,Err:" + err.Error()
@@ -446,8 +511,7 @@ func (this *ResearchController) DepartmentIdDetail() {
 	if detail.MyFllowNum > 0 {
 		resp.IsFllow = true
 	}
-	var condition string
-	condition = `  AND a.department_id = ` + strconv.Itoa(departmentId) + ` ORDER BY a.publish_date DESC  `
+	condition += `  AND a.department_id = ` + strconv.Itoa(departmentId) + `  GROUP BY a.article_id  ORDER BY a.publish_date DESC  `
 	list, err := models.GetArticleCollectionList(condition, user.UserId)
 	if err != nil {
 		br.Msg = "获取信息失败"
@@ -548,3 +612,161 @@ func (this *ResearchController) HotKeyWord() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 研选文章类型列表
+// @Description 研选文章类型列表接口
+// @Success 200 {object} models.CygxArticleTypeListResp
+// @router /article/typeList [get]
+func (this *ResearchController) ArticleType() {
+	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
+	}
+	key := utils.YAN_XUAN_TAB_KEY
+	conf, e := models.GetConfigByCode(key)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取首页头部导航失败, Err: " + e.Error()
+		return
+	}
+	if conf.ConfigValue == "" {
+		br.Msg = "获取失败"
+		br.ErrMsg = "首页头部导航配置值有误"
+		return
+	}
+	list := new(models.CygxArticleTypeListResp)
+	if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "首页头部导航配置值解析失败, Err: " + e.Error()
+		return
+	}
+	resp := new(models.CygxArticleTypeListResp)
+	resp = list
+	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   ArticleTypeIds   query   array  true       "文章类型ID多个用  , 隔开"
+// @Success 200 {object} models.IndustrialManagementNewList
+// @router /article/newList [get]
+func (this *ResearchController) ArticleNewList() {
+	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
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	articleTypeIds := this.GetString("ArticleTypeIds")
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+	var condition string
+	var conditiontype string
+	var pars []interface{}
+	condition = `    AND publish_status = 1  `
+	if articleTypeIds == "" {
+		conditiontype = " AND is_show_yanx  = 1 "
+	} else {
+		conditiontype = ` AND   group_id IN  (` + articleTypeIds + `) `
+	}
+	listType, err := models.GetCygxArticleTypeListCondition(conditiontype)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	articleTypeIds = ""
+	for _, v := range listType {
+		articleTypeIds += strconv.Itoa(v.ArticleTypeId) + ","
+	}
+	articleTypeIds = strings.TrimRight(articleTypeIds, ",")
+	condition += `   AND a.article_type_id IN (` + articleTypeIds + `) `
+	total, err := models.GetArticleResearchCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetArticleResearchCount,Err:" + err.Error()
+		return
+	}
+	list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	var articleIds []int
+	for k, v := range list {
+		if v.MyCollectNum > 0 {
+			list[k].IsCollect = true
+		}
+		articleIds = append(articleIds, v.ArticleId)
+	}
+	//处理关联的产业
+	industrialMap, err := services.GetArticleIndustrialByArticleId(articleIds)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取关联的产业信息失败,GetArticleIndustrialByArticleId Err:" + err.Error()
+		return
+	}
+	for k, v := range list {
+		if len(industrialMap[v.ArticleId]) > 0 {
+			list[k].List = industrialMap[v.ArticleId]
+		} else {
+			list[k].List = make([]*models.IndustrialManagementResp, 0)
+		}
+	}
+	//处理对应的文章类型标签按钮
+	nameMap, styleMap, err := services.GetArticleTypeMap()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
+		return
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.ArticleResearchListResp)
+	for _, v := range list {
+		item := models.ArticleResearchResp{
+			ArticleId:       v.ArticleId,
+			Title:           v.Title,
+			PublishDate:     v.PublishDate,
+			DepartmentId:    v.DepartmentId,
+			NickName:        v.NickName,
+			IsCollect:       v.IsCollect,
+			Pv:              v.Pv,
+			CollectNum:      v.CollectNum,
+			ArticleTypeName: nameMap[v.ArticleTypeId],
+			ButtonStyle:     styleMap[v.ArticleTypeId],
+			List:            v.List,
+		}
+		resp.List = append(resp.List, &item)
+	}
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 22 - 3
models/article_type.go

@@ -17,9 +17,20 @@ type CygxArticleType struct {
 	IcoLink            string    `description:"图标链接地址"`
 	IcoLinkM           string    `description:"移动端图标链接地址"`
 	IsShowLinkButton   int       `description:"这种报告类型是否展示查看报告链接"`
+	ButtonStyle        string    `description:"按钮展示样式"`
 }
 
-//详情
+type CygxArticleTypeResp struct {
+	ArticleTypeId   int    `description:"文章类型ID"`
+	ArticleTypeName string `description:"类型名称"`
+	ButtonStyle     string `description:"按钮展示样式"`
+}
+
+type CygxArticleTypeListResp struct {
+	List []*CygxArticleTypeResp
+}
+
+// 详情
 func GetCygxArticleTypeDetailById(activityTypeId int) (item *CygxArticleType, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_article_type WHERE article_type_id = ? `
@@ -27,7 +38,7 @@ func GetCygxArticleTypeDetailById(activityTypeId int) (item *CygxArticleType, er
 	return
 }
 
-//获取数量
+// 获取数量
 func GetCygxArticleTypeCount(condition string) (count int, err error) {
 	o := orm.NewOrm()
 	sqlCount := `SELECT COUNT(1) AS count  FROM cygx_article_type WHERE  1=1 ` + condition
@@ -35,7 +46,7 @@ func GetCygxArticleTypeCount(condition string) (count int, err error) {
 	return
 }
 
-//报告类型列表
+// 报告类型列表
 func GetCygxArticleTypeList() (items []*CygxArticleType, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_article_type ORDER BY sort DESC`
@@ -43,6 +54,14 @@ func GetCygxArticleTypeList() (items []*CygxArticleType, err error) {
 	return
 }
 
+// 报告类型列表
+func GetCygxArticleTypeListCondition(condition string) (items []*CygxArticleType, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article_type   WHERE  1=1 ` + condition + ` ORDER BY sort DESC`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 func GetArticleTypeInfo(activityTypeId int) (item *CygxArticleType, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_article_type   WHERE  article_type_id=? `

+ 22 - 1
models/industrial_article_group_subject.go

@@ -13,7 +13,13 @@ type CygxIndustrialArticleGroupSubject struct {
 	CreateTime          time.Time `description:"创建时间"`
 }
 
-//列表
+type SubjectArticlGroupList struct {
+	SubjectName         string `description:"标的名称"`
+	ArticleId           int    `description:"cygx_article表的文章ID"`
+	IndustrialSubjectId int    `description:"cygx_industrial_subject表的文章ID"`
+}
+
+// 列表
 func GetSubjectArticleGroupManagementList(condition string, pars []interface{}) (items []*CygxIndustrialArticleGroupSubject, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -25,3 +31,18 @@ func GetSubjectArticleGroupManagementList(condition string, pars []interface{})
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// 列表
+func GetSubjectArticlGroupList(condition string, pars []interface{}) (items []*SubjectArticlGroupList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			 s.subject_name,
+			 s.industrial_subject_id,
+			 ag.article_id
+		FROM
+			cygx_industrial_article_group_subject AS ag
+			INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = ag.industrial_subject_id
+			WHERE 1= 1  ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 36 - 33
models/industrial_management.go

@@ -25,7 +25,7 @@ type IndustrialManagementCount struct {
 	IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
 }
 
-//获取产业置顶数量分类列表
+// 获取产业置顶数量分类列表
 func GetIndustrialManagemenCountTop(sqlChartPermissionId string, uid int, condition string) (items []*IndustrialManagementCount, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -41,7 +41,7 @@ func GetIndustrialManagemenCountTop(sqlChartPermissionId string, uid int, condit
 	return
 }
 
-//获取产业不置顶数量
+// 获取产业不置顶数量
 func GetIndustrialManagemenCountNoTop(sqlChartPermissionId string, uid int, condition string) (items []*IndustrialManagementCount, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -57,7 +57,7 @@ func GetIndustrialManagemenCountNoTop(sqlChartPermissionId string, uid int, cond
 	return
 }
 
-//产业列表
+// 产业列表
 func GetIndustrialManagementAll(uid int, condition, orderSrt string, startSize, pageSize int) (items []*IndustrialManagement, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -83,7 +83,7 @@ func GetIndustrialManagementAll(uid int, condition, orderSrt string, startSize,
 	return
 }
 
-//产业列表
+// 产业列表
 func GetIndustrialManagementAllCount(condition string) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -105,7 +105,7 @@ func GetIndustrialManagementAllCount(condition string) (count int, err error) {
 	return
 }
 
-//产业列表 -置顶
+// 产业列表 -置顶
 func GetIndustrialManagementTopAll(uid int, condition string, startSize, pageSize int) (items []*IndustrialManagement, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -130,7 +130,7 @@ func GetIndustrialManagementTopAll(uid int, condition string, startSize, pageSiz
 	return
 }
 
-//标的列表
+// 标的列表
 func GetIndustrialSubjectAll(IndustrialManagementId int) (items []*IndustrialSubject, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_industrial_subject WHERE industrial_management_id = ? `
@@ -138,7 +138,7 @@ func GetIndustrialSubjectAll(IndustrialManagementId int) (items []*IndustrialSub
 	return
 }
 
-//标的列表
+// 标的列表
 func GetIndustrialSubjectAllByIndustrialId(industrialIdArr []int) (items []*IndustrialSubject, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_industrial_subject WHERE industrial_management_id IN  (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)   `
@@ -146,7 +146,7 @@ func GetIndustrialSubjectAllByIndustrialId(industrialIdArr []int) (items []*Indu
 	return
 }
 
-//分析师列表
+// 分析师列表
 func GetIndustrialAnalystAll(IndustrialManagementId int) (items []*IndustrialAnalyst, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_industrial_analyst where industrial_management_id = ? `
@@ -154,7 +154,7 @@ func GetIndustrialAnalystAll(IndustrialManagementId int) (items []*IndustrialAna
 	return
 }
 
-//获取产业数量
+// 获取产业数量
 func GetIndustrialManagementCount(IndustrialManagementId int) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_industrial_management WHERE industrial_management_id=? `
 	o := orm.NewOrm()
@@ -169,7 +169,7 @@ func GetIndustrialManagementDetail(industrialManagementId int) (items *Industria
 	return
 }
 
-//获取该产业下最新的文章详情
+// 获取该产业下最新的文章详情
 func GetIndustrialNewArticleDetail(industrialManagementId int) (item *ArticleDetail, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -194,7 +194,7 @@ func GetIndustrialNewArticleDetail(industrialManagementId int) (item *ArticleDet
 	return
 }
 
-//修改产业是否属于新标签
+// 修改产业是否属于新标签
 func UpdateIndustrialIsNewLabel() (err error) {
 	o := orm.NewOrm()
 	resultTime := time.Now().AddDate(0, -2, 0).Format(utils.FormatDateTime)
@@ -209,7 +209,7 @@ type IndustrialManagementId struct {
 	IndustrialManagementId string `description:"产业Id"`
 }
 
-//获取归类产业报告数量大于10的
+// 获取归类产业报告数量大于10的
 func GetIndustrialMorethan10() (items []*IndustrialManagementId, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM
@@ -219,7 +219,7 @@ func GetIndustrialMorethan10() (items []*IndustrialManagementId, err error) {
 	return
 }
 
-//修改产业是否属于深度标签
+// 修改产业是否属于深度标签
 func UpdateIndustrialIsDeepLabel(idStr string) (err error) {
 	o := orm.NewOrm()
 	msql := `UPDATE cygx_industrial_management
@@ -266,7 +266,7 @@ type IndustrialManagementIdName struct {
 	IsReport     string `description:"1观点,0纪要"`
 }
 
-//获取归类产业报告数量大于10的
+// 获取归类产业报告数量大于10的
 func GetIndustrialManagementIds() (items []*IndustrialManagementIdInt, err error) {
 	o := orm.NewOrm()
 	//sql := `SELECT a.industrial_management_id FROM
@@ -282,12 +282,12 @@ func GetIndustrialManagementIds() (items []*IndustrialManagementIdInt, err error
 
 func GetcygxIndustrialSubject(industrialManagementId int) (items []*IndustrialSubject, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT subject_name FROM cygx_industrial_subject  WHERE industrial_management_id = ?`
+	sql := `SELECT subject_name,industrial_subject_id FROM cygx_industrial_subject  WHERE industrial_management_id = ?`
 	_, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
 	return
 }
 
-//通过名称获取
+// 通过名称获取
 func GetcygxIndustrialSubjectByName(name string) (industrial_management_id string, err error) {
 	o := orm.NewOrm()
 	sql := `	SELECT industrial_subject_id FROM cygx_industrial_subject  WHERE subject_name = ?`
@@ -327,7 +327,7 @@ func UpdateIndustrialManagementArtReadNum(num, industrialManagementId int) (err
 	return
 }
 
-//更新产业布局时间
+// 更新产业布局时间
 func UpdateIndustrialManagementLayoutTime(layoutTime string, industrialManagementId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_industrial_management SET layout_time = ? WHERE industrial_management_id = ?`
@@ -335,7 +335,7 @@ func UpdateIndustrialManagementLayoutTime(layoutTime string, industrialManagemen
 	return
 }
 
-//获取产业下阅读数量第三的产业详情
+// 获取产业下阅读数量第三的产业详情
 func GetIndustrialManagementHot3(chartPermissionId int) (item *IndustrialManagementRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_industrial_management WHERE chart_permission_id = ? ORDER BY article_read_num DESC LIMIT 2,1`
@@ -343,7 +343,7 @@ func GetIndustrialManagementHot3(chartPermissionId int) (item *IndustrialManagem
 	return
 }
 
-//获取产业关联标的的数量
+// 获取产业关联标的的数量
 func GetIndustrialManagementSubjectCount(industrialManagementId int) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count FROM
 				cygx_industrial_subject AS s 
@@ -356,7 +356,7 @@ func GetIndustrialManagementSubjectCount(industrialManagementId int) (count int,
 	return
 }
 
-//获取产业关联标的列表
+// 获取产业关联标的列表
 func GetIndustrialManagementSubjectList(articleId int) (items []*IndustrialSubject, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -388,7 +388,7 @@ type IndustrialManagementNewList struct {
 	List []*IndustrialManagementNewResp
 }
 
-//近期更新主题列表
+// 近期更新主题列表
 func GetIndustrialManagementNewList(condition string) (items []*IndustrialManagementNewResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -412,7 +412,7 @@ func GetIndustrialManagementNewList(condition string) (items []*IndustrialManage
 	return
 }
 
-//获取产业关联标的列表
+// 获取产业关联标的列表
 func GetIndustrialManagementForSubjecName(subjectName string, chartPermissionId int) (items []*IndustrialSubject, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT s.subject_name,s.industrial_subject_id,m.industrial_management_id,m.industry_name,layout_time
@@ -423,7 +423,7 @@ func GetIndustrialManagementForSubjecName(subjectName string, chartPermissionId
 	return
 }
 
-//报告分类的新增与修改
+// 报告分类的新增与修改
 func ReportArticleClassificationEditNew(reportId int, industrialManagementIdStr string, articleId int, ndustrialSubjectIdStr string) (err error) {
 	to, err := orm.NewOrm().Begin()
 	if err != nil {
@@ -479,7 +479,7 @@ func ReportArticleClassificationEditNew(reportId int, industrialManagementIdStr
 	return
 }
 
-//通过标的名称获取相关联的活动ID
+// 通过标的名称获取相关联的活动ID
 func GetActivityIdListBySubjecName(subjectName string) (items []*ActivityIdRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT  * FROM cygx_industrial_activity_group_subject WHERE industrial_subject_id	 IN (SELECT industrial_subject_id FROM cygx_industrial_subject WHERE subject_name IN(` + subjectName + `) ) GROUP BY activity_id`
@@ -487,7 +487,7 @@ func GetActivityIdListBySubjecName(subjectName string) (items []*ActivityIdRep,
 	return
 }
 
-//产业关注榜
+// 产业关注榜
 func GetIndustrialManagementFllowBillboard(pars []interface{}, condition, orderSrt string, startSize, pageSize int) (items []*IndustrialManagement, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -507,7 +507,7 @@ func GetIndustrialManagementFllowBillboard(pars []interface{}, condition, orderS
 	return
 }
 
-//获取标的列表
+// 获取标的列表
 func GetSubjectList(pars []interface{}, condition string) (items []*IndustrialManagementIdInt, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -524,7 +524,7 @@ func GetSubjectList(pars []interface{}, condition string) (items []*IndustrialMa
 	return
 }
 
-//获取标的列表
+// 获取标的列表
 func GetIndustrialListByarticleId(pars []interface{}, condition string) (items []*IndustrialManagementIdInt, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -540,7 +540,7 @@ func GetIndustrialListByarticleId(pars []interface{}, condition string) (items [
 	return
 }
 
-//修改产业关注数量
+// 修改产业关注数量
 func UpdateIndustrialManagementFllowNum(num, industrialManagementId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_industrial_management SET user_fllow_num = ? WHERE industrial_management_id = ?`
@@ -548,7 +548,7 @@ func UpdateIndustrialManagementFllowNum(num, industrialManagementId int) (err er
 	return
 }
 
-//通过id 获取详情
+// 通过id 获取详情
 func GetIndustrialManagemenDetailByAaticleID(articleId int) (items []*IndustrialManagementRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -564,7 +564,7 @@ func GetIndustrialManagemenDetailByAaticleID(articleId int) (items []*Industrial
 	return
 }
 
-//获取所有的产业
+// 获取所有的产业
 func GetindustrialManagement() (items []*IndustrialManagementRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -638,8 +638,11 @@ type IndustrialManagementArticle struct {
 	PublishDate            string `description:"发布时间"`
 }
 
-//时间线的更新时间
+// 时间线的更新时间
 func GetTimeLineReportIndustrialPublishdateList(industrialIdArr []int) (items []*IndustrialManagementArticle, err error) {
+	if len(industrialIdArr) == 0 {
+		return
+	}
 	o := orm.NewOrm()
 	sql := `SELECT	
 			mmc.id,
@@ -659,7 +662,7 @@ func GetTimeLineReportIndustrialPublishdateList(industrialIdArr []int) (items []
 	return
 }
 
-//获取该产业下最新的文章详情
+// 获取该产业下最新的文章详情
 func GetNewArticleDetailByIndustrialIds(industrialIdArr []int) (items []*IndustrialManagementArticle, err error) {
 	arrLen := len(industrialIdArr)
 	if arrLen == 0 {
@@ -685,7 +688,7 @@ func GetNewArticleDetailByIndustrialIds(industrialIdArr []int) (items []*Industr
 	return
 }
 
-//GetIndustrialManagementArticleNewPublishData 获取产业关联文章的最新发布时间
+// GetIndustrialManagementArticleNewPublishData 获取产业关联文章的最新发布时间
 func GetIndustrialManagementArticleNewPublishData() (items []*IndustrialManagement, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT

+ 174 - 58
models/report.go

@@ -5,7 +5,6 @@ import (
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"strconv"
 	"time"
-
 	//"github.com/rdlucklib/rdluck_tools/paging"
 )
 
@@ -64,7 +63,7 @@ type IndustrialSubject struct {
 	LayoutTime             string `description:"产业布局时间"`
 }
 
-//获取产业报告数量
+// 获取产业报告数量
 func GetReportIndustrialCount(categoryId, industrialManagementId int) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT COUNT(1) count 
@@ -86,7 +85,7 @@ WHERE
 	return
 }
 
-//获取产业报告列表
+// 获取产业报告列表
 func GetReportIndustrialList(pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*ReportArticle, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT *,( SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.article_id = a.article_id ) AS readnum 
@@ -109,7 +108,7 @@ WHERE
 	return
 }
 
-//产业下所关联的文章分类列表
+// 产业下所关联的文章分类列表
 func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int) (items []*IndustrialToArticleCategoryRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT map.match_type_name,map.category_id
@@ -127,7 +126,7 @@ func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int)
 	return
 }
 
-//产业下所关联的文章分类列表 2022-10-13
+// 产业下所关联的文章分类列表 2022-10-13
 func IndustrialToArticleCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT map.match_type_name,map.category_id
@@ -144,7 +143,7 @@ func IndustrialToArticleCategoryNew(industrialManagementId int) (items []*Indust
 	return
 }
 
-//判断用户是否阅读该产业下,某一分类的文章
+// 判断用户是否阅读该产业下,某一分类的文章
 func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -164,7 +163,7 @@ WHERE
 	return
 }
 
-//获取最新文章
+// 获取最新文章
 func GetNewIndustrialUserRecordArticle(industrialManagementId, categoryId int) (item *ArticleDetail, err error) {
 	o := orm.NewOrm()
 	//sql := ` SELECT * FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ORDER BY publish_date DESC LIMIT 0, 1`
@@ -179,7 +178,7 @@ WHERE
 	return
 }
 
-//获取最新文章
+// 获取最新文章
 func GetNewArticleByCategoryId(categoryId int) (item *ArticleDetail, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT * FROM cygx_article WHERE  category_id = ? ORDER BY publish_date DESC LIMIT 0, 1`
@@ -216,7 +215,7 @@ type ReportArticleWhichIndustrialRepList struct {
 	List         []*ReportArticleWhichIndustrial
 }
 
-//列表
+// 列表
 func IndustrialToArticleWhichDepartment(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*ReportArticleWhichIndustrial, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -275,7 +274,7 @@ type SearchTxt struct {
 	TabSearch      string `description:"素材库搜索说明"`
 }
 
-//获取用户是否有查看权限
+// 获取用户是否有查看权限
 func GetUserIsAdminCount(mobile string) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT COUNT(1) count  FROM admin 
@@ -331,7 +330,7 @@ type CygxIndustrySearchListPc struct {
 	IndList        []*IndustrialManagement `description:"产业列表"`
 }
 
-//列表
+// 列表
 func GetCygxIndustryAndArticleList(keyWord string) (items []*CygxIndustryAndArticleList, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -362,7 +361,7 @@ func GetArticleIdsBySubId(subjectId string) (articleIds string, err error) {
 	return
 } //end
 
-//用户收藏榜start
+// 用户收藏榜start
 type ArticleCollectionResp struct {
 	ArticleId              int                         `description:"文章id"`
 	Title                  string                      `description:"标题"`
@@ -376,6 +375,7 @@ type ArticleCollectionResp struct {
 	Pv                     int                         `description:"PV"`
 	CollectNum             int                         `description:"收藏人数"`
 	Source                 int                         `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	ArticleTypeId          int                         `description:"文章类型ID"`
 	List                   []*IndustrialManagementResp `description:"产业列表"`
 }
 
@@ -389,7 +389,43 @@ type ArticleCollectionLIstResp struct {
 	List []*ArticleCollectionResp
 }
 
-//列表
+// 研选报告收藏榜单列表
+func GetReportCollectionBillboardListYx(limit int, pars []interface{}, condition string) (items []*ArticleCollectionResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			ac.id,
+			a.category_id,
+			a.article_id,
+			a.title,
+			a.body,
+			a.annotation,
+			a.abstract,
+			a.publish_date,
+			a.article_type_id,
+			d.nick_name,
+			d.department_id,
+			( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id  ) AS collect_num, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collection_num
+		FROM
+			cygx_article AS a
+			INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id 
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
+			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id 
+		WHERE
+			1 = 1 
+			AND a.publish_status = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY a.article_id ORDER BY collection_num DESC,  a.publish_date DESC`
+	sql += ` LIMIT ?`
+	_, err = o.Raw(sql, pars, limit).QueryRows(&items)
+	return
+}
+
+// 列表
 func GetArticleCollectionList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -418,7 +454,67 @@ func GetArticleCollectionList(condition string, userId int) (items []*ArticleCol
 	return
 } //end
 
-//用户收藏榜start
+type ArticleResearchListResp struct {
+	Paging *paging.PagingItem
+	List   []*ArticleResearchResp
+}
+
+type ArticleResearchResp struct {
+	ArticleId       int                         `description:"文章id"`
+	Title           string                      `description:"标题"`
+	PublishDate     string                      `description:"发布时间"`
+	DepartmentId    int                         `description:"作者Id"`
+	NickName        string                      `description:"作者昵称"`
+	IsCollect       bool                        `description:"本人是否收藏"`
+	Pv              int                         `description:"PV"`
+	CollectNum      int                         `description:"收藏人数"`
+	Source          int                         `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	ArticleTypeId   int                         `description:"文章类型ID"`
+	ArticleTypeName string                      `description:"类型名称"`
+	ButtonStyle     string                      `description:"按钮展示样式"`
+	List            []*IndustrialManagementResp `description:"产业列表"`
+}
+
+// 获取我的日程数量
+func GetArticleResearchCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := `SELECT COUNT( 1 ) AS count FROM
+			cygx_article AS a
+		WHERE
+			1 = 1  AND a.publish_status = 1` + condition
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int) (items []*ArticleCollectionResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			a.article_id,
+			a.title,
+			date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
+			a.article_type_id,
+			d.nick_name,
+			d.department_id,
+			( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id  ) AS collect_num, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collect_num_order, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id  AND user_id = ? ) AS my_collect_num
+		FROM
+			cygx_article AS a
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
+			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id 
+		WHERE
+			1 = 1  AND a.publish_status = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY a.article_id ORDER  BY   a.publish_date DESC  LIMIT ?,? `
+	_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+// 用户收藏榜start
 type IndustrialManagementHotResp struct {
 	IndustrialManagementId int                   `orm:"column(industrial_management_id);pk" description:"产业id"`
 	IndustryName           string                `description:"产业名称"`
@@ -442,8 +538,8 @@ type IndustrialManagementHotListResp struct {
 	List   []*IndustrialManagementHotResp
 }
 
-//产业列表
-func GetThemeHeatList(userId int, condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
+// 产业列表
+func GetThemeHeatList(userId int, condition, conditionOrder string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			m.industry_name,
@@ -452,7 +548,7 @@ func GetThemeHeatList(userId int, condition string, startSize, pageSize int) (it
           	MAX( a.publish_date ) AS publish_date,
 			MIN(a.publish_date) AS min_report_time,
 			( SELECT count( 1 ) FROM cygx_industry_fllow AS f  WHERE f.industrial_management_id = m.industrial_management_id  AND user_id =? AND f.type = 1  ) AS fllow_num,
-			m.article_read_num + ( SELECT count( 1 ) FROM cygx_activity_meet_detail_log AS la  WHERE la.activity_id  IN  (SELECT activity_id FROM cygx_industrial_activity_group_management WHERE industrial_management_id = m.industrial_management_id  ) AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( la.activity_time ) ) AS sum_num
+			( SELECT count( 1 ) FROM cygx_industry_fllow AS f  WHERE f.industrial_management_id = m.industrial_management_id  AND f.type = 1  ) AS sum_num
 		FROM
 			cygx_industrial_management AS m
 			LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
@@ -460,14 +556,12 @@ func GetThemeHeatList(userId int, condition string, startSize, pageSize int) (it
 			LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
 		WHERE
 			1 = 1
-			AND a.article_type_id > 0
-			AND publish_status = 1 
-			GROUP BY m.industrial_management_id ` + condition + ` LIMIT ?,?`
+			AND publish_status = 1  ` + condition + `  GROUP BY m.industrial_management_id ` + conditionOrder + ` , last_updated_time  DESC LIMIT ?,?`
 	_, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
 	return
 }
 
-//获取数量
+// 获取数量
 func GetThemeHeatListCount(condition string) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT   COUNT( DISTINCT m.industrial_management_id ) FROM
@@ -477,12 +571,12 @@ func GetThemeHeatListCount(condition string) (count int, err error) {
 			LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
 		WHERE
 			1 = 1
-			AND a.article_type_id > 0 AND a.publish_status = 1  ` + condition
+            AND a.publish_status = 1  ` + condition
 	err = o.Raw(sql).QueryRow(&count)
 	return
 }
 
-//标的列表
+// 标的列表
 func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -507,18 +601,20 @@ func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err
 	return
 } //end
 
-//Kol sratr
+// Kol sratr
 type DepartmentResp struct {
 	DepartmentId int    `description:"作者Id"`
 	NickName     string `description:"作者昵称"`
 	ImgUrl       string `description:"图片链接"`
 	IsFollw      bool   `description:"是否关注"`
+	IsHot        bool   `description:"是否关注"`
 	FllowNum     int    `description:"关注数量"`
 	List         []*IndustrialDepartmentListResp
 }
 
 type DepartmentListResp struct {
-	List []*DepartmentResp
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*DepartmentResp
 }
 type IndustrialDepartmentListResp struct {
 	IndustrialManagementId int    `description:"产业Id"`
@@ -526,32 +622,52 @@ type IndustrialDepartmentListResp struct {
 	DepartmentId           int    `description:"作者Id"`
 }
 
-//作者列表
-func GetDepartmentList(userId int) (items []*DepartmentResp, err error) {
+// 作者列表
+func GetDepartmentList(condition, conditionOrder string, userId, startSize, pageSize int) (items []*DepartmentResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			d.nick_name,
 			d.department_id,
 			d.img_url,
+			MAX( a.publish_date ) AS publish_date,
 			( SELECT count( 1 ) FROM cygx_article_department_follow AS f  WHERE f.department_id = d.department_id  AND user_id =?  AND f.type= 1  ) AS fllow_num,
-			( SELECT count( 1 ) FROM cygx_article_department_follow  AS f INNER JOIN wx_user AS u ON u.user_id = f.user_id  WHERE f.department_id = d.department_id AND f.type= 1 ) +( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user AS u ON u.user_id = ac.user_id  WHERE ac.article_id IN (SELECT article_id FROM cygx_article WHERE department_id = d.department_id ) 	AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS sum_num
+			( SELECT count( 1 ) FROM cygx_article_department_follow AS f  WHERE f.department_id = d.department_id  AND  f.type= 1  ) AS sum_num
 		FROM
 		cygx_article_department AS d
 			INNER JOIN cygx_article AS a ON d.department_id = a.department_id
 		WHERE
 			1 = 1
-			AND a.article_type_id > 0 
-			AND publish_status = 1 
+			AND publish_status = 1  ` + condition + `
 		GROUP BY
-				d.department_id
-		ORDER BY
-			sum_num DESC
-			LIMIT 15`
-	_, err = o.Raw(sql, userId).QueryRows(&items)
+				d.department_id ` + conditionOrder + ` , last_updated_time  DESC LIMIT ?,?`
+	_, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+// 获取数量
+func GetDepartmentlistCount(condition string) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	count(*) AS count 
+FROM
+	(
+	SELECT
+		COUNT( 1 ) AS count 
+	FROM
+		cygx_article_department AS d
+		INNER JOIN cygx_article AS a ON d.department_id = a.department_id 
+	WHERE
+		1 = 1 
+		AND a.article_type_id > 0 
+		AND publish_status = 1 
+	GROUP BY
+	d.department_id 
+	) c `
+	err = o.Raw(sql).QueryRow(&count)
 	return
 }
 
-//作者文章所关联的产业列表
+// 作者文章所关联的产业列表
 func GetIndustrialDepartmentList() (items []*IndustrialDepartmentListResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -575,7 +691,7 @@ func GetIndustrialDepartmentList() (items []*IndustrialDepartmentListResp, err e
 	return
 }
 
-//主题详情start
+// 主题详情start
 type GetThemeDetailListResp struct {
 	ArticleId              int    `description:"文章id"`
 	Title                  string `description:"标题"`
@@ -613,7 +729,7 @@ type GetThemeAericleListBuSubjectResp struct {
 	List        []*GetThemeAericleListResp
 }
 
-//主题详情start
+// 主题详情start
 type GetThemeDetailResp struct {
 	IndustrialManagementId int                  `description:"产业Id"`
 	IndustryName           string               `description:"产业名称"`
@@ -622,7 +738,7 @@ type GetThemeDetailResp struct {
 	List                   []*GetThemeAericleListResp
 }
 
-//列表
+// 列表
 func GetThemeDetail(userId, industrialManagementId int, condition string) (items []*GetThemeDetailListResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -649,14 +765,14 @@ func GetThemeDetail(userId, industrialManagementId int, condition string) (items
 		WHERE
 			1 = 1
 			AND m.industrial_management_id = ? 
-			AND publish_status = 1 ` + condition + `
+			AND publish_status = 1 ` + condition + ` GROUP BY article_id
 		ORDER BY
 			publish_date DESC`
 	_, err = o.Raw(sql, userId, userId, industrialManagementId).QueryRows(&items)
 	return
 } //end
 
-//用户收藏榜start
+// 用户收藏榜start
 type DepartmentDetailResp struct {
 	DepartmentId   int    `description:"作者Id"`
 	NickName       string `description:"作者昵称"`
@@ -680,8 +796,8 @@ type DepartmentDetail struct {
 	MyFllowNum   int    `description:"本人是否关注"`
 }
 
-//列表
-func GetDepartmentDetail(userId, departmentId int) (item DepartmentDetail, err error) {
+// 列表
+func GetDepartmentDetail(userId, departmentId int, condition string) (item DepartmentDetail, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			d.department_id,
@@ -689,8 +805,8 @@ func GetDepartmentDetail(userId, departmentId int) (item DepartmentDetail, err e
 			d.img_url,
 			( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.user_id = ? AND af.department_id = d.department_id AND af.type= 1 ) AS my_fllow_num,
 			( SELECT count( 1 ) FROM cygx_article_department_follow AS f INNER JOIN wx_user as u ON  u.user_id = f.user_id   WHERE f.department_id = d.department_id  AND f.type= 1 ) AS fllow_num,
-			( SELECT count( 1 ) FROM cygx_article AS a WHERE a.department_id = d.department_id  ) AS article_num,
-			( SELECT count( 1 ) FROM cygx_article_collect  AS c INNER JOIN wx_user as u ON  u.user_id = c.user_id   WHERE c.article_id IN (SELECT  article_id FROM cygx_article AS a WHERE a.department_id = d.department_id )) AS collect_num
+			( SELECT count( 1 ) FROM cygx_article AS a WHERE a.department_id = d.department_id ` + condition + `  ) AS article_num,
+			( SELECT count( 1 ) FROM cygx_article_collect  AS c INNER JOIN wx_user as u ON  u.user_id = c.user_id   WHERE c.article_id IN (SELECT  article_id FROM cygx_article AS a WHERE a.department_id = d.department_id  ` + condition + ` )) AS collect_num
 		FROM
 			cygx_article_department AS d 
 		WHERE
@@ -699,13 +815,13 @@ func GetDepartmentDetail(userId, departmentId int) (item DepartmentDetail, err e
 	return
 } //end
 
-//报告搜索start
+// 报告搜索start
 type ReoprtSearchResp struct {
 	ListYx []*ArticleCollectionResp `description:"研选报告"`
 	ListHz []*ArticleCollectionResp `description:"弘则报告"`
 }
 
-//列表
+// 列表
 func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -730,13 +846,13 @@ func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollecti
 	return
 } //end
 
-//搜索资源包 start
+// 搜索资源包 start
 type SearchResourceResp struct {
 	ListHz []*IndustrialManagementHotResp `description:"弘则"`
 	ListYx []*IndustrialManagementHotResp `description:"研选"`
 }
 
-//搜索资源包 start
+// 搜索资源包 start
 type SearchReportAndResourceResp struct {
 	ListHzResource []*IndustrialManagementHotResp `description:"弘则资源包"`
 	ListYxResource []*IndustrialManagementHotResp `description:"研选资源包"`
@@ -744,7 +860,7 @@ type SearchReportAndResourceResp struct {
 	ListHzReport   []*ArticleCollectionResp       `description:"弘则报告"`
 }
 
-//产业列表
+// 产业列表
 func GetSearchResourceList(userId int, condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -769,19 +885,19 @@ func GetSearchResourceList(userId int, condition string, startSize, pageSize int
 	return
 }
 
-//切换列表
+// 切换列表
 type ReportBillboardTableResp struct {
 	Name   string `description:"名称"`
 	Source int    `description:"类型"`
 	List   []*ChartPermission
 }
 
-//切换列表
+// 切换列表
 type ReportBillboardTableListResp struct {
 	List []*ReportBillboardTableResp
 }
 
-//报告榜单start
+// 报告榜单start
 type ArticleReportBillboardResp struct {
 	ArticleId      int    `description:"文章id"`
 	Title          string `description:"标题"`
@@ -805,7 +921,7 @@ type ArticleReportBillboardLIstPageResp struct {
 	Paging *paging.PagingItem
 }
 
-//报告收藏榜单列表
+// 报告收藏榜单列表
 func GetReportCollectionBillboardList(limit int, pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -831,7 +947,7 @@ func GetReportCollectionBillboardList(limit int, pars []interface{}, condition s
 	return
 }
 
-//报告阅读榜单列表
+// 报告阅读榜单列表
 func GetReportPvBillboardList(pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -851,7 +967,7 @@ func GetReportPvBillboardList(pars []interface{}, condition string) (items []*Ar
 	return
 }
 
-//获取产业报告+晨会点评数量
+// 获取产业报告+晨会点评数量
 func GetTimeLineReportIndustrialCount(industrialManagementId int) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT SUM(count) AS count FROM (
@@ -891,7 +1007,7 @@ type TimeLineReportItem struct {
 	Readnum         int    `description:"阅读数量"`
 }
 
-//获取产业报告+晨会点评列表
+// 获取产业报告+晨会点评列表
 func GetTimeLineReportIndustrialList(userId, industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -947,7 +1063,7 @@ type IndustrialReadNum struct {
 	Readnum                int `description:"阅读次数"`
 }
 
-//获取该产业下文章的用户阅读次数-小红点用
+// 获取该产业下文章的用户阅读次数-小红点用
 func GetReportIndustrialReadNumList(userId int, industrialIds string, createtime time.Time) (items []*IndustrialReadNum, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT a.industrial_management_id, MIN(a.readnum) AS readnum FROM (

+ 24 - 6
routers/commentsRouter.go

@@ -108,8 +108,8 @@ func init() {
 
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
         beego.ControllerComments{
-            Method: "ActivityList",
-            Router: `/list`,
+            Method: "ActivityListNew",
+            Router: `/listNew`,
             AllowHTTPMethods: []string{"get"},
             MethodParams: param.Make(),
             Filters: nil,
@@ -117,8 +117,8 @@ func init() {
 
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
         beego.ControllerComments{
-            Method: "ActivityListNew",
-            Router: `/listNew`,
+            Method: "ActivityListSearch",
+            Router: `/listSearch`,
             AllowHTTPMethods: []string{"get"},
             MethodParams: param.Make(),
             Filters: nil,
@@ -126,8 +126,8 @@ func init() {
 
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
         beego.ControllerComments{
-            Method: "ActivityListSearch",
-            Router: `/listSearch`,
+            Method: "ActivityList",
+            Router: `/list_del_test`,
             AllowHTTPMethods: []string{"get"},
             MethodParams: param.Make(),
             Filters: nil,
@@ -1024,6 +1024,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
+        beego.ControllerComments{
+            Method: "ArticleNewList",
+            Router: `/article/newList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
+        beego.ControllerComments{
+            Method: "ArticleType",
+            Router: `/article/typeList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
         beego.ControllerComments{
             Method: "CollectionList",

+ 59 - 11
services/industrial_management.go

@@ -11,7 +11,7 @@ import (
 	"time"
 )
 
-//修改标签状态
+// 修改标签状态
 func UpdateIndustrialManagementLabel(cont context.Context) (err error) {
 	defer func() {
 		if err != nil {
@@ -41,7 +41,7 @@ func UpdateIndustrialManagementLabel(cont context.Context) (err error) {
 	return
 }
 
-//修改活动状态
+// 修改活动状态
 func UpdateIndustrialManagementSubjectNnames() (err error) {
 	defer func() {
 		if err != nil {
@@ -108,7 +108,7 @@ func ReportBillboardUpdate(cont context.Context) (err error) {
 	return
 }
 
-//修改产业关注数量
+// 修改产业关注数量
 func IndustryFllowCountUpdate() (err error) {
 	defer func() {
 		if err != nil {
@@ -129,7 +129,7 @@ func IndustryFllowCountUpdate() (err error) {
 	return err
 }
 
-//修改文章收藏数量
+// 修改文章收藏数量
 func ArticleCollectCountUpdate() (err error) {
 	defer func() {
 		if err != nil {
@@ -150,7 +150,7 @@ func ArticleCollectCountUpdate() (err error) {
 	return err
 }
 
-//根据行业处理所选的全部赛道字段
+// 根据行业处理所选的全部赛道字段
 func DoXzsChooseSend(chartPermissionName string) string {
 	var allIn string
 	if chartPermissionName == utils.YI_YAO_NAME {
@@ -167,7 +167,7 @@ func DoXzsChooseSend(chartPermissionName string) string {
 	return allIn
 }
 
-//行业关注或者取消关注的时候,对于用户全部赛道的影响
+// 行业关注或者取消关注的时候,对于用户全部赛道的影响
 func IndustryFllowWithTrack(industrialManagementId, count, uid int) (err error) {
 	defer func() {
 		if err != nil {
@@ -272,7 +272,7 @@ func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error
 //	GetIndustrialManagementArticleNewPublishData()
 //}
 
-//批量修改获取产业关联文章的最新发布时间
+// 批量修改获取产业关联文章的最新发布时间
 func GetIndustrialManagementArticleNewPublishData() (err error) {
 	defer func() {
 		if err != nil {
@@ -309,7 +309,7 @@ func GetIndustrialManagementArticleNewPublishData() (err error) {
 	return
 }
 
-//HandleIndustryList预处理产业列表字段
+// HandleIndustryList预处理产业列表字段
 func HandleIndustryList(list []*models.IndustrialManagement, user *models.WxUserItem) (items []*models.IndustrialManagement, err error) {
 	userId := user.UserId
 	fllowList, err := models.GetUserFllowIndustrialList(userId)
@@ -432,11 +432,11 @@ func HandleIndustryList(list []*models.IndustrialManagement, user *models.WxUser
 	industrialIdMap := make(map[string]time.Time)
 	for _, v := range recrodList {
 		industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
-		if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok{
+		if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
 			if createTime.Before(v.CreateTime) {
 				industrialIdMap[industrialManagementIdstr] = v.CreateTime
 			}
-		}else {
+		} else {
 			industrialIdMap[industrialManagementIdstr] = v.CreateTime
 		}
 	}
@@ -452,7 +452,7 @@ func HandleIndustryList(list []*models.IndustrialManagement, user *models.WxUser
 	timeLineRedMap := make(map[int]bool, 0)
 
 	for _, industrialId := range industrialIdArr {
-		if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok{
+		if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
 			if createTime.Before(morningMeetingTimeMap[industrialId]) {
 				timeLineRedMap[industrialId] = true
 			}
@@ -505,3 +505,51 @@ func HandleIndustryList(list []*models.IndustrialManagement, user *models.WxUser
 	items = list
 	return
 }
+
+// 通过文章ID获取文章所关联的产业
+func GetArticleIndustrialByArticleId(articleIds []int) (itemMap map[int][]*models.IndustrialManagementResp, err error) {
+	lenarticleIds := len(articleIds)
+	if lenarticleIds == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND mg.article_id IN (` + utils.GetOrmInReplace(lenarticleIds) + `)`
+	pars = append(pars, articleIds)
+	industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
+	if err != nil {
+		return
+	}
+	industrialMap := make(map[int][]*models.IndustrialManagementResp)
+	if len(industrialList) > 0 {
+		for _, v := range industrialList {
+			item := new(models.IndustrialManagementResp)
+			item.IndustrialManagementId = v.IndustrialManagementId
+			item.IndustryName = v.IndustryName
+			item.ChartPermissionId = v.ChartPermissionId
+			industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
+		}
+	}
+	itemMap = industrialMap
+	return
+}
+
+func GetArticleTypeMap() (nameMapResp map[int]string, buttonStyleMapResp map[int]string, err error) {
+	condition := " AND is_show_yanx  = 1 "
+	list, e := models.GetCygxArticleTypeListCondition(condition)
+	if e != nil {
+		err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
+		return
+	}
+	nameMap := make(map[int]string)
+	buttonStyleMap := make(map[int]string)
+	if len(list) > 0 {
+		for _, v := range list {
+			nameMap[v.ArticleTypeId] = v.ArticleTypeName
+			buttonStyleMap[v.ArticleTypeId] = v.ButtonStyle
+		}
+	}
+	nameMapResp = nameMap
+	buttonStyleMapResp = buttonStyleMap
+	return
+}

+ 100 - 0
services/yan_xuan.go

@@ -0,0 +1,100 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+)
+
+// 获取研选类型的文章分类Id
+func GetYanXuanArticleTypeIds() (articleTypeIds string, err error) {
+	var condition string
+	condition = " AND is_show_yanx  = 1 "
+	listType, e := models.GetCygxArticleTypeListCondition(condition)
+	if e != nil {
+		err = errors.New("GetCygxArticleTypeListCondition, Err: " + e.Error())
+		return
+	}
+	for _, v := range listType {
+		articleTypeIds += strconv.Itoa(v.ArticleTypeId) + ","
+	}
+	articleTypeIds = strings.TrimRight(articleTypeIds, ",")
+	if articleTypeIds == "" {
+		err = errors.New("研选分类ID不能为空")
+		return
+	}
+	return
+}
+
+// 处理研选关联的新标签
+func GetYanXuanIndustrialManagementIdNewMap(articleTypeIds string) (respMap map[int]bool, err error) {
+	var condition string
+	if articleTypeIds == "" {
+		return
+	}
+	condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
+	list, e := models.GetIndustrialManagementNewList(condition)
+	if e != nil {
+		err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
+		return
+	}
+	newMap := make(map[int]bool)
+	for _, v := range list {
+		newMap[v.IndustrialManagementId] = true
+	}
+	respMap = newMap
+	return
+}
+
+// 处理研选关联的hot标签
+func GetYanXuanIndustrialManagementIdHotMap(articleTypeIds string) (respMap map[int]bool, err error) {
+	var condition string
+	var conditionOrder string
+	if articleTypeIds == "" {
+		return
+	}
+	condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
+	conditionOrder = ` ORDER BY sum_num DESC `
+	listHot, e := models.GetThemeHeatList(0, condition, conditionOrder, 0, 3)
+	if e != nil {
+		err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
+		return
+	}
+	hotMap := make(map[int]bool)
+	for _, v := range listHot {
+		hotMap[v.IndustrialManagementId] = true
+	}
+	respMap = hotMap
+	return
+}
+
+// GetArticleSubjectName 获取文章关联的多个标的名称
+func GetArticleSubjectName(articleIds []int) (respMap, subjectMap map[int]string, err error) {
+	lenarticleIds := len(articleIds)
+	if lenarticleIds == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND ag.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
+	pars = append(pars, articleIds)
+	list, e := models.GetSubjectArticlGroupList(condition, pars)
+	if e != nil {
+		err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
+		return
+	}
+	artMap := make(map[int]string)
+	subMap := make(map[int]string)
+	for _, v := range list {
+		artMap[v.ArticleId] += v.SubjectName + "/"
+		subMap[v.IndustrialSubjectId] = v.SubjectName
+	}
+	for _, v := range list {
+		artMap[v.ArticleId] = strings.TrimRight(artMap[v.ArticleId], "/")
+	}
+	respMap = artMap
+	subjectMap = subMap
+	return
+}

+ 2 - 1
utils/constants.go

@@ -107,7 +107,8 @@ const (
 )
 
 const (
-	YAN_XUAN__EXPLAIN = "买方研选内容实行阶段,限时免费。也欢迎您向我们提宝贵建议。"
+	YAN_XUAN_EXPLAIN = "买方研选内容实行阶段,限时免费。也欢迎您向我们提宝贵建议。"
+	YAN_XUAN_TAB_KEY = "yanxuan_header_tab"
 )
 
 const (