xingzai 1 rok pred
rodič
commit
2ea67552d6
3 zmenil súbory, kde vykonal 132 pridanie a 2 odobranie
  1. 25 2
      controllers/report.go
  2. 59 0
      models/report.go
  3. 48 0
      services/article_industry_label.go

+ 25 - 2
controllers/report.go

@@ -2880,6 +2880,7 @@ func (this *ReportController) SearchReportAndResource() {
 	keyWord := this.GetString("KeyWord")
 	pageSize, _ := this.GetInt("PageSize")
 	var condition string
+	var conditionSpecial string // 研选专栏
 	var sqlGroup string
 	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
 	if err != nil {
@@ -2900,7 +2901,8 @@ func (this *ReportController) SearchReportAndResource() {
 	} else {
 		sqlGroup += ` LIMIT 100 `
 	}
-	ListYxReport, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+articleTypeIds+`) `+condition+sqlGroup, user.UserId)
+	conditionSpecial = ` AND ( a.title LIKE  '%` + keyWord + `%' OR  a.content LIKE '%` + keyWord + `%' )`
+	ListYxReport, err := models.GetArticleAndYxSpecialList(` AND a.article_type_id IN (`+articleTypeIds+`) `+condition, conditionSpecial, user.UserId)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取研选文章列表失败,Err:" + err.Error()
@@ -2975,8 +2977,29 @@ func (this *ReportController) SearchReportAndResource() {
 	for _, v := range ListHzReport {
 		articleIds += strconv.Itoa(v.ArticleId) + ","
 	}
-	for _, v := range ListYxReport {
+	for i, v := range ListYxReport {
 		articleIds += strconv.Itoa(v.ArticleId) + ","
+
+		if v.ArticleTypeId == -1 {
+			ListYxReport[i].ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
+		} else if v.ArticleTypeId > 0 {
+			ListYxReport[i].ArticleTypeName = utils.CYGX_YANXUAN_ARTICLE
+		}
+		if v.SpecialType == 1 {
+			ListYxReport[i].Title = "【笔记】" + ListYxReport[i].Title
+		} else if ListYxReport[i].SpecialType == 2 {
+			ListYxReport[i].Title = "【观点】" + ListYxReport[i].Title
+		}
+		if v.CompanyTags != "" {
+			v.SpecialTags += v.CompanyTags
+		}
+		if v.IndustryTags != "" {
+			if v.SpecialTags != "" {
+				v.SpecialTags += ","
+			}
+			v.SpecialTags += v.IndustryTags
+		}
+		v.SpecialTags = v.SpecialTags
 	}
 	articleIds = strings.TrimRight(articleIds, ",")
 	silcearticleIds := strings.Split(articleIds, ",")

+ 59 - 0
models/report.go

@@ -509,6 +509,7 @@ type ArticleCollectionResp struct {
 	SpecialType            int                         `description:"专栏类型 1:笔记,2:观点"`
 	IndustryTags           string                      `description:"研选专栏行业标签"`
 	CompanyTags            string                      `description:"研选专栏公司标签"`
+	ArticleTypeName        string                      `description:"文章类型名称"`
 }
 
 type IndustrialManagementResp struct {
@@ -586,6 +587,64 @@ func GetArticleCollectionList(condition string, userId int) (items []*ArticleCol
 	return
 } //end
 
+// 资源包研选跟研选专栏的搜索
+func GetArticleAndYxSpecialList(condition, conditionSpecial 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,
+			d.nick_name,
+			d.department_id,
+			a.article_type_id,
+			0 AS is_special,
+			"" AS special_tags,
+			"" AS company_tags,
+			"" AS industry_tags,
+			( 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,
+			'' AS special_type,
+			'' AS user_id,
+			'' AS create_time 
+		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 ` + condition + `  GROUP BY article_id 
+			UNION ALL
+		SELECT
+			a.id AS article_id,
+			a.title AS title,
+			date_format( a.publish_time, '%Y-%m-%d' ) AS publish_date,
+			"" AS nick_name,
+			0 AS department_id,
+			- 1 AS article_type_id,
+			1 AS is_special,
+			a.tags AS special_tags,
+			a.company_tags,
+			a.industry_tags,
+			( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
+			( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
+			( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num,
+			a.type AS special_type,
+			a.user_id AS user_id,
+			c.create_time AS create_time 
+		FROM
+			cygx_yanxuan_special AS a
+			JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
+			JOIN cygx_yanxuan_special_collect AS c ON a.id = c.yanxuan_special_id 
+		WHERE
+			1 = 1 
+			AND a.STATUS = 3 ` + conditionSpecial + ` ORDER BY publish_date DESC  LIMIT 30`
+
+	_, err = o.Raw(sql, userId, userId).QueryRows(&items)
+	return
+} //end
+
 type ArticleResearchListResp struct {
 	Paging *paging.PagingItem
 	List   []*ArticleResearchResp

+ 48 - 0
services/article_industry_label.go

@@ -0,0 +1,48 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+)
+
+// 文章关联产业标签处理List
+func GetArticleIndustrialLabelMapListByArticleids(articleIds []int) (mapResp map[int][]*models.IndustrialManagementIdInt) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("文章关联产业标签处理,信息失败,GetArticleIndustrialLabelMapListByArticleids Err:"+err.Error(), articleIds), 3)
+		}
+	}()
+	lenIds := len(articleIds)
+	if lenIds == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	//获取文章关联的产业
+	pars = make([]interface{}, 0)
+	condition = ` AND mg.article_id IN (  ` + utils.GetOrmInReplace(len(articleIds)) + ` )  `
+	pars = append(pars, articleIds)
+	industrialList, e := models.GetIndustrialListByarticleId(pars, condition)
+	if e != nil && e.Error() != utils.RunMode {
+		err = errors.New("GetIndustrialListByarticleId, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int][]*models.IndustrialManagementIdInt, 0)
+	if len(industrialList) > 0 {
+		for _, v := range industrialList {
+			item := new(models.IndustrialManagementIdInt)
+			item.ArticleId = v.ArticleId
+			if v.ArticleId > utils.SummaryArticleId {
+				item.IsResearch = true
+			}
+			item.IndustrialManagementId = v.IndustrialManagementId
+			item.IndustryName = v.IndustryName
+			mapResp[v.ArticleId] = append(mapResp[v.ArticleId], item)
+		}
+	}
+	return
+}