Explorar o código

Merge branch 'cygx_v2' of hongze/hongze_cygx into master

hongze %!s(int64=3) %!d(string=hai) anos
pai
achega
07f76de2ca
Modificáronse 5 ficheiros con 37 adicións e 8 borrados
  1. 7 1
      controllers/chart_permission.go
  2. 12 5
      controllers/report.go
  3. 1 1
      controllers/tactics.go
  4. 16 0
      models/report.go
  5. 1 1
      utils/config.go

+ 7 - 1
controllers/chart_permission.go

@@ -93,7 +93,13 @@ func (this *ChartPermissionAuthController) StrategyDetail() {
 			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 			return
 		}
-		if count == 0 {
+		Newdetail, err := models.GetNewArticleByCategoryId(v.CategoryId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
 			list[k].IsRed = true
 		}
 	}

+ 12 - 5
controllers/report.go

@@ -58,7 +58,7 @@ func (this *ReportController) TradeList() {
 			br.Msg = "获取帖子总数失败,Err:" + err.Error()
 			return
 		}
-		if count == 0 {
+		if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
 			list[k].IsRed = true
 		}
 	}
@@ -73,7 +73,7 @@ func (this *ReportController) TradeList() {
 // @Title 产业报告分类列表接口
 // @Description 获取产业报告分类列表接口
 // @Param   ChartPermissionId   query   int  true       "分类ID"
-// @Param   OrderColumn   query   int  true       "排序字段 ,NewTime最近更新 ,Recommend弘则推荐"
+// @Param   OrderColumn   query   int  true       "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Success 200 {object} models.IndustrialManagementList
@@ -210,7 +210,8 @@ func (this *ReportController) IndustryList() {
 			br.ErrMsg = "获取信息失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(newArtinfo.ArticleId)
 			return
 		}
-		if recordCount == 0 {
+		//
+		if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
 			list[k].IsRed = true
 		}
 	}
@@ -259,7 +260,13 @@ func (this *ReportController) ArticleCategoryList() {
 			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 			return
 		}
-		if recordCount == 0 {
+		Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
 			list[k].IsRed = true
 		}
 	}
@@ -350,7 +357,7 @@ func (this *ReportController) List() {
 	}
 
 	for k, v := range list {
-		if v.Readnum == 0 {
+		if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
 			list[k].IsRed = true
 		}
 	}

+ 1 - 1
controllers/tactics.go

@@ -99,7 +99,7 @@ func (this *TacticsController) List() {
 	}
 
 	for k, v := range list {
-		if v.Readnum == 0 {
+		if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
 			list[k].IsRed = true
 		}
 	}

+ 16 - 0
models/report.go

@@ -110,3 +110,19 @@ WHERE
 	err = o.Raw(sql, industrialManagementId, categoryId, userId).QueryRow(&count)
 	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`
+	err = o.Raw(sql, industrialManagementId, categoryId).QueryRow(&item)
+	return
+}
+
+//获取最新文章
+func GetNewArticleByCategoryId(categoryId int) (item *ArticleDetail, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM cygx_article WHERE  category_id = ? ORDER BY publish_date DESC LIMIT 0, 1`
+	err = o.Raw(sql, categoryId).QueryRow(&item)
+	return
+}

+ 1 - 1
utils/config.go

@@ -61,7 +61,7 @@ func init() {
 		fmt.Println(Re)
 		panic(Re)
 	}
-
+	OnlineTime = "2021-06-01 00:00:01" //上线时间
 	if RunMode == "release" {
 		WxAppId = "wxcc32b61f96720d2f"
 		WxAppSecret = "06894933fafb24dafead7eaae09c08e0"