gmy 3 ヶ月 前
コミット
ed954a4019

+ 9 - 4
models/document_manage_model/outside_report.go

@@ -50,15 +50,20 @@ func init() {
 }
 
 // GetOutsideReportListByConditionCount 根据条件查询列表条数
-func GetOutsideReportListByConditionCount(condition string, pars []interface{}) (count int, err error) {
+func GetOutsideReportListByConditionCount(condition string, pars []interface{}, chartPermissionIdList []string) (count int, err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := `select count(1) from ( 
-			SELECT COUNT( DISTINCT t1.outside_report_id ) 
+	var sql string
+	if len(chartPermissionIdList) > 0 {
+		sql = `select count(1) from (`
+	}
+	sql += `SELECT COUNT( DISTINCT t1.outside_report_id ) 
 			FROM outside_report t1 
 			    LEFT JOIN chart_permission_search_key_word_mapping t2 ON t1.classify_id = t2.classify_id 
 			WHERE 1 = 1 `
 	sql += condition
-	sql += ` ) t`
+	if len(chartPermissionIdList) > 0 {
+		sql += ` ) t`
+	}
 
 	err = o.Raw(sql, pars).QueryRow(&count)
 	if err != nil && err != orm.ErrNoRows {

+ 1 - 1
services/document_manage_service/document_manage_service.go

@@ -162,7 +162,7 @@ func DocumentReportList(documentType int, chartPermissionIdList []string, classi
 		condition += ` GROUP BY t1.outside_report_id HAVING COUNT(DISTINCT t2.chart_permission_id) = ` + strconv.Itoa(len(chartPermissionIdList))
 	}
 
-	count, err := document_manage_model.GetOutsideReportListByConditionCount(condition, pars)
+	count, err := document_manage_model.GetOutsideReportListByConditionCount(condition, pars, chartPermissionIdList)
 	if err != nil {
 		return nil, err
 	}