xiziwen 4 months ago
parent
commit
bb0ab00d40

+ 6 - 1
controllers/document_manage/document_manage_controller.go

@@ -241,6 +241,11 @@ func (this *DocumentManageController) RuiSiReportList() {
 	if strings.TrimSpace(classifyIdListStr) != "" {
 		classifyIdList = strings.Split(classifyIdListStr, ",")
 	}
+	chartPermissionIdString := this.GetString("ChartPermissionIdList")
+	var chartPermissionIdList []string
+	if strings.TrimSpace(chartPermissionIdString) != "" {
+		chartPermissionIdList = strings.Split(chartPermissionIdString, ",")
+	}
 
 	keyword := this.GetString("Keyword")
 	orderField := this.GetString("OrderField")
@@ -254,7 +259,7 @@ func (this *DocumentManageController) RuiSiReportList() {
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
-	RuiSiReportPage, err := document_manage_service.RuiSiReportListV2(classifyIdList, keyword, orderField, orderType, currentIndex, pageSize)
+	RuiSiReportPage, err := document_manage_service.RuiSiReportListV2(classifyIdList, chartPermissionIdList, keyword, orderField, orderType, currentIndex, pageSize)
 	if err != nil {
 		br.Msg = "获取报告列表失败"
 		br.ErrMsg = "获取报告列表失败,Err:" + err.Error()

+ 19 - 4
models/report.go

@@ -1685,7 +1685,7 @@ func GetReportListByCollectList(classifyIdFirst, classifyIdSecond, classifyIdThi
 	return items, err
 }
 
-func GetReportListByCollectCountV2(classifyIdFirst, classifyIdSecond, classifyIdThird []string, keyword, author string, state int) (count int, err error) {
+func GetReportListByCollectCountV2(classifyIdFirst, classifyIdSecond, classifyIdThird, chartPermissionIdList []string, keyword, author string, state int) (count int, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	var params []interface{}
 
@@ -1694,9 +1694,16 @@ func GetReportListByCollectCountV2(classifyIdFirst, classifyIdSecond, classifyId
 		SELECT COUNT(DISTINCT t.id) AS totalCount
 		FROM (
 			SELECT b.id
-			FROM report AS b
+			FROM report AS b left join chart_permission_search_key_word_mapping c on
+b.classify_id = c.classify_id
 			WHERE 1 = 1
 	`
+	if len(chartPermissionIdList) > 0 {
+		sql += ` and c.chart_permission_id in (` + utils.GetOrmInReplace(len(chartPermissionIdList)) + `)`
+		for _, chartPermissionId := range chartPermissionIdList {
+			params = append(params, chartPermissionId)
+		}
+	}
 
 	// 处理关键词
 	if keyword != "" {
@@ -1750,7 +1757,7 @@ func GetReportListByCollectCountV2(classifyIdFirst, classifyIdSecond, classifyId
 	return count, err
 }
 
-func GetReportListByCollectListV2(classifyIdFirst, classifyIdSecond, classifyIdThird []string, keyword, orderField, orderType string, startSize, pageSize int, author string, state int) (items []*ReportList, err error) {
+func GetReportListByCollectListV2(classifyIdFirst, classifyIdSecond, classifyIdThird, chartPermissionIdList []string, keyword, orderField, orderType string, startSize, pageSize int, author string, state int) (items []*ReportList, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	var params []interface{}
 
@@ -1759,7 +1766,8 @@ func GetReportListByCollectListV2(classifyIdFirst, classifyIdSecond, classifyIdT
 		SELECT DISTINCT t.id, t.title, t.author, t.modify_time, t.publish_time,t.classify_id_first,t.classify_name_first,t.classify_id_second,t.classify_name_second,t.classify_id_third,t.classify_name_third
 		FROM (
 			SELECT b.id, b.title, b.author, b.modify_time, b.publish_time,b.classify_id_first,b.classify_name_first,b.classify_id_second,b.classify_name_second,b.classify_id_third,b.classify_name_third
-			FROM report AS b
+			FROM report AS b  left join chart_permission_search_key_word_mapping c on
+b.classify_id = c.classify_id 
 			WHERE 1 = 1
 	`
 
@@ -1808,6 +1816,13 @@ func GetReportListByCollectListV2(classifyIdFirst, classifyIdSecond, classifyIdT
 		sql += ` AND (` + strings.Join(classifyIdSqlList, " OR ") + `) `
 	}
 
+	if len(chartPermissionIdList) > 0 {
+		sql += ` and c.chart_permission_id in (` + utils.GetOrmInReplace(len(chartPermissionIdList)) + `)`
+		for _, chartPermissionId := range chartPermissionIdList {
+			params = append(params, chartPermissionId)
+		}
+	}
+
 	sql += ") AS t "
 
 	// 排序处理

+ 3 - 3
services/document_manage_service/document_manage_service.go

@@ -418,7 +418,7 @@ func DocumentDelete(outsideReportId int) error {
 	return nil
 }
 
-func RuiSiReportListV2(classifyIdList []string, keyword, orderField, orderType string, startSize, pageSize int) (*models.ReportListResp, error) {
+func RuiSiReportListV2(classifyIdList, chartPermissionIdList []string, keyword, orderField, orderType string, startSize, pageSize int) (*models.ReportListResp, error) {
 	logs.Info("RuiSiReportList")
 
 	allClassifyList, err := models.GetClassifyListByIdStrList(classifyIdList)
@@ -443,7 +443,7 @@ func RuiSiReportListV2(classifyIdList []string, keyword, orderField, orderType s
 	// 已发布的报告
 	state := 2
 
-	count, err := models.GetReportListByCollectCountV2(classifyIdFirst, classifyIdSecond, classifyIdThird, keyword, author, state)
+	count, err := models.GetReportListByCollectCountV2(classifyIdFirst, classifyIdSecond, classifyIdThird, chartPermissionIdList, keyword, author, state)
 	if err != nil {
 		return nil, err
 	}
@@ -455,7 +455,7 @@ func RuiSiReportListV2(classifyIdList []string, keyword, orderField, orderType s
 		return &reportPage, nil
 	}
 
-	reportList, err := models.GetReportListByCollectListV2(classifyIdFirst, classifyIdSecond, classifyIdThird, keyword, orderField, orderType, startSize, pageSize, author, state)
+	reportList, err := models.GetReportListByCollectListV2(classifyIdFirst, classifyIdSecond, classifyIdThird, chartPermissionIdList, keyword, orderField, orderType, startSize, pageSize, author, state)
 	if err != nil {
 		return nil, err
 	}