chejianzheng 3 місяців тому
батько
коміт
ce130c1e27

+ 0 - 1
src/main/java/cn/hfln/framework/gateway/config/SaTokenConfigure.java

@@ -1,7 +1,6 @@
 package cn.hfln.framework.gateway.config;
 
 import cn.dev33.satoken.context.SaHolder;
-import cn.dev33.satoken.error.SaErrorCode;
 import cn.dev33.satoken.exception.SaTokenException;
 import cn.dev33.satoken.reactor.filter.SaReactorFilter;
 import cn.dev33.satoken.router.SaRouter;

+ 11 - 7
src/main/java/cn/hfln/framework/gateway/config/StpInterfaceImpl.java

@@ -1,6 +1,8 @@
 package cn.hfln.framework.gateway.config;
 
+import cn.dev33.satoken.session.SaSession;
 import cn.dev33.satoken.stp.StpInterface;
+import cn.dev33.satoken.stp.StpUtil;
 import cn.hfln.framework.redis.util.RedisUtil;
 import com.alibaba.fastjson2.JSONArray;
 import lombok.extern.slf4j.Slf4j;
@@ -51,13 +53,15 @@ public class StpInterfaceImpl implements StpInterface {
 	public List<String> getRoleList(Object loginIdObj, String loginType) {
 
 		// 当前登录用户的角色
-		String roleKeyPre = "hfln:role:";
-		String roleListStr = (String)redisService.get(roleKeyPre + loginIdObj);
-		if (!StringUtils.hasText(roleListStr)) {
-			log.info("当前账户未配置角色, loginId :{}", loginIdObj);
-			return new ArrayList<>();
-		}
-		return new ArrayList<>(JSONArray.parseArray(roleListStr, String.class));
+//		String roleKeyPre = "hfln:role:";
+//		String roleListStr = (String)redisService.get(roleKeyPre + loginIdObj);
+//		if (!StringUtils.hasText(roleListStr)) {
+//			log.info("当前账户未配置角色, loginId :{}", loginIdObj);
+//			return new ArrayList<>();
+//		}
+		List<String> roleCodeList = StpUtil.getSession().getModel(SaSession.ROLE_LIST, List.class);
+		return roleCodeList == null ? new ArrayList<>() : roleCodeList;
+//		return new ArrayList<>(JSONArray.parseArray(roleListStr, String.class));
 	}
 
 }