允许TokenIgnore标记在类上面

This commit is contained in:
‘毛文春’
2023-02-17 10:03:56 +08:00
parent e8369320ab
commit 23493afb2f
2 changed files with 7 additions and 1 deletions

View File

@@ -5,7 +5,7 @@ import java.lang.annotation.*;
/** /**
* @author hao * @author hao
*/ */
@Target(ElementType.METHOD) @Target({ElementType.METHOD,ElementType.TYPE})
@Documented @Documented
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface TokenIgnore { public @interface TokenIgnore {

View File

@@ -46,6 +46,12 @@ public class TsTokenAspect {
@Before("methodArgs()") @Before("methodArgs()")
public void before(JoinPoint joinPoint) { public void before(JoinPoint joinPoint) {
Object aThis = joinPoint.getTarget();
TokenIgnore annotation = aThis.getClass().getAnnotation(TokenIgnore.class);
if (annotation != null) {
return;
}
// 过滤不要需要验证的接口 // 过滤不要需要验证的接口
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod(); Method method = signature.getMethod();