浏览代码

wip:权限过滤

wangshan 7 月之前
父节点
当前提交
18b5966a00
共有 1 个文件被更改,包括 26 次插入2 次删除
  1. 26 2
      entity/workDesktop.go

+ 26 - 2
entity/workDesktop.go

@@ -386,7 +386,19 @@ func (m *WorkDesktopMenu) VerifyPermissions(powerIds string, excludeCodes string
 		userPower := m.AutoUserPowerInfo() //m.TimeOut, m.BigMemberOff,
 		if len(strings.Split(powerIds, ",")) > 0 {
 			for _, pv := range strings.Split(powerIds, ",") {
-				if userPower[pv] > 0 {
+				//同时满足
+				if pvs := strings.Split(pv, "+"); len(pvs) > 1 {
+					var pi int
+					for _, v := range pvs {
+						if userPower[v] > 0 {
+							pi++
+						}
+					}
+					if pi == len(pvs) {
+						pb.HasBool = true
+						break
+					}
+				} else if userPower[pv] > 0 {
 					pb.HasBool = true
 					break
 				}
@@ -394,7 +406,19 @@ func (m *WorkDesktopMenu) VerifyPermissions(powerIds string, excludeCodes string
 		}
 		if len(strings.Split(excludeCodes, ",")) > 0 {
 			for _, pv := range strings.Split(excludeCodes, ",") {
-				if userPower[pv] > 0 {
+				//同时满足
+				if ecs := strings.Split(pv, "+"); len(ecs) > 1 {
+					var ei int
+					for _, v := range ecs {
+						if userPower[v] > 0 {
+							ei++
+						}
+					}
+					if ei == len(ecs) {
+						pb.ExcludeBool = true
+						break
+					}
+				} else if userPower[pv] > 0 {
 					pb.ExcludeBool = true
 					break
 				}