Răsfoiți Sursa

add:增加ppt的分类可见权限过滤

zqbao 4 luni în urmă
părinte
comite
ad1d634c0a
2 a modificat fișierele cu 24 adăugiri și 8 ștergeri
  1. 6 6
      controllers/classify.go
  2. 18 2
      controllers/ppt_report.go

+ 6 - 6
controllers/classify.go

@@ -585,12 +585,7 @@ func (this *ClassifyController) ListClassify() {
 	visibleUserMap := make(map[int][]int)
 
 	for _, v := range visibleUsers {
-		if m, ok := visibleUserMap[v.ClassifyId]; !ok {
-			visibleUserMap[v.ClassifyId] = make([]int, 0)
-			visibleUserMap[v.ClassifyId] = append(visibleUserMap[v.ClassifyId], v.AdminId)
-		} else {
-			visibleUserMap[v.ClassifyId] = append(m, v.AdminId)
-		}
+		visibleUserMap[v.ClassifyId] = append(visibleUserMap[v.ClassifyId], v.AdminId)
 	}
 
 	for i, v := range list {
@@ -623,6 +618,11 @@ func (this *ClassifyController) ListClassify() {
 			if !utils.InArrayByInt(classifyIds, v.Id) {
 				continue
 			}
+			if visible, ok := visibleUserMap[v.Id]; ok {
+				if !utils.InArrayByInt(visible, this.SysUser.AdminId) {
+					continue
+				}
+			}
 			list = append(list, v)
 		}
 	}

+ 18 - 2
controllers/ppt_report.go

@@ -7,10 +7,11 @@ import (
 	"eta_gn/eta_api/services"
 	"eta_gn/eta_api/utils"
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
 // ReportClassify
@@ -98,8 +99,18 @@ func (this *PptV2Controller) ReportClassify() {
 		classifyPpt[v.ClassifyId] = append(classifyPpt[v.ClassifyId], t)
 	}
 
-	resp := make([]*models.PptReportClassifyItem, 0)
+	visibleUsers, err := models.GetClassifyVisibleAll()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = fmt.Sprintf("获取可见用户失败, err: %s", err.Error())
+		return
+	}
+	visibleUsersMap := make(map[int][]int)
+	for _, v := range visibleUsers {
+		visibleUsersMap[v.ClassifyId] = append(visibleUsersMap[v.ClassifyId], v.AdminId)
+	}
 
+	var resp []*models.PptReportClassifyItem
 	// 获取分类
 	classifies := make([]*models.Classify, 0)
 	{
@@ -145,6 +156,11 @@ func (this *PptV2Controller) ReportClassify() {
 			if !utils.InArrayByInt(classifyIds, v.Id) {
 				continue
 			}
+			if visible, ok := visibleUsersMap[v.Id]; ok {
+				if !utils.InArrayByInt(visible, sysUser.AdminId) {
+					continue
+				}
+			}
 			classifies = append(classifies, v)
 		}
 	}