token保持一致

This commit is contained in:
litianxiang
2026-04-20 10:26:04 +08:00
parent 560e47747a
commit 32a228485b
3 changed files with 31 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ import com.ai.da.common.enums.ProductEnum;
import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.ResultEnum;
import com.ai.da.common.security.jwt.JWTTokenHelper;
import com.ai.da.feign.seller.SellerFeignClient;
import com.ai.da.common.utils.*;
import com.ai.da.mapper.primary.*;
import com.ai.da.mapper.primary.entity.*;
@@ -96,6 +97,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
@Resource
private JWTTokenHelper jwtTokenHelper;
@Resource
private SellerFeignClient sellerFeignClient;
@Resource
private AccountLoginLogService accountLoginLogService;
@@ -619,6 +623,12 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
LocalCacheUtils.delTokenCache(userIdStr);
// 同时删除 Redis 中的 token防止服务重启后仍然有效
redisUtil.deleteLoginToken(accountLogoutDTO.getUserId());
// 同步调用 seller 清除本地缓存
try {
sellerFeignClient.clearTokenCache(accountLogoutDTO.getUserId());
} catch (Exception e) {
log.warn("调用 seller 清理缓存失败userId={}, error={}", accountLogoutDTO.getUserId(), e.getMessage());
}
return Boolean.TRUE;
}