Browse Source

no message

xingzai 2 years ago
parent
commit
1e1c87e5b0
3 changed files with 54 additions and 18 deletions
  1. 43 9
      controllers/report.go
  2. 2 0
      models/home.go
  3. 9 9
      routers/commentsRouter.go

+ 43 - 9
controllers/report.go

@@ -1262,12 +1262,18 @@ func (this *ReportCommonController) CompanyList() {
 // @Param   IndustrialManagementId   query   int  false       "产业ID"
 // @Success 200 {object} models.TacticsListResp
 // @router /timeline [get]
-func (this *ReportCommonController) Timeline() {
+func (this *MobileReportController) Timeline() {
 	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")
 	industrialManagementId, _ := this.GetInt("IndustrialManagementId")
@@ -1290,16 +1296,44 @@ func (this *ReportCommonController) Timeline() {
 		br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
 		return
 	}
-	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) //时间字符串格式转时间格式
+	//查询用户今天是否看过时间线
+	count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
+	if err != nil {
+		br.Msg = "查询浏览记录数量失败"
+		br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
+		return
+	}
+	var recordItem *models.CygxPageHistoryRecord
+	if count > 1 {
+		recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
+		if err != nil {
+			br.Msg = "查询浏览记录失败"
+			br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
+			return
+		}
+	}
+	//lenList := len(list)
+	for k, v := range list {
+		item := v
+		list[k].Body = ""
+		list[k].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
+		list[k].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
+		list[k].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
 		//行业比较研究、资金流向,显示报告的摘要
 		if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
-			list[i].Annotation = list[i].Abstract
+			list[k].Annotation = list[k].Abstract
+		}
+		if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
+			list[k].IsRed = true
+		}
+		timeLineRed := false
+		if count < 2 && v.SubCategoryName == "时间线" {
+			timeLineRed = true
+		} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
+			timeLineRed = true
+		}
+		if v.SubCategoryName == "时间线" && timeLineRed {
+			list[k].IsRed = true
 		}
 	}
 	if len(list) == 0 {

+ 2 - 0
models/home.go

@@ -40,6 +40,8 @@ type HomeArticle struct {
 	Annotation      string               `description:"核心观点"`
 	ArticleTypeId   int                  `description:"文章类型ID判断是否是研选使用"`
 	HomeType        int                  `description:"数据类型:0-纪要(默认); 1-微路演音频"`
+	Readnum         int                  `description:"阅读数量"`
+	IsRed           bool                 `description:"是否标红"`
 	MicroAudio      *MicroAudioUnionList `description:"微路演音频"`
 	List            []*IndustrialManagementIdInt
 }

+ 9 - 9
routers/commentsRouter.go

@@ -385,6 +385,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"],
+        beego.ControllerComments{
+            Method: "Timeline",
+            Router: `/timeline`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"],
         beego.ControllerComments{
             Method: "ArticleCategoryList",
@@ -511,15 +520,6 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ReportCommonController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ReportCommonController"],
-        beego.ControllerComments{
-            Method: "Timeline",
-            Router: `/timeline`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ReportController"],
         beego.ControllerComments{
             Method: "CategoryFllow",