mirror of
https://gitee.com/dromara/sa-token.git
synced 2026-05-14 12:52:08 +08:00
新增 SaCheckOr 注解,批量注解鉴权:只要满足其中一个注解即可通过验证
This commit is contained in:
@@ -117,7 +117,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
@Autowired
|
||||
public void rewriteSaStrategy() {
|
||||
// 重写Sa-Token的注解处理器,增加注解合并功能
|
||||
SaStrategy.me.getAnnotation = (element, annotationClass) -> {
|
||||
SaStrategy.instance.getAnnotation = (element, annotationClass) -> {
|
||||
return AnnotatedElementUtils.getMergedAnnotation(element, annotationClass);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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.34.0
|
||||
*/
|
||||
@Component
|
||||
public class StpUserUtil {
|
||||
|
||||
private StpUserUtil() {}
|
||||
|
||||
@@ -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.34.0
|
||||
*/
|
||||
@Component
|
||||
public class StpUserUtil {
|
||||
|
||||
private StpUserUtil() {}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.pj.test;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.util.SaResult;
|
||||
import com.pj.satoken.StpUserUtil;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -18,7 +18,7 @@ public class TestController {
|
||||
// 测试登录 ---- http://localhost:8081/test/login
|
||||
@RequestMapping("login")
|
||||
public SaResult login(@RequestParam(defaultValue = "10001") long id) {
|
||||
StpUtil.login(id);
|
||||
StpUserUtil.login(id);
|
||||
return SaResult.ok("登录成功");
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ public class TestController {
|
||||
@RequestMapping("test")
|
||||
public SaResult test() {
|
||||
System.out.println("------------进来了");
|
||||
StpUtil.getExtra("name");
|
||||
// 返回
|
||||
return SaResult.data("");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user