Browse Source

Merge branch 'cygx_4.0' of http://8.136.199.33:3000/cxzhang/hongze_clpt into debug

xingzai 2 years ago
parent
commit
da9adab95f

+ 429 - 0
controllers/research.go

@@ -0,0 +1,429 @@
+package controllers
+
+import (
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/services"
+	"hongze/hongze_clpt/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+type MobileResearchController struct {
+	BaseAuthMobileController
+}
+
+// @Title 研选文章类型列表
+// @Description 研选文章类型列表接口
+// @Success 200 {object} models.CygxArticleTypeListResp
+// @router /article/typeList [get]
+func (this *MobileResearchController) 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
+	}
+	var condition string
+	condition = " AND is_show_yanx  = 1 "
+	list, err := models.GetCygxArticleTypeListCondition(condition)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.CygxArticleTypeListResp)
+	for _, v := range list {
+		item := models.CygxArticleTypeResp{
+			ArticleTypeId:   v.ArticleTypeId,
+			ArticleTypeName: v.ArticleTypeName,
+			ButtonStyle:     v.ButtonStyle,
+		}
+		resp.List = append(resp.List, &item)
+	}
+	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 *MobileResearchController) 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 pars []interface{}
+	condition = `    AND publish_status = 1  `
+	if articleTypeIds == "" {
+		var conditiontype string
+		conditiontype = " AND is_show_yanx  = 1 "
+		listType, err := models.GetCygxArticleTypeListCondition(conditiontype)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+			return
+		}
+		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
+	}
+	list, err = services.HandleArticleCategoryImg(list)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
+		return
+	}
+	//处理对应的文章类型标签按钮
+	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,
+			ArticleTypeId:   v.ArticleTypeId,
+			Title:           v.Title,
+			PublishDate:     v.PublishDate,
+			DepartmentId:    v.DepartmentId,
+			NickName:        v.NickName,
+			IsCollect:       v.IsCollect,
+			Pv:              v.Pv,
+			CollectNum:      v.CollectNum,
+			Abstract:        v.Abstract,
+			Annotation:      v.Annotation,
+			ImgUrlPc:        v.ImgUrlPc,
+			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
+}
+
+// @Title KOL榜列表
+// @Description KOL榜列表接口
+// @Success 200 {object} models.DepartmentListResp
+// @router /kolList [get]
+func (this *MobileResearchController) KolList() {
+	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
+	}
+	list, err := models.GetDepartmentList(user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	listIndustrial, err := models.GetIndustrialDepartmentList()
+	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].IsFollow = 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   ThemeType   query   int  true       "主题类型,1主题热度、2近期更新 默认1"
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.IndustrialManagementHotListResp
+// @router /hotList [get]
+func (this *MobileResearchController) 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
+	}
+	themeType, _ := this.GetInt("ThemeType", 1)
+	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)
+	var condition string
+	if themeType == 1 {
+		condition = `ORDER BY publish_date DESC `
+	} else {
+		condition = `ORDER BY sum_num DESC `
+	}
+	total, err := models.GetThemeHeatListCount("")
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	list, err := models.GetThemeHeatList(user.UserId, condition, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	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)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range listHot {
+		mapHot[v.IndustryName] = v.IndustrialManagementId
+	}
+	nowTime := time.Now().Local()
+	threeMonBefore := nowTime.AddDate(0, -3, 0)
+	for k, v := range list {
+		if v.MinReportTime != "" {
+			t, err := time.Parse(utils.FormatDateTime, v.MinReportTime)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "报告最早发布时间有误,Err:" + err.Error()
+				return
+			}
+			if t.After(threeMonBefore) {
+				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 mapHot[v.IndustryName] > 0 {
+			list[k].IsHot = true
+		}
+		list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.IndustrialManagementHotListResp)
+	resp.Paging = page
+	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 *MobileResearchController) 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
+	}
+	detailIndustrial, err := models.GetIndustrialManagementDetail(industrialManagementId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	var condition string
+
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+		return
+	}
+	if articleTypeIds != "" {
+		condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
+	} else {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "研选分类ID不能为空"
+		return
+	}
+	resp := new(models.GetThemeDetailResp)
+	list, err := models.GetThemeDetail(user.UserId, industrialManagementId, condition)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	list, err = services.HandleArticleCategoryImg(list)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
+		return
+	}
+	//处理对应的文章类型标签按钮
+	nameMap, styleMap, err := services.GetArticleTypeMap()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
+		return
+	}
+	var articleIds []int
+	for _, v := range list {
+		item := models.ArticleResearchResp{
+			ArticleId:       v.ArticleId,
+			ArticleTypeId:   v.ArticleTypeId,
+			Title:           v.Title,
+			PublishDate:     v.PublishDate,
+			DepartmentId:    v.DepartmentId,
+			NickName:        v.NickName,
+			IsCollect:       v.IsCollect,
+			Pv:              v.Pv,
+			CollectNum:      v.CollectNum,
+			Abstract:        v.Abstract,
+			Annotation:      v.Annotation,
+			ImgUrlPc:        v.ImgUrlPc,
+			ArticleTypeName: nameMap[v.ArticleTypeId],
+			ButtonStyle:     styleMap[v.ArticleTypeId],
+			List:            v.List,
+		}
+		resp.List = append(resp.List, &item)
+		articleIds = append(articleIds, v.ArticleId)
+	}
+
+	//处理用户数是否关注该产业
+	userFollowIndustrialMap, err := services.GetUserFollowIndustrialMap(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
+		return
+	}
+	if _, ok := userFollowIndustrialMap[industrialManagementId]; ok {
+		resp.IsFollw = true
+	}
+
+	//处理文章关联的标的
+	articleGroupSubjectMap, listSubtect, err := services.GetArticleGroupSubjectMap(articleIds)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
+		return
+	}
+	if len(articleGroupSubjectMap) > 0 {
+		for k, v := range resp.List {
+			resp.List[k].ListSubject = articleGroupSubjectMap[v.ArticleId]
+		}
+		resp.ListSubject = listSubtect
+	}
+
+	resp.IndustryName = detailIndustrial.IndustryName
+	resp.IndustrialManagementId = detailIndustrial.IndustrialManagementId
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 6 - 5
models/article.go

@@ -76,7 +76,7 @@ type ArticleFollowDetail struct {
 	MacNum int `description:"本人是否收藏这个文章"`
 }
 
-//获取文章被关注被收藏的详情
+// 获取文章被关注被收藏的详情
 func GetArticleFollowDetail(articleId, uid int) (item *ArticleFollowDetail, err error) {
 	//d_num 作者被关注的数量 、 md_num 本人是否关注这个作者 、ac_num 文章被收藏的数量 、 mac_num 本人是否收藏这个文章
 	o := orm.NewOrm()
@@ -103,7 +103,7 @@ func GetArticleCountById(articleId int) (count int, err error) {
 	return
 }
 
-//用户收藏榜start
+// 用户收藏榜start
 type ArticleCollectionResp struct {
 	ArticleId       int                         `description:"文章id"`
 	Title           string                      `description:"标题"`
@@ -126,9 +126,10 @@ type ArticleCollectionResp struct {
 	HttpUrl         string                      `description:"文章链接跳转地址"`
 	IsNeedJump      bool                        `description:"是否需要跳转链接地址"`
 	MyCollectNum    int                         `description:"本人是否收藏数量"`
+	ArticleTypeId   int                         `description:"文章类型ID"`
 }
 
-//列表
+// 列表
 func GetArticleCollectionList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -189,7 +190,7 @@ type CygxArticleEs struct {
 	MatchTypeName    string `description:"匹配类型"`
 }
 
-//获取文章列表
+// 获取文章列表
 func GetArticleList(condition string, pars []interface{}) (items []*ArticleDetail, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT	article_id FROM cygx_article  WHERE 1= 1 ` + condition
@@ -204,4 +205,4 @@ func GetArticleDetailByIdStr(articleIdStr string) (items []*ArticleDetail, err e
 			LEFT JOIN cygx_article_department AS d ON d.department_id = art.department_id  WHERE article_id IN(` + articleIdStr + `) `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
-}
+}

+ 32 - 1
models/article_department.go

@@ -20,6 +20,12 @@ type DepartmentResp struct {
 	NickName     string `description:"昵称"`
 	ImgUrl       string `description:"头像链接"`
 	IsFollow     bool   `description:"是否关注"`
+	FllowNum     int    `description:"关注数量"`
+	List         []*IndustrialDepartmentListResp
+}
+
+type DepartmentListResp struct {
+	List []*DepartmentResp
 }
 
 type CygxArticleDepartmentId struct {
@@ -33,7 +39,7 @@ func GetArticleDepartmentDateilById(departmentId int) (item *DepartmentResp, err
 	return
 }
 
-//数量
+// 数量
 func GetArticleDepartmentCount(condition string) (count int, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT COUNT(*) count
@@ -54,3 +60,28 @@ func GetArticleDepartmentCount(condition string) (count int, err error) {
 type IndustrialSubjectList struct {
 	SubjectName string `description:"标的名称"`
 }
+
+// 作者列表
+func GetDepartmentList(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 =?  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
+		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
+		ORDER BY
+			sum_num DESC
+			LIMIT 15`
+	_, err = o.Raw(sql, userId).QueryRows(&items)
+	return
+}

+ 70 - 0
models/article_type.go

@@ -0,0 +1,70 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxArticleType struct {
+	ArticleTypeId      int       `orm:"column(article_type_id);pk";description:"文章类型ID"`
+	ArticleTypeName    string    `description:"类型名称"`
+	Sort               int       `description:"排序字段"`
+	CreateTime         time.Time `description:"创建时间"`
+	ModifyTime         time.Time `description:"最后修改时间"`
+	IsSendEs           int       `description:"这种报告类型是否同步到Es"`
+	YanxPermissionId   int       `description:"研选类型所对应的ID"`
+	YanxPermissionName string    `description:"研选类型所对应的名称"`
+	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 = ? `
+	err = o.Raw(sql, activityTypeId).QueryRow(&item)
+	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
+	err = o.Raw(sqlCount).QueryRow(&count)
+	return
+}
+
+// 报告类型列表
+func GetCygxArticleTypeList() (items []*CygxArticleType, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article_type ORDER BY sort DESC`
+	_, err = o.Raw(sql).QueryRows(&items)
+	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=? `
+	err = o.Raw(sql, activityTypeId).QueryRow(&item)
+	return
+}

+ 4 - 0
models/home.go

@@ -63,6 +63,10 @@ type ArticleListResp struct {
 	ChartPermissionName string `description:"权限名称"`
 	ArticleTypeId       int    `description:"文章类型ID判断是否是研选使用"`
 	BodyImg             string `description:"文章封面图片"`
+	DepartmentId        int    `description:"作者Id"`
+	NickName            string `description:"作者昵称"`
+	IsCollect           bool   `description:"本人是否收藏"`
+	CollectNum          int    `description:"收藏人数"`
 	List                []*IndustrialManagementIdInt
 }
 

+ 31 - 0
models/industrial_article_group_management.go

@@ -54,3 +54,34 @@ func GetIndustrialArticleGroupManagementList(condition string, pars []interface{
 	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
 	return
 }
+
+type IndustrialDepartmentListResp struct {
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+	DepartmentId           int    `description:"作者Id"`
+	List                   []*IndustrialDepartmentListResp
+}
+
+// 作者文章所关联的产业列表
+func GetIndustrialDepartmentList() (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.article_type_id > 0
+			AND publish_status = 1 
+		GROUP BY
+			a.article_id 
+		ORDER BY
+			a.publish_date DESC`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 30 - 0
models/industrial_subject.go

@@ -0,0 +1,30 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type IndustrialSubjectByArticle struct {
+	IndustrialSubjectId    int    `description:"标的id"`
+	IndustrialManagementId int    `description:"产业id"`
+	SubjectName            string `description:"标的名称"`
+	IndustryName           string `description:"产业名称"`
+	ArticleId              int    `description:"文章ID"`
+}
+
+// 获取标的列表
+func GetArticleGroupSubjectList(pars []interface{}, condition string) (items []*IndustrialSubjectByArticle, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			s.subject_name,
+			s.industrial_subject_id,
+			s.industrial_management_id,
+			g.article_id 
+		FROM
+			cygx_industrial_article_group_subject AS g
+			INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = g.industrial_subject_id 
+		WHERE
+			1 = 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 210 - 19
models/report.go

@@ -51,13 +51,13 @@ type TacticsListResp struct {
 	List             []*HomeArticle
 }
 
-//报告搜索start
+// 报告搜索start
 type ReoprtSearchResp struct {
 	Paging *paging.PagingItem
 	ListHz []*ArticleCollectionResp `description:"弘则报告"`
 }
 
-//搜索资源包 start
+// 搜索资源包 start
 type SearchResourceResp struct {
 	ListHz []*IndustrialManagement `description:"弘则"`
 }
@@ -76,7 +76,7 @@ type SearchResourceResp struct {
 //	IndustrialSubjectList  []*IndustrialSubject `description:"标的列表"`
 //}
 
-//获取列表数量
+// 获取列表数量
 func GetReoprtSearchCount(condition string) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -93,7 +93,7 @@ func GetReoprtSearchCount(condition string) (count int, err error) {
 	return
 }
 
-//列表
+// 列表
 func GetReoprtSearchList(condition string, userId, startSize, pageSize int) (items []*ArticleCollectionResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -124,7 +124,7 @@ func GetReoprtSearchList(condition string, userId, startSize, pageSize int) (ite
 	return
 } //end
 
-//列表
+// 列表
 func GetSearchResourceList(condition string) (items []*IndustrialManagement, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -145,7 +145,7 @@ func GetSearchResourceList(condition string) (items []*IndustrialManagement, err
 	return
 }
 
-//标的列表
+// 标的列表
 func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -170,7 +170,7 @@ func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err
 	return
 } //end
 
-//产业下所关联的文章分类列表
+// 产业下所关联的文章分类列表
 func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int) (items []*IndustrialToArticleCategoryRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT map.match_type_name,map.category_id
@@ -188,7 +188,7 @@ func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int)
 	return
 }
 
-//判断用户是否阅读该产业下,某一分类的文章
+// 判断用户是否阅读该产业下,某一分类的文章
 func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -202,7 +202,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 category_id = ? ORDER BY publish_date DESC LIMIT 0, 1`
@@ -210,7 +210,7 @@ func GetNewIndustrialUserRecordArticle(industrialManagementId, categoryId int) (
 	return
 }
 
-//列表
+// 列表
 func GetReoprtSearchListHz(condition string, userId int) (items []*ArticleCollectionResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -236,7 +236,7 @@ func GetReoprtSearchListHz(condition string, userId int) (items []*ArticleCollec
 	return
 } //end
 
-//产业列表
+// 产业列表
 func GetSearchResourceListHz(condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -259,7 +259,7 @@ func GetSearchResourceListHz(condition string, startSize, pageSize int) (items [
 	return
 }
 
-//用户收藏榜start
+// 用户收藏榜start
 type IndustrialManagementHotResp struct {
 	IndustrialManagementId int                  `orm:"column(industrial_management_id);pk" description:"产业id"`
 	IndustryName           string               `description:"产业名称"`
@@ -270,17 +270,18 @@ type IndustrialManagementHotResp struct {
 	PublishDate            string               `description:"发布时间"`
 	ArticleReadNum         int                  `description:"文章阅读数量"`
 	Source                 int                  `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	MinReportTime          string               `description:"报告最早发布时间"`
 	IndustrialSubjectList  []*IndustrialSubject `description:"标的列表"`
 }
 
-//搜索资源包 start
+// 搜索资源包 start
 type SearchReportAndResourceResp struct {
 	ListHzResource []*IndustrialManagement  `description:"弘则资源包"`
 	ListHzReport   []*ArticleCollectionResp `description:"弘则报告"`
 	Paging         *paging.PagingItem       `description:"弘则报告分页"`
 }
 
-//报告收藏榜单列表
+// 报告收藏榜单列表
 func GetReportCollectionBillboardList(limit int, pars []interface{}, condition string) (items []*ArticleListResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -308,7 +309,7 @@ func GetReportCollectionBillboardList(limit int, pars []interface{}, condition s
 	return
 }
 
-//研选报告收藏榜单列表
+// 研选报告收藏榜单列表
 func GetReportCollectionBillboardListYx(limit int, pars []interface{}, condition string) (items []*ArticleListResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -335,7 +336,7 @@ func GetReportCollectionBillboardListYx(limit int, pars []interface{}, condition
 	return
 }
 
-//获取产业报告+晨会点评列表
+// 获取产业报告+晨会点评列表
 func GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize int) (items []*HomeArticle, total int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -374,7 +375,7 @@ type IndustrialPublishdate struct {
 	IndustrialManagementId int    `description:"产业D"`
 }
 
-//标的列表
+// 标的列表
 func GetTimeLineReportIndustrialPublishdateList(industrialIdArr []int) (items []*IndustrialPublishdate, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT	
@@ -395,7 +396,7 @@ func GetTimeLineReportIndustrialPublishdateList(industrialIdArr []int) (items []
 	return
 }
 
-//报告榜单start
+// 报告榜单start
 type ArticleReportBillboardResp struct {
 	ArticleId      int    `description:"文章id"`
 	Title          string `description:"标题"`
@@ -413,4 +414,194 @@ type ArticleReportBillboardResp struct {
 type ArticleReportBillboardLIstPageResp struct {
 	List   []*ArticleReportBillboardResp
 	Paging *paging.PagingItem
-}
+}
+
+type ArticleResearchListResp struct {
+	Paging *paging.PagingItem
+	List   []*ArticleResearchResp
+}
+
+type ArticleResearchResp struct {
+	ArticleId       int                          `description:"文章id"`
+	Title           string                       `description:"标题"`
+	Annotation      string                       `description:"核心观点"`
+	Abstract        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:"按钮展示样式"`
+	ImgUrlPc        string                       `description:"图片链接"`
+	List            []*IndustrialManagementIdInt `description:"产业列表"`
+	ListSubject     []*IndustrialSubject         `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 []*ArticleListResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			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 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
+}
+
+type IndustrialManagementHotListResp struct {
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*IndustrialManagementHotResp
+}
+
+// 获取数量
+func GetThemeHeatListCount(condition string) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT   COUNT( DISTINCT m.industrial_management_id ) 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.article_type_id > 0 AND a.publish_status = 1  ` + condition
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}
+
+// 产业列表
+func GetThemeHeatList(userId int, condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			m.industry_name,
+			m.industrial_management_id,
+			m.article_read_num,
+          	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
+		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.article_type_id > 0
+			AND publish_status = 1 
+			GROUP BY m.industrial_management_id ` + condition + ` LIMIT ?,?`
+	_, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type GetThemeAericleListResp 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:"收藏人数"`
+	FllowNum            int    `description:"关注数量"`
+	MyCollectNum        int    `description:"本人是否收藏"`
+	IsCollect           bool   `description:"本人是否收藏"`
+}
+
+// 主题详情start
+type GetThemeDetailResp struct {
+	IndustrialManagementId int                  `description:"产业Id"`
+	IndustryName           string               `description:"产业名称"`
+	IsFollw                bool                 `description:"是否关注"`
+	ListSubject            []*IndustrialSubject `description:"标的列表"`
+	List                   []*ArticleResearchResp
+}
+
+// 主题详情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 GetThemeAericleListBuSubjectResp struct {
+	SubjectName string `description:"标的名称"`
+	List        []*GetThemeAericleListResp
+}
+
+// 列表
+func GetThemeDetail(userId, industrialManagementId int, condition string) (items []*ArticleListResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			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 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 m.industrial_management_id = ? 
+			AND publish_status = 1 ` + condition + `
+		ORDER BY
+			publish_date DESC`
+	_, err = o.Raw(sql, userId, industrialManagementId).QueryRows(&items)
+	return
+} //end

+ 45 - 0
routers/commentsRouter.go

@@ -385,6 +385,51 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"],
+        beego.ControllerComments{
+            Method: "ArticleNewList",
+            Router: `/article/newList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"],
+        beego.ControllerComments{
+            Method: "ArticleType",
+            Router: `/article/typeList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"],
+        beego.ControllerComments{
+            Method: "HotList",
+            Router: `/hotList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"],
+        beego.ControllerComments{
+            Method: "KolList",
+            Router: `/kolList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"],
+        beego.ControllerComments{
+            Method: "ThemeDetail",
+            Router: `/theme/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileSearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileSearchController"],
         beego.ControllerComments{
             Method: "BrowseHistoryList",

+ 5 - 1
routers/router.go

@@ -101,7 +101,11 @@ func init() {
 				&controllers.AdviceController{},
 			),
 		),
-
+		web.NSNamespace("/research",
+			web.NSInclude(
+				&controllers.MobileResearchController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 0 - 1
services/activity_special.go

@@ -633,7 +633,6 @@ func GetActivitySpecialSearcheList(user *models.WxUserItem, condition string, st
 		err = errors.New("GetActivitySpecialSearcheList, Err: " + e.Error())
 		return
 	}
-
 	keyWordArr, e := GetIndustryMapNameSliceV3(keywords)
 	if e != nil {
 		err = errors.New("GetActivityonditionList, Err: " + e.Error())

+ 27 - 7
services/article.go

@@ -31,7 +31,7 @@ func FixArticleImgUrl(body string) (contentSub string, err error) {
 	return
 }
 
-//GetReportContentTextSubByarticle 解析文章内容
+// GetReportContentTextSubByarticle 解析文章内容
 func GetReportContentTextSubByarticle(content, abstract string, articleId int) (contentSub string, err error) {
 	var lenabstract int
 	//如果不是研选就这么展示
@@ -81,7 +81,7 @@ func GetReportContentTextArticleBody(content string) (contentSub string) {
 	return
 }
 
-//HandleArticleCategoryImg 预处理文章的封面图片
+// HandleArticleCategoryImg 预处理文章的封面图片
 func HandleArticleCategoryImg(list []*models.ArticleListResp) (items []*models.ArticleListResp, err error) {
 	//研选的五张图片
 	detailResearch, e := models.GetConfigByCode("category_research_img_url")
@@ -202,7 +202,7 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp) (items []*models.A
 	return
 }
 
-//HandleArticleStock 处理报告关联的个股标签
+// HandleArticleStock 处理报告关联的个股标签
 func HandleArticleStock(stock string) (items []*models.ComapnyNameResp) {
 	sliceSubjects := strings.Split(stock, "/")
 	if len(sliceSubjects) > 0 {
@@ -216,7 +216,7 @@ func HandleArticleStock(stock string) (items []*models.ComapnyNameResp) {
 	return
 }
 
-//弘则报告发布日期在三个月以内的
+// 弘则报告发布日期在三个月以内的
 func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
 	var condition string
 	var pars []interface{}
@@ -265,7 +265,7 @@ func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
 	return
 }
 
-//GetSpecialArticleDetailUserPower 处理用户查看专项调研文章详情的权限
+// GetSpecialArticleDetailUserPower 处理用户查看专项调研文章详情的权限
 func GetSpecialArticleDetailUserPower(user *models.WxUserItem, articleInfo *models.ArticleDetail) (havePower bool, err error) {
 	permissionStr, e := GetCompanyPermissionUpgrade(user.CompanyId)
 	if e != nil {
@@ -316,7 +316,7 @@ func GetReportContentTextSubNew(content string) (contentSub string, err error) {
 	return
 }
 
-//处理核心观点的展示规则
+// 处理核心观点的展示规则
 func ArticleAnnotation(item *models.ArticleListResp) (annotation string) {
 	if item.ArticleId >= utils.SummaryArticleId {
 		item.Annotation = YxArticleAnnotation(item)
@@ -388,7 +388,7 @@ func ArticleAnnotation(item *models.ArticleListResp) (annotation string) {
 	return
 }
 
-//解析研选内容中的核心观点
+// 解析研选内容中的核心观点
 func YxArticleAnnotation(article *models.ArticleListResp) (annotation string) {
 	//如果不规范,就获取内容主体
 	if strings.Count(article.Body, "<hr") == 0 {
@@ -439,3 +439,23 @@ func YxArticleAnnotation(article *models.ArticleListResp) (annotation string) {
 	annotation = body
 	return
 }
+
+// 获取研选类型的文章分类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
+}

+ 69 - 3
services/industrial_management.go

@@ -8,7 +8,7 @@ import (
 	"time"
 )
 
-//根据行业处理所选的全部赛道字段
+// 根据行业处理所选的全部赛道字段
 func DoXzsChooseSend(chartPermissionName string) string {
 	var allIn string
 	if chartPermissionName == utils.YI_YAO_NAME {
@@ -25,7 +25,7 @@ func DoXzsChooseSend(chartPermissionName string) string {
 	return allIn
 }
 
-//行业关注或者取消关注的时候,对于用户全部赛道的影响
+// 行业关注或者取消关注的时候,对于用户全部赛道的影响
 func IndustryFllowWithTrack(industrialManagementId, count, uid int) (err error) {
 	defer func() {
 		if err != nil {
@@ -76,7 +76,7 @@ func IndustryFllowWithTrack(industrialManagementId, count, uid int) (err error)
 	return err
 }
 
-//HandleIndustryList预处理产业列表字段
+// HandleIndustryList预处理产业列表字段
 func HandleIndustryList(list []*models.IndustrialManagement, user *models.WxUserItem) (items []*models.IndustrialManagement, err error) {
 	userId := user.UserId
 	fllowList, err := models.GetUserFllowIndustrialList(userId)
@@ -220,3 +220,69 @@ 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
+}
+
+// GetUserFollowIndustrialMap获取用户关注的产业
+func GetUserFollowIndustrialMap(user *models.WxUserItem) (mapResp map[int]int, err error) {
+	list, e := models.GetUserFllowIndustrialList(user.UserId)
+	if e != nil {
+		err = errors.New("GetUserFllowIndustrialList " + e.Error())
+		return
+	}
+	fllowMap := make(map[int]int)
+	if len(list) > 0 {
+		for _, v := range list {
+			fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
+		}
+	}
+	mapResp = fllowMap
+	return
+}

+ 42 - 0
services/industrial_subject.go

@@ -0,0 +1,42 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+)
+
+// GetArticleGroupSubjectMap 获取文章所关联的标的
+func GetArticleGroupSubjectMap(articleIds []int) (mapResp map[int][]*models.IndustrialSubject, listSubtect []*models.IndustrialSubject, err error) {
+	lenArticleIds := len(articleIds)
+	if lenArticleIds == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND g.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
+	pars = append(pars, articleIds)
+	list, e := models.GetArticleGroupSubjectList(pars, condition)
+	if e != nil {
+		err = errors.New("GetArticleGroupSubjectList " + e.Error())
+		return
+	}
+	listMap := make(map[int][]*models.IndustrialSubject)
+	mapName := make(map[int]int)
+	if len(list) > 0 {
+		for _, v := range list {
+			item := models.IndustrialSubject{
+				IndustrialSubjectId:    v.IndustrialSubjectId,
+				IndustrialManagementId: v.IndustrialManagementId,
+				SubjectName:            v.SubjectName,
+			}
+			listMap[v.ArticleId] = append(listMap[v.ArticleId], &item)
+			if _, ok := mapName[v.IndustrialSubjectId]; !ok {
+				listSubtect = append(listSubtect, &item)
+			}
+			mapName[v.IndustrialSubjectId] = v.IndustrialManagementId
+		}
+	}
+	mapResp = listMap
+	return
+}