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