菜单鉴权,网页下拉不鉴权
This commit is contained in:
parent
019894f111
commit
c490ec515f
|
|
@ -60,10 +60,10 @@ public class PreAuthorizeAspect
|
|||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable
|
||||
{
|
||||
//获取请求参数
|
||||
boolean needPermission = true;
|
||||
Object[] args = joinPoint.getArgs();
|
||||
String argStr = JSON.toJSONString(args);
|
||||
JSONArray jsonArray = JSONUtil.parseArray(argStr);
|
||||
boolean needPermission = true;
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
Object obj = jsonArray.getObj(i);
|
||||
if (Objects.nonNull(obj) && obj instanceof JSONObject) {
|
||||
|
|
@ -75,10 +75,9 @@ public class PreAuthorizeAspect
|
|||
}
|
||||
|
||||
// 注解鉴权
|
||||
if (needPermission) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
checkMethodAnnotation(signature.getMethod());
|
||||
}
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
checkMethodAnnotation(signature.getMethod(), needPermission);
|
||||
|
||||
try
|
||||
{
|
||||
// 执行原有逻辑
|
||||
|
|
@ -94,7 +93,7 @@ public class PreAuthorizeAspect
|
|||
/**
|
||||
* 对一个Method对象进行注解检查
|
||||
*/
|
||||
public void checkMethodAnnotation(Method method)
|
||||
public void checkMethodAnnotation(Method method, boolean needPermission)
|
||||
{
|
||||
// 校验 @RequiresLogin 注解
|
||||
RequiresLogin requiresLogin = method.getAnnotation(RequiresLogin.class);
|
||||
|
|
@ -111,10 +110,11 @@ public class PreAuthorizeAspect
|
|||
}
|
||||
|
||||
// 校验 @RequiresPermissions 注解
|
||||
RequiresPermissions requiresPermissions = method.getAnnotation(RequiresPermissions.class);
|
||||
if (requiresPermissions != null)
|
||||
{
|
||||
AuthUtil.checkPermi(requiresPermissions);
|
||||
if (needPermission) {
|
||||
RequiresPermissions requiresPermissions = method.getAnnotation(RequiresPermissions.class);
|
||||
if (requiresPermissions != null) {
|
||||
AuthUtil.checkPermi(requiresPermissions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue