浏览代码

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

xingzai 3 年之前
父节点
当前提交
bb9c2f3021

+ 7 - 1
controllers/article.go

@@ -266,6 +266,13 @@ func (this *ArticleController) Detail() {
 			}
 		}
 		detail.SellerList = sellerList
+		//作者头像
+		if detail.DepartmentId > 0 {
+			departmentDetail, err := models.GetArticleDepartmentDateilById(detail.DepartmentId)
+			if err == nil {
+				detail.DepartmentImgUrl = departmentDetail.ImgUrl
+			}
+		}
 	} else { //潜在客户
 		if applyCount > 0 {
 			hasPermission = 5
@@ -298,7 +305,6 @@ Loop:
 		haveResearch = true
 	}
 
-	fmt.Println("hasPermission", hasPermission)
 	if hasPermission == 2 || hasPermission == 4 {
 		//获取销售手机号
 		sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)

+ 137 - 0
controllers/report.go

@@ -2174,3 +2174,140 @@ func (this *ReportController) IndustryAndArticleListPc() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 报告搜索
+// @Description 报告搜索接口
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} models.ReoprtSearchResp
+// @router /searchReport [get]
+func (this *ReportController) SearchReport() {
+	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
+	}
+	keyWord := this.GetString("KeyWord")
+	var condition string
+	//匹配报告标题、对应产业名称、标的名称。
+	condition = `AND (
+	    a.title LIKE '%` + keyWord + `%'
+	    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 + `%' ) ) 
+	)
+	GROUP BY  a.article_id  ORDER BY a.publish_date DESC  `
+	listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition, user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range listYx {
+		if v.MyCollectNum > 0 {
+			listYx[k].IsCollect = true
+		}
+	}
+	listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition, user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range listHz {
+		if v.MyCollectNum > 0 {
+			listHz[k].IsCollect = true
+		}
+	}
+	if keyWord != "" {
+		keyWordItem := new(models.CygxUserSearchKeyWord)
+		keyWordItem.UserId = user.UserId
+		keyWordItem.KeyWord = keyWord
+		keyWordItem.PageType = "ReortSearch"
+		keyWordItem.CreateTime = time.Now()
+		go models.AddUserSearchKeyWord(keyWordItem)
+	}
+	resp := new(models.ReoprtSearchResp)
+	resp.ListYx = listYx
+	resp.ListHz = listHz
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 资源包搜索
+// @Description 资源包搜索接口
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} models.SearchResourceResp
+// @router /searchResource [get]
+func (this *ReportController) SearchResource() {
+	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
+	}
+	keyWord := this.GetString("KeyWord")
+	var condition string
+	condition = `AND m.industry_name LIKE '%` + keyWord + `%' AND m.chart_permission_id != 31 GROUP BY m.industrial_management_id `
+	listHz, err := models.GetSearchResourceList(condition)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	condition = `AND m.industry_name LIKE '%` + keyWord + `%' AND m.chart_permission_id = 31 GROUP BY m.industrial_management_id `
+	listYx, err := models.GetSearchResourceList(condition)
+	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
+	}
+	for k, v := range listHz {
+
+		for _, v2 := range listSubjcet {
+			if v2.IndustrialManagementId == v.IndustrialManagementId {
+				listHz[k].IndustrialSubjectList = append(listHz[k].IndustrialSubjectList, v2)
+			}
+		}
+	}
+	for k, v := range listYx {
+		for _, v2 := range listSubjcet {
+			if v2.IndustrialManagementId == v.IndustrialManagementId {
+				listHz[k].IndustrialSubjectList = append(listHz[k].IndustrialSubjectList, v2)
+			}
+		}
+	}
+	if keyWord != "" {
+		keyWordItem := new(models.CygxUserSearchKeyWord)
+		keyWordItem.UserId = user.UserId
+		keyWordItem.KeyWord = keyWord
+		keyWordItem.PageType = "ReortSearch"
+		keyWordItem.CreateTime = time.Now()
+		go models.AddUserSearchKeyWord(keyWordItem)
+	}
+	resp := new(models.SearchResourceResp)
+	resp.ListYx = listYx
+	resp.ListHz = listHz
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 355 - 5
controllers/research.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"hongze/hongze_cygx/models"
+	"strconv"
 )
 
 //研选
@@ -90,12 +91,19 @@ func (this *ResearchController) CollectionList() {
 		br.ErrMsg = "获取信息失败,Err:" + err.Error()
 		return
 	}
-	list, err := models.GetArticleCollectionList(categoryinfo.PermissionName)
+	var condition string
+	condition = `  AND a.category_name LIKE '%` + categoryinfo.PermissionName + `%' AND publish_status = 1 GROUP BY m.industrial_management_id ORDER BY collect_num DESC, publish_date DESC LIMIT 15 `
+	list, err := models.GetArticleCollectionList(condition, user.UserId)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
+	for k, v := range list {
+		if v.MyCollectNum > 0 {
+			list[k].IsCollect = true
+		}
+	}
 	resp := new(models.ArticleCollectionLIstResp)
 	resp.List = list
 	br.Ret = 200
@@ -104,12 +112,102 @@ func (this *ResearchController) CollectionList() {
 	br.Data = resp
 }
 
-// @Title 主题热度列表
-// @Description 主题热度列表接口
+// @Title 主题热度/近期更新更多,列表
+// @Description 主题热度/近期更新更多,列表接口
 // @Param   ChartPermissionId   query   int  true       "分类ID"
-// @Success 200 {object} models.ArticleCollectionLIstResp
+// @Param   ThemeType   query   int  true       "主题类型,1主题热度、2近期更新 默认1"
+// @Success 200 {object} models.IndustrialManagementHotListResp
 // @router /hotList [get]
 func (this *ResearchController) HotList() {
+	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
+	}
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
+	themeType, _ := this.GetInt("ThemeType")
+	if chartPermissionId < 1 {
+		br.Msg = "请输入分类ID"
+		return
+	}
+	var condition string
+	if themeType != 2 {
+		themeType = 1
+		condition = `ORDER BY sum_num DESC LIMIT 15`
+	} else {
+		condition = `ORDER BY publish_date DESC LIMIT 30`
+	}
+	categoryinfo, err := models.GetChartPermissionById(chartPermissionId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	list, err := models.GetThemeHeatList(categoryinfo.PermissionName, user.UserId, condition)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	newMap := make(map[int]string)
+	listNew, err := models.GetIndustrialManagementNewList(categoryinfo.PermissionName)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取产业最新信息失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range listNew {
+		newMap[v.IndustrialManagementId] = v.IndustryName
+	}
+	condition = ` AND a.category_name LIKE '%` + categoryinfo.PermissionName + `%' `
+	listSubjcet, err := models.GetThemeHeatSubjectList(condition)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
+		return
+	}
+	detailHot3, err := models.GetIndustrialManagementHot3(chartPermissionId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range list {
+		if newMap[v.IndustrialManagementId] != "" {
+			list[k].IsNew = true
+		}
+		if v.FllowNum > 0 {
+			list[k].IsFollw = true
+		}
+		for _, v2 := range listSubjcet {
+			if v2.IndustrialManagementId == v.IndustrialManagementId {
+				list[k].IndustrialSubjectList = append(list[k].IndustrialSubjectList, v2)
+			}
+		}
+		if v.ArticleReadNum >= detailHot3.ArticleReadNum {
+			list[k].IsHot = true
+		}
+	}
+	resp := new(models.IndustrialManagementHotListResp)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title KOL榜列表
+// @Description KOL榜列表接口
+// @Param   ChartPermissionId   query   int  true       "分类ID"
+// @Success 200 {object} models.DepartmentListResp
+// @router /kolList [get]
+func (this *ResearchController) KolList() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		this.Data["json"] = br
@@ -132,12 +230,233 @@ func (this *ResearchController) HotList() {
 		br.ErrMsg = "获取信息失败,Err:" + err.Error()
 		return
 	}
-	list, err := models.GetArticleCollectionList(categoryinfo.PermissionName)
+	list, err := models.GetDepartmentList(categoryinfo.PermissionName, user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	listIndustrial, err := models.GetIndustrialDepartmentList(categoryinfo.PermissionName)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
+	departmentMap := make(map[string]string)
+	for k, v := range list {
+		if v.FllowNum > 0 {
+			list[k].IsFollw = true
+		}
+		for _, v2 := range listIndustrial {
+			if v2.DepartmentId == v.DepartmentId {
+				if departmentMap["D"+strconv.Itoa(v2.DepartmentId)+"In"+strconv.Itoa(v2.IndustrialManagementId)] == "" && len(list[k].List) < 4 {
+					list[k].List = append(list[k].List, v2)
+					departmentMap["D"+strconv.Itoa(v2.DepartmentId)+"In"+strconv.Itoa(v2.IndustrialManagementId)] = v.NickName
+				}
+			}
+		}
+	}
+	resp := new(models.DepartmentListResp)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 主题详情
+// @Description 主题详情接口
+// @Param   IndustrialManagementId   query   int  true       "分类ID"
+// @Success 200 {object} models.GetThemeDetailResp
+// @router /theme/detail [get]
+func (this *ResearchController) ThemeDetail() {
+	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
+	}
+	industrialManagementId, _ := this.GetInt("IndustrialManagementId")
+	if industrialManagementId < 1 {
+		br.Msg = "请输入产业ID"
+		return
+	}
+	resp := new(models.GetThemeDetailResp)
+	list, err := models.GetThemeDetail(user.UserId, industrialManagementId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+
+	var itemsNull []*models.GetThemeAericleListResp
+	subjectMap := make(map[string]string)
+	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.Pv = v.Pv
+			item.CollectNum = v.CollectNum
+			itemsNull = append(itemsNull, item)
+		}
+	}
+
+	for _, v := range resp.ListSubject {
+		subjetcGroup := new(models.GetThemeAericleListBuSubjectResp)
+		for _, v2 := range list {
+			if v2.IndustrialSubjectId == v.IndustrialSubjectId {
+				item := new(models.GetThemeAericleListResp)
+				item.ArticleId = v2.ArticleId
+				item.Title = v2.Title
+				item.PublishDate = v2.PublishDate
+				item.SubjectName = v2.SubjectName
+				for _, v3 := range list {
+					if v3.ArticleId == v2.ArticleId && v3.SubjectName != v2.SubjectName && v3.SubjectName != "" {
+						item.SubjectName += "/" + v3.SubjectName
+					}
+				}
+				item.DepartmentId = v2.DepartmentId
+				item.Pv = v2.Pv
+				item.CollectNum = v2.CollectNum
+				item.MyCollectNum = v2.MyCollectNum
+				if v2.MyCollectNum > 0 {
+					item.IsCollect = true
+				}
+				subjetcGroup.List = append(subjetcGroup.List, item)
+			}
+			subjetcGroup.SubjectName = v.SubjectName
+		}
+		resp.List = append(resp.List, subjetcGroup)
+	}
+	//当标的为空时进行合并
+	if len(itemsNull) > 0 {
+		subjetcGroup := new(models.GetThemeAericleListBuSubjectResp)
+		for _, v := range itemsNull {
+			subjetcGroup.List = append(subjetcGroup.List, v)
+			subjetcGroup.SubjectName = v.SubjectName
+		}
+		resp.List = append(resp.List, subjetcGroup)
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 研选作者详情
+// @Description 研选作者详情接口
+// @Param   DepartmentId   query   int  true       "作者ID"
+// @Success 200 {object} models.DepartmentDetailResp
+// @router /departmentId/detail [get]
+func (this *ResearchController) DepartmentIdDetail() {
+	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
+	}
+	departmentId, _ := this.GetInt("DepartmentId")
+	if departmentId < 1 {
+		br.Msg = "请输入作者ID"
+		return
+	}
+	resp := new(models.DepartmentDetailResp)
+	detail, err := models.GetDepartmentDetail(user.UserId, departmentId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取作者信息失败,Err:" + err.Error()
+		return
+	}
+	resp.DepartmentId = detail.DepartmentId
+	resp.NickName = detail.NickName
+	resp.ImgUrl = detail.ImgUrl
+	resp.FllowNum = detail.FllowNum
+	resp.ArticleNum = detail.ArticleNum
+	resp.CollectNum = detail.CollectNum
+	if detail.MyFllowNum > 0 {
+		resp.IsFllow = true
+	}
+	var condition string
+	condition = `  AND a.department_id = ` + strconv.Itoa(departmentId) + ` ORDER BY a.publish_date DESC  `
+	list, err := models.GetArticleCollectionList(condition, user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range list {
+		if v.MyCollectNum > 0 {
+			list[k].IsCollect = true
+		}
+	}
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 文章相关热门收藏
+// @Description 文章相关热门收藏接口
+// @Param   ArticleId   query   int  true       "文章ID"
+// @Success 200 {object} models.ArticleCollectionLIstResp
+// @router /article/hotList [get]
+func (this *ResearchController) ArticleHotList() {
+	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
+	}
+	articleId, _ := this.GetInt("ArticleId")
+	if articleId < 1 {
+		br.Msg = "请输入分类ID"
+		return
+	}
+	var condition string
+	condition = ` AND 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_article_group_management  WHERE  article_id = ` + strconv.Itoa(articleId) + ` ) ) AND a.article_id != ` + strconv.Itoa(articleId) + ` AND a.category_name LIKE '%研选%' AND publish_status = 1 GROUP BY a.article_id ORDER BY collect_num DESC, publish_date DESC LIMIT 3 `
+	list, err := models.GetArticleCollectionList(condition, user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range list {
+		if v.MyCollectNum > 0 {
+			list[k].IsCollect = true
+		}
+	}
 	resp := new(models.ArticleCollectionLIstResp)
 	resp.List = list
 	br.Ret = 200
@@ -145,3 +464,34 @@ func (this *ResearchController) HotList() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 热搜关键词
+// @Description 热搜关键词接口
+// @Success 200 {object} models.UserSearchKeyWordListResp
+// @router /hotKeyWord [get]
+func (this *ResearchController) HotKeyWord() {
+	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
+	}
+	//本来应该放在config控制器下,与未上线的代码冲突,所以放在这里
+	list, err := models.GetUserSearchKeyWord()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.UserSearchKeyWordListResp)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 1 - 0
models/article.go

@@ -134,6 +134,7 @@ type ArticleDetail struct {
 	FollowNum               int    `description:"关注数量"`
 	CollectionNum           int    `description:"收藏数量"`
 	DepartmentId            int    `description:"作者ID"`
+	DepartmentImgUrl        string `description:"作者头像"`
 	SubjectIds              string `description:"文章关联标的的ID字符串"`
 	IndustrialAndSubjectIds string `description:"文章关联产业和标的的ID字符串"`
 	IndustrialManagementId  int    `description:"文章关联产业ID"`

+ 2 - 2
models/industrial_management.go

@@ -263,6 +263,7 @@ func GetcygxIndustrialSubject(industrialManagementId int) (items []*IndustrialSu
 	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 = ?`
@@ -368,8 +369,7 @@ func GetIndustrialManagementNewList(permissionName string) (items []*IndustrialM
 			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 
 		WHERE
-			1 = 1 
-			AND a.is_report = 1 
+			1 = 1
 			AND a.category_name LIKE '%` + permissionName + `%' 
 			AND publish_status = 1 
 		GROUP BY

+ 317 - 10
models/report.go

@@ -305,9 +305,7 @@ func GetArticleIdsBySubId(subjectId string) (articleIds string, err error) {
 			WHERE subject_ids  LIKE '%` + subjectId + `%'`
 	err = o.Raw(sql).QueryRow(&articleIds)
 	return
-}
-
-//end
+} //end
 
 //用户收藏榜start
 type ArticleCollectionResp struct {
@@ -320,6 +318,8 @@ type ArticleCollectionResp struct {
 	NickName               string `description:"作者昵称"`
 	Pv                     int    `description:"PV"`
 	CollectNum             int    `description:"收藏人数"`
+	MyCollectNum           int    `description:"本人是否收藏"`
+	IsCollect              bool   `description:"本人是否收藏"`
 }
 
 type ArticleCollectionLIstResp struct {
@@ -327,7 +327,7 @@ type ArticleCollectionLIstResp struct {
 }
 
 //列表
-func GetArticleCollectionList(permissionName string) (items []*ArticleCollectionResp, err error) {
+func GetArticleCollectionList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			a.article_id,
@@ -338,23 +338,330 @@ func GetArticleCollectionList(permissionName string) (items []*ArticleCollection
 			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 WHERE ac.article_id = a.article_id ) AS collect_num 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num, 
+			( 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.is_report = 1 
+			1 = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, userId).QueryRows(&items)
+	return
+} //end
+
+//用户收藏榜start
+type IndustrialManagementHotResp struct {
+	IndustrialManagementId int                  `orm:"column(industrial_management_id);pk" description:"产业id"`
+	IndustryName           string               `description:"产业名称"`
+	IsFollw                bool                 `description:"是否关注"`
+	FllowNum               int                  `description:"关注数量"`
+	IsNew                  bool                 `description:"是否新标签"`
+	IsHot                  bool                 `description:"是否新标签"`
+	PublishDate            string               `description:"发布时间"`
+	ArticleReadNum         int                  `description:"文章阅读数量"`
+	IndustrialSubjectList  []*IndustrialSubject `description:"标的列表"`
+}
+
+type IndustrialManagementHotListResp struct {
+	List []*IndustrialManagementHotResp
+}
+
+//产业列表
+func GetThemeHeatList(permissionName string, userId int, condition string) (items []*IndustrialManagementHotResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			m.industry_name,
+			m.industrial_management_id,
+			m.article_read_num,
+            date_format(  MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date,	
+			( SELECT count( 1 ) FROM cygx_industry_fllow AS f  WHERE f.industrial_management_id = m.industrial_management_id  AND user_id =?   ) AS fllow_num,
+			( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id IN  (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = m.industrial_management_id )) + ( 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  )) 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
+			LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id 
+			LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
+		WHERE
+			1 = 1
+			AND a.category_name LIKE '%` + permissionName + `%' 
+			AND publish_status = 1 
+			GROUP BY m.industrial_management_id ` + condition
+	_, err = o.Raw(sql, userId).QueryRows(&items)
+	return
+}
+
+//标的列表
+func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			m.subject_name,
+			m.industrial_management_id,
+			m.industrial_subject_id 
+		FROM
+			cygx_article AS a
+			INNER JOIN cygx_industrial_article_group_subject AS mg ON mg.article_id = a.article_id
+			INNER JOIN cygx_industrial_subject AS m ON m.industrial_subject_id = mg.industrial_subject_id 
+		WHERE
+			1 = 1`
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` AND publish_status = 1 
+		GROUP BY
+			m.industrial_subject_id 
+		ORDER BY
+			publish_date DESC`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+} //end
+
+//Kol sratr
+type DepartmentResp struct {
+	DepartmentId int    `description:"作者Id"`
+	NickName     string `description:"作者昵称"`
+	ImgUrl       string `description:"图片链接"`
+	IsFollw      bool   `description:"是否关注"`
+	FllowNum     int    `description:"关注数量"`
+	List         []*IndustrialDepartmentListResp
+}
+
+type DepartmentListResp struct {
+	List []*DepartmentResp
+}
+type IndustrialDepartmentListResp struct {
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+	DepartmentId           int    `description:"作者Id"`
+}
+
+//作者列表
+func GetDepartmentList(permissionName string, userId int) (items []*DepartmentResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			d.nick_name,
+			d.department_id,
+			d.img_url,
+			( SELECT count( 1 ) FROM cygx_article_department_follow AS f  WHERE f.department_id = d.department_id  AND user_id =?   ) AS fllow_num,
+			( SELECT count( 1 ) FROM cygx_article_department_follow AS f WHERE f.department_id = d.department_id ) +( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) 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.category_name LIKE '%` + permissionName + `%' 
 			AND publish_status = 1 
 		GROUP BY
-			m.industrial_management_id 
+				d.department_id
 		ORDER BY
-			collect_num DESC,
-			publish_date DESC 
+			sum_num DESC
 			LIMIT 15`
+	_, err = o.Raw(sql, userId).QueryRows(&items)
+	return
+}
+
+//作者文章所关联的产业列表
+func GetIndustrialDepartmentList(permissionName string) (items []*IndustrialDepartmentListResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			m.industrial_management_id,
+			m.industry_name,
+			d.department_id 
+		FROM
+			cygx_article_department AS d
+			INNER JOIN cygx_article AS a ON d.department_id = a.department_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 
+		WHERE
+			1 = 1
+			AND a.category_name LIKE '%` + permissionName + `%' 
+			AND publish_status = 1 
+		GROUP BY
+			a.article_id 
+		ORDER BY
+			a.publish_date DESC`
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
+}
+
+//主题详情start
+type GetThemeDetailListResp struct {
+	ArticleId              int    `description:"文章id"`
+	Title                  string `description:"标题"`
+	PublishDate            string `description:"发布时间"`
+	SubjectName            string `description:"标的名称"`
+	IndustrialSubjectId    int    `description:"标的id"`
+	DepartmentId           int    `description:"作者Id"`
+	NickName               string `description:"作者昵称"`
+	Pv                     int    `description:"PV"`
+	CollectNum             int    `description:"收藏人数"`
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+	FllowNum               int    `description:"关注数量"`
+	MyCollectNum           int    `description:"本人是否收藏"`
+	IsCollect              bool   `description:"本人是否收藏"`
+}
+
+type GetThemeAericleListResp struct {
+	ArticleId    int    `description:"文章id"`
+	Title        string `description:"标题"`
+	PublishDate  string `description:"发布时间"`
+	SubjectName  string `description:"标的名称"`
+	DepartmentId int    `description:"作者Id"`
+	NickName     string `description:"作者昵称"`
+	Pv           int    `description:"PV"`
+	CollectNum   int    `description:"收藏人数"`
+	FllowNum     int    `description:"关注数量"`
+	MyCollectNum int    `description:"本人是否收藏"`
+	IsCollect    bool   `description:"本人是否收藏"`
+}
+
+type GetThemeAericleListBuSubjectResp struct {
+	SubjectName string `description:"标的名称"`
+	List        []*GetThemeAericleListResp
+}
+
+//主题详情start
+type GetThemeDetailResp struct {
+	IndustrialManagementId int                  `description:"产业Id"`
+	IndustryName           string               `description:"产业名称"`
+	IsFollw                bool                 `description:"是否关注"`
+	ListSubject            []*IndustrialSubject `description:"标的列表"`
+	List                   []*GetThemeAericleListBuSubjectResp
+}
+
+//列表
+func GetThemeDetail(userId, industrialManagementId int) (items []*GetThemeDetailListResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			a.article_id,
+			a.title,
+			date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
+			m.industry_name,
+			m.industrial_management_id,
+			d.nick_name,
+			d.department_id,
+			s.industrial_subject_id,
+			s.subject_name,
+			( 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 WHERE ac.article_id = a.article_id ) AS collect_num,
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id and user_id = ? ) AS my_collect_num,
+			( SELECT count( 1 ) FROM cygx_industry_fllow AS ac WHERE user_id = ?  AND ac.industrial_management_id = m.industrial_management_id ) AS fllow_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
+			LEFT JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = a.article_id
+			LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id 
+		WHERE
+			1 = 1
+			AND a.category_name LIKE '%研选%' 
+			AND m.industrial_management_id = ? 
+			AND publish_status = 1 
+		ORDER BY
+			publish_date DESC`
+	_, err = o.Raw(sql, userId, userId, industrialManagementId).QueryRows(&items)
+	return
+} //end
+
+//用户收藏榜start
+type DepartmentDetailResp struct {
+	DepartmentId int    `description:"作者Id"`
+	NickName     string `description:"作者昵称"`
+	ImgUrl       string `description:"图片链接"`
+	FllowNum     int    `description:"多少人关注"`
+	ArticleNum   int    `description:"文章数量"`
+	CollectNum   int    `description:"收藏人数"`
+	IsFllow      bool   `description:"是否关注"`
+	List         []*ArticleCollectionResp
+}
+
+type DepartmentDetail struct {
+	DepartmentId int    `description:"作者Id"`
+	NickName     string `description:"作者昵称"`
+	ImgUrl       string `description:"图片链接"`
+	FllowNum     int    `description:"多少人关注"`
+	ArticleNum   int    `description:"文章数量"`
+	CollectNum   int    `description:"收藏人数"`
+	IsFllow      bool   `description:"是否关注"`
+	MyFllowNum   int    `description:"本人是否关注"`
+}
+
+//列表
+func GetDepartmentDetail(userId, departmentId int) (item DepartmentDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			d.department_id,
+			d.nick_name,
+			d.img_url,
+			( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.user_id = ? AND af.department_id = d.department_id ) AS my_fllow_num,
+			( SELECT count( 1 ) FROM cygx_article_department_follow AS f WHERE f.department_id = d.department_id  ) 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  WHERE c.article_id IN (SELECT  article_id FROM cygx_article AS a WHERE a.department_id = d.department_id )) AS collect_num
+		FROM
+			cygx_article_department AS d 
+		WHERE
+			d.department_id = ?`
+	err = o.Raw(sql, userId, departmentId).QueryRow(&item)
+	return
 } //end
+
+//报告搜索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
+			a.article_id,
+			a.title,
+			date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
+			m.industry_name,
+			m.industrial_management_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 WHERE ac.article_id = a.article_id ) AS collect_num,
+			( 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
+		WHERE
+			1 = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, userId).QueryRows(&items)
+	return
+} //end
+
+//搜索资源包 start
+type SearchResourceResp struct {
+	ListHz []*IndustrialManagementHotResp `description:"弘则"`
+	ListYx []*IndustrialManagementHotResp `description:"研选"`
+}
+
+//产业列表
+func GetSearchResourceList(condition string) (items []*IndustrialManagementHotResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			m.industry_name,
+			m.industrial_management_id,
+			date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date 
+		FROM
+			cygx_industrial_management AS m
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
+			INNER JOIN cygx_article AS a ON a.article_id = mg.article_id 
+		WHERE
+			1 = 1 
+			AND publish_status = 1 ` + condition
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 28 - 0
models/user_search_key_word.go

@@ -19,3 +19,31 @@ func AddUserSearchKeyWord(item *CygxUserSearchKeyWord) (lastId int64, err error)
 	lastId, err = o.Insert(item)
 	return
 }
+
+type UserSearchKeyWord struct {
+	KeyWord string `description:"关键词"`
+}
+
+type UserSearchKeyWordListResp struct {
+	List []*UserSearchKeyWord
+}
+
+//列表
+func GetUserSearchKeyWord() (items []*UserSearchKeyWord, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			key_word,
+			key_word AS kw,
+			( SELECT count( 1 ) FROM cygx_user_search_key_word AS k WHERE k.key_word = kw ) AS key_num 
+		FROM
+			cygx_user_search_key_word 
+		WHERE
+			page_type = 'ReortSearch' 
+		GROUP BY
+			key_word 
+		ORDER BY
+			key_num DESC 
+			LIMIT 8`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 63 - 0
routers/commentsRouter_controllers.go

@@ -520,6 +520,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "SearchReport",
+            Router: "/searchReport",
+            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.ControllerComments{
+            Method: "SearchResource",
+            Router: "/searchResource",
+            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.ControllerComments{
             Method: "ArticleCategoryList",
@@ -538,6 +556,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
+        beego.ControllerComments{
+            Method: "ArticleHotList",
+            Router: "/article/hotList",
+            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",
@@ -547,6 +574,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: "DepartmentIdDetail",
+            Router: "/departmentId/detail",
+            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: "HotKeyWord",
+            Router: "/hotKeyWord",
+            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: "HotList",
@@ -556,6 +601,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: "KolList",
+            Router: "/kolList",
+            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: "ThemeDetail",
+            Router: "/theme/detail",
+            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: "NewList",