Browse Source

产业报告-阅读量最多的产业加筛选条件

hsun 2 years ago
parent
commit
6164cb6307
2 changed files with 14 additions and 4 deletions
  1. 7 1
      controllers/report.go
  2. 7 3
      models/industrial_management.go

+ 7 - 1
controllers/report.go

@@ -234,8 +234,14 @@ func (this *ReportController) IndustryList() {
 		return
 	}
 	// 获取近一个月产业报告阅读次数最多的产业
+	var topCond string
+	var topPars []interface{}
 	topReadIndustryId := 0
-	topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry()
+	if ChartPermissionId > 0 {
+		topCond += ` AND chart_permission_id = ?`
+		topPars = append(topPars, ChartPermissionId)
+	}
+	topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
 	if e != nil && e.Error() != utils.ErrNoRow() {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()

+ 7 - 3
models/industrial_management.go

@@ -586,9 +586,13 @@ func GetActiveArticleIndustryIds() (ids []int, err error) {
 }
 
 // GetTopOneMonthArtReadNumIndustry 获取近一个月报告阅读数量最多的产业信息
-func GetTopOneMonthArtReadNumIndustry() (item *IndustrialManagement, err error) {
-	sql := `SELECT * FROM cygx_industrial_management ORDER BY article_read_num DESC LIMIT 1`
-	err = orm.NewOrm().Raw(sql).QueryRow(&item)
+func GetTopOneMonthArtReadNumIndustry(condition string, pars []interface{}) (item *IndustrialManagement, err error) {
+	sql := `SELECT * FROM cygx_industrial_management WHERE 1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` ORDER BY article_read_num DESC LIMIT 1`
+	err = orm.NewOrm().Raw(sql, pars).QueryRow(&item)
 	return
 }