From 9c3bb5f9566f76b02803fc219ed022ddf0f1a2da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Thu, 13 Mar 2025 10:06:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=9C=AA=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E5=88=86=E6=9D=83=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/service/auth/AuthServiceImpl.java | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/com/engine/salary/service/auth/AuthServiceImpl.java b/src/com/engine/salary/service/auth/AuthServiceImpl.java index e988f796d..63277ae39 100644 --- a/src/com/engine/salary/service/auth/AuthServiceImpl.java +++ b/src/com/engine/salary/service/auth/AuthServiceImpl.java @@ -61,10 +61,6 @@ public class AuthServiceImpl extends Service implements AuthService { Boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution(); boolean isAuth = clazz.isAnnotationPresent(Auth.class); - if (!isOpenDevolution || !isAuth) { - return list; - } - Auth auth = clazz.getAnnotation(Auth.class); String taxAgentIdField = auth.taxAgentIdField(); String taxAgentIdFieldGetter = "get" + taxAgentIdField.substring(0, 1).toUpperCase() + taxAgentIdField.substring(1); @@ -76,6 +72,34 @@ public class AuthServiceImpl extends Service implements AuthService { String optsFieldGetter = "get" + optsField.substring(0, 1).toUpperCase() + optsField.substring(1); String optsFieldSetter = "set" + optsField.substring(0, 1).toUpperCase() + optsField.substring(1); + //不开启分权 + if (!isOpenDevolution) { + if (filterType == AuthFilterTypeEnum.DATA_OPT) { + list.forEach(t -> { + try { + Method optsFieldGetterMethod = t.getClass().getMethod(optsFieldGetter); + Set opts = (Set) optsFieldGetterMethod.invoke(t); + if (opts == null) { + opts = new HashSet<>(); + } + opts.add("query"); + opts.add("admin"); + + Method optsFieldSetterMethod = t.getClass().getMethod(optsFieldSetter, Set.class); + optsFieldSetterMethod.invoke(t, opts); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new SalaryRunTimeException(e); + } + }); + } + return list; + } + + //未配置分权 + if (!isAuth) { + return list; + } + //给总管理员赋值最大权限 Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID()); if (isChief || filterType == AuthFilterTypeEnum.NO_AUTH) {