mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-23 19:19:32 +08:00
jwt的解析
This commit is contained in:
12
src/main/java/xyz/playedu/api/middleware/AuthMiddleware.java
Normal file
12
src/main/java/xyz/playedu/api/middleware/AuthMiddleware.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package xyz.playedu.api.middleware;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AuthMiddleware {
|
||||
String prv();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package xyz.playedu.api.middleware.impl;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import xyz.playedu.api.middleware.AuthMiddleware;
|
||||
import xyz.playedu.api.service.JWTService;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
public class AuthMiddlewareImpl {
|
||||
|
||||
@Autowired
|
||||
private JWTService jwtService;
|
||||
|
||||
@Pointcut("@annotation(xyz.playedu.api.middleware.AuthMiddleware)")
|
||||
private void doPointcut() {
|
||||
}
|
||||
|
||||
@Around("doPointcut()")
|
||||
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
|
||||
AuthMiddleware authMiddleware = methodSignature.getMethod().getAnnotation(AuthMiddleware.class);
|
||||
log.info("prv的值:" + authMiddleware.prv());
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user