Browse Source

no message

xingzai 2 years ago
parent
commit
66fa59bb7e
3 changed files with 50 additions and 28 deletions
  1. 35 27
      controllers/report.go
  2. 14 0
      models/home.go
  3. 1 1
      models/report.go

+ 35 - 27
controllers/report.go

@@ -508,7 +508,7 @@ func (this *MobileReportController) List() {
 	var total int
 	var total int
 	resp := new(models.TacticsListResp)
 	resp := new(models.TacticsListResp)
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	page := paging.GetPaging(currentIndex, pageSize, total)
-	list := make([]*models.HomeArticle, 0)
+	list := make([]*models.ArticleListResp, 0)
 
 
 	if categoryId == utils.TIME_CATEGORYID {
 	if categoryId == utils.TIME_CATEGORYID {
 		var err error
 		var err error
@@ -567,17 +567,6 @@ func (this *MobileReportController) List() {
 			imgUrlChart = vslice[len(vslice)-1]
 			imgUrlChart = vslice[len(vslice)-1]
 			mapCategoryUrl[categoryIdStr] = imgUrlChart
 			mapCategoryUrl[categoryIdStr] = imgUrlChart
 		}
 		}
-
-		//condition += ` AND category_id_two=? `
-		//pars = append(pars, categoryId)
-
-		//categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(categoryId)
-		//if errCategory != nil {
-		//	br.Msg = "获取信息失败"
-		//	br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
-		//	return
-		//}
-		//fmt.Println(detail.PolymerizationId)
 		if detail.CeLueFieldId != "" {
 		if detail.CeLueFieldId != "" {
 			condition = ` AND ce_lue_field_id IN(` + detail.CeLueFieldId + `)`
 			condition = ` AND ce_lue_field_id IN(` + detail.CeLueFieldId + `)`
 		} else if detail.PolymerizationId != "" {
 		} else if detail.PolymerizationId != "" {
@@ -618,7 +607,7 @@ func (this *MobileReportController) List() {
 			return
 			return
 		}
 		}
 
 
-		list, err = models.GetHomeList(condition, pars, startSize, pageSize)
+		list, err = models.GetHomeListNew(condition, pars, startSize, pageSize)
 		if err != nil {
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.Msg = "获取信息失败"
 			br.Msg = "获取帖子数据失败,Err:" + err.Error()
 			br.Msg = "获取帖子数据失败,Err:" + err.Error()
@@ -647,23 +636,42 @@ func (this *MobileReportController) List() {
 		}
 		}
 		resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
 		resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
 	}
 	}
-	lenList := len(list)
-	for i := 0; i < lenList; i++ {
-		item := list[i]
-		list[i].Body = ""
-		list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
-		list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
-		list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
-		//行业比较研究、资金流向,显示报告的摘要
-		if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
-			list[i].Annotation = list[i].Abstract
-		}
+
+	listPublic, err := services.HandleArticleCategoryImg(list, user)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
+		return
 	}
 	}
-	if len(list) == 0 {
-		list = make([]*models.HomeArticle, 0)
+	listResp := make([]*models.HomeArticle, 0)
+	//listResp :=
+	for _, v := range listPublic {
+		listResp = append(listResp, &models.HomeArticle{
+			ArticleId:   v.ArticleId,
+			Title:       v.Title,
+			Annotation:  v.Annotation,
+			Abstract:    v.Abstract,
+			ImgUrlPc:    v.ImgUrlPc,
+			PublishDate: v.PublishDate,
+		})
+	}
+	//lenList := len(list)
+	//for i := 0; i < lenList; i++ {
+	//	item := list[i]
+	//	list[i].Body = ""
+	//	list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
+	//	list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
+	//	list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
+	//	//行业比较研究、资金流向,显示报告的摘要
+	//	if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
+	//		list[i].Annotation = list[i].Abstract
+	//	}
+	//}
+	if len(listResp) == 0 {
+		listResp = make([]*models.HomeArticle, 0)
 	}
 	}
 	page = paging.GetPaging(currentIndex, pageSize, total)
 	page = paging.GetPaging(currentIndex, pageSize, total)
-	resp.List = list
+	resp.List = listResp
 	resp.Paging = page
 	resp.Paging = page
 	br.Ret = 200
 	br.Ret = 200
 	br.Success = true
 	br.Success = true

+ 14 - 0
models/home.go

@@ -69,6 +69,7 @@ type ArticleListResp struct {
 	DepartmentId        int    `description:"作者Id"`
 	DepartmentId        int    `description:"作者Id"`
 	NickName            string `description:"作者昵称"`
 	NickName            string `description:"作者昵称"`
 	IsCollect           bool   `description:"本人是否收藏"`
 	IsCollect           bool   `description:"本人是否收藏"`
+	IsRed               bool   `description:"是否标红"`
 	CollectNum          int    `description:"收藏人数"`
 	CollectNum          int    `description:"收藏人数"`
 	List                []*IndustrialManagementIdInt
 	List                []*IndustrialManagementIdInt
 }
 }
@@ -122,6 +123,19 @@ func GetHomeList(condition string, pars []interface{}, startSize, pageSize int)
 	return
 	return
 }
 }
 
 
+func GetHomeListNew(condition string, pars []interface{}, startSize, pageSize int) (items []*ArticleListResp, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
+                 FROM cygx_article AS a
+                WHERE a.publish_status=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
 // 获取产业报告列表
 // 获取产业报告列表
 func GetReportIndustrialList(condition string, pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*HomeArticle, err error) {
 func GetReportIndustrialList(condition string, pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*HomeArticle, err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()

+ 1 - 1
models/report.go

@@ -390,7 +390,7 @@ func GetReportCollectionBillboardListYx(limit int, pars []interface{}, condition
 }
 }
 
 
 // 获取产业报告+晨会点评列表
 // 获取产业报告+晨会点评列表
-func GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize int) (items []*HomeArticle, total int, err error) {
+func GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize int) (items []*ArticleListResp, total int, err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()
 	sql := `SELECT
 	sql := `SELECT
 			a.id,
 			a.id,