优化demo示例

This commit is contained in:
click33 2024-05-04 09:48:31 +08:00
parent c0a993a0f5
commit 7f5ae11961
2 changed files with 11 additions and 9 deletions

View File

@ -1,12 +1,5 @@
package com.pj.satoken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.filter.SaServletFilter;
import cn.dev33.satoken.interceptor.SaInterceptor;
@ -14,6 +7,13 @@ import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.strategy.SaStrategy;
import cn.dev33.satoken.util.SaResult;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.PostConstruct;
/**
@ -114,11 +114,11 @@ public class SaTokenConfigure implements WebMvcConfigurer {
/**
* 重写 Sa-Token 框架内部算法策略
*/
@Autowired
@PostConstruct
public void rewriteSaStrategy() {
// 重写Sa-Token的注解处理器增加注解合并功能
SaStrategy.instance.getAnnotation = (element, annotationClass) -> {
return AnnotatedElementUtils.getMergedAnnotation(element, annotationClass);
return AnnotatedElementUtils.getMergedAnnotation(element, annotationClass);
};
}

View File

@ -7,6 +7,7 @@ import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.SaLoginModel;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpLogic;
import org.springframework.stereotype.Component;
import java.util.List;
@ -16,6 +17,7 @@ import java.util.List;
* @author click33
* @since 1.0.0
*/
@Component
public class StpUserUtil {
private StpUserUtil() {}