mirror of
https://gitee.com/dromara/sa-token.git
synced 2024-12-01 11:27:53 +08:00
稍微简化一下cn.dev33.satoken.action.SaTokenActionDefaultImpl.checkMethodAnnotation的验证逻辑
This commit is contained in:
parent
737aeb5fb0
commit
953ba965aa
@ -1,5 +1,6 @@
|
||||
package cn.dev33.satoken.action;
|
||||
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -89,44 +90,29 @@ public class SaTokenActionDefaultImpl implements SaTokenAction {
|
||||
|
||||
// 获取这个 Method 所属的 Class
|
||||
Class<?> clazz = method.getDeclaringClass();
|
||||
|
||||
|
||||
// 从 Class 校验 @SaCheckLogin 注解
|
||||
if(clazz.isAnnotationPresent(SaCheckLogin.class)) {
|
||||
SaCheckLogin at = clazz.getAnnotation(SaCheckLogin.class);
|
||||
|
||||
validateAnnotation(clazz);
|
||||
validateAnnotation(method);
|
||||
}
|
||||
|
||||
private void validateAnnotation(AnnotatedElement target) {
|
||||
// 校验 @SaCheckLogin 注解
|
||||
if(target.isAnnotationPresent(SaCheckLogin.class)) {
|
||||
SaCheckLogin at = target.getAnnotation(SaCheckLogin.class);
|
||||
SaManager.getStpLogic(at.key()).checkByAnnotation(at);
|
||||
}
|
||||
|
||||
// 从 Class 校验 @SaCheckRole 注解
|
||||
if(clazz.isAnnotationPresent(SaCheckRole.class)) {
|
||||
SaCheckRole at = clazz.getAnnotation(SaCheckRole.class);
|
||||
// 校验 @SaCheckRole 注解
|
||||
if(target.isAnnotationPresent(SaCheckRole.class)) {
|
||||
SaCheckRole at = target.getAnnotation(SaCheckRole.class);
|
||||
SaManager.getStpLogic(at.key()).checkByAnnotation(at);
|
||||
}
|
||||
|
||||
// 从 Class 校验 @SaCheckPermission 注解
|
||||
if(clazz.isAnnotationPresent(SaCheckPermission.class)) {
|
||||
SaCheckPermission at = clazz.getAnnotation(SaCheckPermission.class);
|
||||
// 校验 @SaCheckPermission 注解
|
||||
if(target.isAnnotationPresent(SaCheckPermission.class)) {
|
||||
SaCheckPermission at = target.getAnnotation(SaCheckPermission.class);
|
||||
SaManager.getStpLogic(at.key()).checkByAnnotation(at);
|
||||
}
|
||||
|
||||
// 从 Method 校验 @SaCheckLogin 注解
|
||||
if(method.isAnnotationPresent(SaCheckLogin.class)) {
|
||||
SaCheckLogin at = method.getAnnotation(SaCheckLogin.class);
|
||||
SaManager.getStpLogic(at.key()).checkByAnnotation(at);
|
||||
}
|
||||
|
||||
// 从 Method 校验 @SaCheckRole 注解
|
||||
if(method.isAnnotationPresent(SaCheckRole.class)) {
|
||||
SaCheckRole at = method.getAnnotation(SaCheckRole.class);
|
||||
SaManager.getStpLogic(at.key()).checkByAnnotation(at);
|
||||
}
|
||||
|
||||
// 从 Method 校验 @SaCheckPermission 注解
|
||||
if(method.isAnnotationPresent(SaCheckPermission.class)) {
|
||||
SaCheckPermission at = method.getAnnotation(SaCheckPermission.class);
|
||||
SaManager.getStpLogic(at.key()).checkByAnnotation(at);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user