废弃 SaTokenAction 接口,新增 SaStrategy 策略类

This commit is contained in:
click33
2021-09-28 23:57:56 +08:00
parent 356e65f749
commit 713e11482c
17 changed files with 234 additions and 88 deletions

View File

@@ -5,7 +5,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.util.PathMatcher;
import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.action.SaTokenAction;
import cn.dev33.satoken.basic.SaBasicTemplate;
import cn.dev33.satoken.basic.SaBasicUtil;
import cn.dev33.satoken.config.SaTokenConfig;
@@ -63,7 +62,7 @@ public class SaBeanInject {
* @param saTokenAction SaTokenAction对象
*/
@Autowired(required = false)
public void setSaTokenAction(SaTokenAction saTokenAction) {
public void setSaTokenAction(@SuppressWarnings("deprecation") cn.dev33.satoken.action.SaTokenAction saTokenAction) {
SaManager.setSaTokenAction(saTokenAction);
}

View File

@@ -29,6 +29,7 @@ import cn.dev33.satoken.temp.SaTempInterface;
* @author noear
* @since 1.4
*/
@SuppressWarnings("deprecation")
public class XPluginImp implements Plugin {
@Override

View File

@@ -1,9 +1,10 @@
package cn.dev33.satoken.solon.integration;
import cn.dev33.satoken.SaManager;
import org.noear.solon.core.aspect.Interceptor;
import org.noear.solon.core.aspect.Invocation;
import cn.dev33.satoken.strategy.SaStrategy;
/**
* @author noear
* @since 1.4
@@ -14,8 +15,8 @@ public class SaTokenMethodInterceptor implements Interceptor {
@Override
public Object doIntercept(Invocation inv) throws Throwable {
// 注解鉴权
SaManager.getSaTokenAction().checkMethodAnnotation(inv.method().getMethod());
// 注解鉴权
SaStrategy.me.checkMethodAnnotation.accept(inv.method().getMethod());
// 执行原有逻辑
return inv.invoke();

View File

@@ -8,7 +8,7 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.strategy.SaStrategy;
/**
* 注解式鉴权 - 拦截器
@@ -37,7 +37,7 @@ public class SaAnnotationInterceptor implements HandlerInterceptor {
Method method = ((HandlerMethod) handler).getMethod();
// 进行验证
SaManager.getSaTokenAction().checkMethodAnnotation(method);
SaStrategy.me.checkMethodAnnotation.accept(method);
// 通过验证
return true;

View File

@@ -5,7 +5,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.util.PathMatcher;
import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.action.SaTokenAction;
import cn.dev33.satoken.basic.SaBasicTemplate;
import cn.dev33.satoken.basic.SaBasicUtil;
import cn.dev33.satoken.config.SaTokenConfig;
@@ -63,7 +62,7 @@ public class SaBeanInject {
* @param saTokenAction SaTokenAction对象
*/
@Autowired(required = false)
public void setSaTokenAction(SaTokenAction saTokenAction) {
public void setSaTokenAction(@SuppressWarnings("deprecation") cn.dev33.satoken.action.SaTokenAction saTokenAction) {
SaManager.setSaTokenAction(saTokenAction);
}