Browse Source

去掉refresh 接口

chejianzheng 3 months ago
parent
commit
9daa0e05d8

+ 0 - 9
portal-service-application/src/main/java/com/hfln/portal/application/controller/web/WebUserController.java

@@ -45,15 +45,6 @@ public class WebUserController {
         return ApiResult.success(CopyUtils.copy(StpUtil.getTokenInfo(), UserTokenInfo.class));
     }
 
-    @GetMapping("/refresh")
-    @Operation(summary = "刷新token")
-    public ApiResult<UserTokenInfo> refresh() {
-
-        webGateway.refresh();
-        return ApiResult.success(CopyUtils.copy(StpUtil.getTokenInfo(), UserTokenInfo.class));
-    }
-
-
     @GetMapping("/logout")
     @Operation(summary = "用户退出登录")
     public ApiResult<Void> logout() {

+ 0 - 2
portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/WebGateway.java

@@ -74,7 +74,5 @@ public interface WebGateway {
 
     RoleMenuTreeDTO getRoleSelectedMenu(Long roleId);
 
-    void refresh();
-
 }
 

+ 15 - 10
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/config/UserAuthService.java

@@ -1,5 +1,6 @@
 package com.hfln.portal.infrastructure.config;
 
+import cn.dev33.satoken.session.SaSession;
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hfln.framework.redis.util.RedisUtil;
 import com.alibaba.fastjson2.JSONArray;
@@ -56,13 +57,17 @@ public class UserAuthService {
 
 		List<String> roleCodeList = this.getRoleCodeList(StpUtil.getLoginId(), StpUtil.getLoginType());
 		if (!CollectionUtils.isEmpty(roleCodeList)) {
-			// 登录缓存角色 防止用户角色有变更,登录前先删除之前的缓存
-			if (!redisService.hasKey(RedisCacheConstant.USER_ROLE_KEY_PRE+StpUtil.getLoginId())) {
-				// 这里从更改用户角色的地方修改最好
-				redisService.del(RedisCacheConstant.USER_ROLE_KEY_PRE+StpUtil.getLoginId());
-				// 永久期限
-				redisService.setForever(RedisCacheConstant.USER_ROLE_KEY_PRE+ StpUtil.getLoginId(), JSONArray.toJSONString(roleCodeList));
-			}
+//			// 登录缓存角色 防止用户角色有变更,登录前先删除之前的缓存
+//			if (!redisService.hasKey(RedisCacheConstant.USER_ROLE_KEY_PRE+StpUtil.getLoginId())) {
+//				// 这里从更改用户角色的地方修改最好
+//				redisService.del(RedisCacheConstant.USER_ROLE_KEY_PRE+StpUtil.getLoginId());
+//				// 永久期限
+//				redisService.setForever(RedisCacheConstant.USER_ROLE_KEY_PRE+ StpUtil.getLoginId(), JSONArray.toJSONString(roleCodeList));
+//			}
+
+			StpUtil.getSession().set(SaSession.ROLE_LIST, roleCodeList);
+//			List<String> roles = StpUtil.getSession().getModel(SaSession.ROLE_LIST, List.class);
+//			List<String> o = (List<String>)StpUtil.getSession().get(SaSession.ROLE_LIST);
 			for (String roleCode : roleCodeList) {
 				if (!redisService.hasKey(RedisCacheConstant.ROLE_PERM_KEY_PRE+roleCode)) {
 					// 这里从更改角色权限的地方修改最好
@@ -78,9 +83,9 @@ public class UserAuthService {
 		// 每次修改用户角色,应该注销用户登录信息,让用户重新登录
 	}
 
-	public void delUserRoleCache() {
-		redisService.del(RedisCacheConstant.USER_ROLE_KEY_PRE+StpUtil.getLoginId());
-	}
+//	public void delUserRoleCache() {
+//		redisService.del(RedisCacheConstant.USER_ROLE_KEY_PRE+StpUtil.getLoginId());
+//	}
 
 	/**
 	 * 返回一个账号所拥有的角色标识集合

+ 1 - 6
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/WebGatewayImpl.java

@@ -343,7 +343,7 @@ public class WebGatewayImpl implements WebGateway {
     public void logout() {
 
         StpUtil.logout(StpUtil.getLoginId(), StpUtil.getLoginDeviceType());
-        userAuthService.delUserRoleCache();
+//        userAuthService.delUserRoleCache();
     }
 
     @Override
@@ -465,11 +465,6 @@ public class WebGatewayImpl implements WebGateway {
         return filterAndSortMenuList(parentMap, 0L);
     }
 
-    @Override
-    public void refresh() {
-        StpUtil.renewTimeout(StpUtil.getTokenValue(), adminActiveTimeout);
-    }
-
     /**
      * 过滤并排序菜单列表
      * @param parentMap 按父级ID分组的菜单Map