Browse Source

我的收藏,用户足迹

xingzai 2 years ago
parent
commit
de01fc999d
5 changed files with 105 additions and 23 deletions
  1. 88 16
      controllers/user.go
  2. 3 1
      models/article.go
  3. 1 0
      models/industrial_management.go
  4. 11 4
      models/report.go
  5. 2 2
      models/user.go

+ 88 - 16
controllers/user.go

@@ -409,11 +409,45 @@ func (this *UserController) CollectList() {
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
+	var condition string
+	var pars []interface{}
 	var articleIds []string
 	for _, v := range list {
 		articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
 	}
 	articleIdStr := strings.Join(articleIds, ",")
+
+	//获取文章关联的产业
+	pars = make([]interface{}, 0)
+	condition = ` AND mg.article_id IN (  ` + utils.GetOrmInReplace(len(articleIds)) + ` )  `
+	pars = append(pars, articleIds)
+	industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,GetSubjectList Err:" + err.Error()
+		return
+	}
+	industrialMap := make(map[int][]*models.IndustrialManagementIdInt)
+	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
+			industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
+		}
+	}
+	for k, v := range list {
+		if len(industrialMap[v.ArticleId]) > 0 {
+			list[k].List = industrialMap[v.ArticleId]
+		} else {
+			list[k].List = make([]*models.IndustrialManagementIdInt, 0)
+		}
+	}
+
 	articleMap := make(map[int]*models.ArticleDetail)
 	if articleIdStr != "" {
 		articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
@@ -433,17 +467,19 @@ func (this *UserController) CollectList() {
 		item := list[i]
 		article := articleMap[item.ArticleId]
 		list[i].Title = article.Title
-		list[i].TitleEn = article.TitleEn
-		list[i].UpdateFrequency = article.UpdateFrequency
-		list[i].CreateDate = article.CreateDate
+		list[i].DepartmentId = article.DepartmentId
+		list[i].NickName = article.NickName
+		//list[i].TitleEn = article.TitleEn
+		//list[i].UpdateFrequency = article.UpdateFrequency
+		//list[i].CreateDate = article.CreateDate
 		list[i].PublishDate = article.PublishDate
-		list[i].Body, _ = services.GetReportContentTextSub(article.Body)
-		list[i].Abstract = article.Abstract
-		list[i].CategoryName = article.CategoryName
-		list[i].SubCategoryName = article.SubCategoryName
+		//list[i].Body, _ = services.GetReportContentTextSub(article.Body)
+		//list[i].Abstract = article.Abstract
+		//list[i].CategoryName = article.CategoryName
+		//list[i].SubCategoryName = article.SubCategoryName
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
-	resp := new(models.ArticleCollectListResp)
+	resp := new(models.ArticleReportBillboardLIstPageResp)
 	resp.List = list
 	resp.Paging = page
 	br.Msg = "获取成功!"
@@ -572,10 +608,44 @@ func (this *UserController) BrowseHistoryList() {
 		return
 	}
 	var articleIds []string
+	var condition string
+	var pars []interface{}
 	for _, v := range list {
 		articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
 	}
 	articleIdStr := strings.Join(articleIds, ",")
+
+	//获取文章关联的产业
+	pars = make([]interface{}, 0)
+	condition = ` AND mg.article_id IN (  ` + utils.GetOrmInReplace(len(articleIds)) + ` )  `
+	pars = append(pars, articleIds)
+	industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,GetSubjectList Err:" + err.Error()
+		return
+	}
+	industrialMap := make(map[int][]*models.IndustrialManagementIdInt)
+	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
+			industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
+		}
+	}
+	for k, v := range list {
+		if len(industrialMap[v.ArticleId]) > 0 {
+			list[k].List = industrialMap[v.ArticleId]
+		} else {
+			list[k].List = make([]*models.IndustrialManagementIdInt, 0)
+		}
+	}
+
 	articleMap := make(map[int]*models.ArticleDetail)
 	if articleIdStr != "" {
 		articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
@@ -596,18 +666,20 @@ func (this *UserController) BrowseHistoryList() {
 		article := articleMap[item.ArticleId]
 		if article != nil {
 			list[i].Title = article.Title
-			list[i].TitleEn = article.TitleEn
-			list[i].UpdateFrequency = article.UpdateFrequency
-			list[i].CreateDate = article.CreateDate
 			list[i].PublishDate = article.PublishDate
-			list[i].Body, _ = services.GetReportContentTextSub(article.Body)
-			list[i].Abstract = article.Abstract
-			list[i].CategoryName = article.CategoryName
-			list[i].SubCategoryName = article.SubCategoryName
+			list[i].DepartmentId = article.DepartmentId
+			list[i].NickName = article.NickName
+			//list[i].TitleEn = article.TitleEn
+			//list[i].UpdateFrequency = article.UpdateFrequency
+			//list[i].CreateDate = article.CreateDate
+			//list[i].Body, _ = services.GetReportContentTextSub(article.Body)
+			//list[i].Abstract = article.Abstract
+			//list[i].CategoryName = article.CategoryName
+			//list[i].SubCategoryName = article.SubCategoryName
 		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
-	resp := new(models.ArticleBrowseHistoryListResp)
+	resp := new(models.ArticleReportBillboardLIstPageResp)
 	resp.List = list
 	resp.Paging = page
 	br.Msg = "获取成功!"

+ 3 - 1
models/article.go

@@ -184,7 +184,9 @@ func GetArticleDetailByIdMd5(articleIdMd5 string) (item *ArticleDetail, err erro
 
 func GetArticleDetailByIdStr(articleIdStr string) (items []*ArticleDetail, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_article WHERE article_id IN(` + articleIdStr + `) `
+	sql := `SELECT 	art.*,d.nick_name FROM
+			cygx_article AS art
+			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
 }

+ 1 - 0
models/industrial_management.go

@@ -236,6 +236,7 @@ type IndustrialManagementIdInt struct {
 	IndustryName           string `description:"产业名称"`
 	SubjectName            string `description:"标的名称"`
 	ArticleId              int    `description:"文章ID"`
+	IsResearch             bool   `description:"是否属于研选"`
 }
 
 type IndustrialManagementIdInts struct {

+ 11 - 4
models/report.go

@@ -692,16 +692,23 @@ type ReportBillboardTableListResp struct {
 
 //报告榜单start
 type ArticleReportBillboardResp struct {
-	ArticleId   int    `description:"文章id"`
-	Title       string `description:"标题"`
-	PublishDate string `description:"发布时间"`
-	List        []*IndustrialManagementIdInt
+	ArticleId    int    `description:"文章id"`
+	Title        string `description:"标题"`
+	PublishDate  string `description:"发布时间"`
+	DepartmentId int    `description:"作者Id"`
+	NickName     string `description:"作者昵称"`
+	List         []*IndustrialManagementIdInt
 }
 
 type ArticleReportBillboardLIstResp struct {
 	List []*ArticleReportBillboardResp
 }
 
+type ArticleReportBillboardLIstPageResp struct {
+	List   []*ArticleReportBillboardResp
+	Paging *paging.PagingItem
+}
+
 //报告收藏榜单列表
 func GetReportCollectionBillboardList(pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
 	o := orm.NewOrm()

+ 2 - 2
models/user.go

@@ -153,7 +153,7 @@ func GetArticleUserCollectCount(userId int) (count int, err error) {
 	return
 }
 
-func GetArticleUserCollectList(startSize, pageSize, userId int) (items []*ArticleCollectList, err error) {
+func GetArticleUserCollectList(startSize, pageSize, userId int) (items []*ArticleReportBillboardResp, err error) {
 	sql := `SELECT a.* FROM cygx_article_collect AS a INNER JOIN cygx_article as art ON art.article_id = a.article_id
 			WHERE a.user_id=? 
            ORDER BY a.create_time DESC LIMIT ?,? `
@@ -193,7 +193,7 @@ func GetArticleUserBrowseHistoryCount(userId int, endDate string) (count int, er
 	return
 }
 
-func GetArticleUserBrowseHistoryList(startSize, pageSize, userId int, endDate string) (items []*ArticleInterviewApplyList, err error) {
+func GetArticleUserBrowseHistoryList(startSize, pageSize, userId int, endDate string) (items []*ArticleReportBillboardResp, err error) {
 	sql := `SELECT a.* FROM cygx_article_history_record AS a
 			WHERE a.user_id=? AND a.create_time>=?  GROUP BY a.article_id
            ORDER BY a.id DESC LIMIT ?,? `