浏览代码

Merge branch 'cygx_9.2' into debug

ziwen 2 年之前
父节点
当前提交
9473171a75
共有 2 个文件被更改,包括 6 次插入4 次删除
  1. 5 3
      controllers/report.go
  2. 1 1
      models/report.go

+ 5 - 3
controllers/report.go

@@ -301,13 +301,15 @@ func (this *ReportController) ArticleCategoryList() {
 			return
 		}
 		Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
-		if err != nil {
+		if err != nil && err.Error() != utils.ErrNoRow() {
 			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
+		if Newdetail != nil {
+			if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
+				list[k].IsRed = true
+			}
 		}
 	}
 

+ 1 - 1
models/report.go

@@ -159,7 +159,7 @@ WHERE
 //获取最新文章
 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`
+	sql := ` SELECT * FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ORDER BY publish_date DESC LIMIT 0, 1`
 	err = o.Raw(sql, industrialManagementId, categoryId).QueryRow(&item)
 	return
 }