Browse Source

Merge branch 'bzq/dev' of eta_mini/eta_mini_bridge into debug

鲍自强 7 months ago
parent
commit
c6ccfb72d5
2 changed files with 11 additions and 5 deletions
  1. 2 2
      controllers/report.go
  2. 9 3
      models/report.go

+ 2 - 2
controllers/report.go

@@ -939,14 +939,14 @@ func (this *ReportNoAuthController) List() {
 		for k := range classifyIdMap {
 			selectedClassifyIds = append(selectedClassifyIds, k)
 		}
-		tmptotal, err := models.GetPushReportCount(selectedClassifyIds)
+		tmptotal, err := models.GetPushReportCount(selectedClassifyIds, condition)
 		if err != nil {
 			br.Msg = "获取数据失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
 		total = tmptotal
-		tmpReportList, err := models.GetPushReportListByPage(selectedClassifyIds, startSize, pageSize)
+		tmpReportList, err := models.GetPushReportListByPage(selectedClassifyIds, condition, startSize, pageSize)
 		if err != nil {
 			br.Msg = "获取报告列表失败"
 			br.ErrMsg = "获取报告列表失败,Err:" + err.Error()

+ 9 - 3
models/report.go

@@ -200,20 +200,23 @@ func GetPushReportListByClassifyIds(classifyFirstIds, classifySecondIds, classif
 	return
 }
 
-func GetPushReportCount(classifyIds []int) (count int, err error) {
+func GetPushReportCount(classifyIds []int, dateCondition string) (count int, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT COUNT(*) AS count FROM report_push_status WHERE state=1 AND report_type=1 `
 	var pars []interface{}
 	if len(classifyIds) > 0 {
-		sql += " AND (classify_id_first IN (%s) OR classify_id_second IN (%s) OR classify_id_third IN (%s))"
+		sql += ` AND (classify_id_first IN (%s) OR classify_id_second IN (%s) OR classify_id_third IN (%s)) `
 		sql = fmt.Sprintf(sql, utils.GetOrmReplaceHolder(len(classifyIds)), utils.GetOrmReplaceHolder(len(classifyIds)), utils.GetOrmReplaceHolder(len(classifyIds)))
 		pars = append(pars, classifyIds, classifyIds, classifyIds)
 	}
+	if dateCondition != "" {
+		sql += dateCondition
+	}
 	err = o.Raw(sql, pars...).QueryRow(&count)
 	return
 }
 
-func GetPushReportListByPage(classifyIds []int, startSize, pageSize int) (items []*ReportPushView, err error) {
+func GetPushReportListByPage(classifyIds []int, dateCondition string, startSize, pageSize int) (items []*ReportPushView, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT * FROM report_push_status WHERE state=1 AND report_type=1 `
 	var pars []interface{}
@@ -222,6 +225,9 @@ func GetPushReportListByPage(classifyIds []int, startSize, pageSize int) (items
 		sql = fmt.Sprintf(sql, utils.GetOrmReplaceHolder(len(classifyIds)), utils.GetOrmReplaceHolder(len(classifyIds)), utils.GetOrmReplaceHolder(len(classifyIds)))
 		pars = append(pars, classifyIds, classifyIds, classifyIds)
 	}
+	if dateCondition != "" {
+		sql += dateCondition
+	}
 	sql += ` ORDER BY publish_time DESC LIMIT ?,? `
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return