登录成功后清空缓存

This commit is contained in:
WeiXiao
2025-07-01 09:30:18 +08:00
parent 9a7e3be855
commit 49420260c2
4 changed files with 2 additions and 21 deletions

View File

@@ -26,10 +26,10 @@ public class TenantRedisCacheManager extends TimeoutRedisCacheManager {
@Override
public Cache getCache(String name) {
// 如果开启多租户,则 name 拼接租户后缀
if (!TenantContextHolder.isIgnore()
/*if (!TenantContextHolder.isIgnore()
&& TenantContextHolder.getTenantId() != null) {
name = name + ":" + TenantContextHolder.getTenantId();
}
}*/
// 继续基于父方法
return super.getCache(name);

View File

@@ -110,12 +110,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
}
//清空缓存
permissionService.clearCache(user.getId());
permissionService.clearCacheIgnoreTenant(user.getId());
try{
Thread.sleep(2000L);
}catch (Exception e){
}
// 创建 Token 令牌,记录登录日志
return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME);
}

View File

@@ -146,6 +146,4 @@ public interface PermissionService {
//清除缓存
Boolean clearCache(Long userId);
//清除缓存忽略租户
Boolean clearCacheIgnoreTenant(Long userId);
}

View File

@@ -360,18 +360,6 @@ public class PermissionServiceImpl implements PermissionService {
return true;
}
//清除缓存忽略租户
@TenantIgnore
public Boolean clearCacheIgnoreTenant(Long userId){
try{
PermissionServiceImpl bean = SpringUtil.getBean(PermissionServiceImpl.class);
bean.clearCache(userId);
Thread.sleep(500L);
}catch (Exception e){
}
return true;
}
/**
* 获得自身的代理对象,解决 AOP 生效问题