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

@@ -0,0 +1,20 @@
package com.ai.da.feign.seller;
import com.ai.da.common.response.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 调用 aida-seller 设计师相关接口的 Feign 客户端
*/
@FeignClient(name = "aida-seller", path = "/api/designer")
public interface SellerFeignClient {
@GetMapping("/check")
Response<Boolean> checkDesignerQualification(@RequestParam("userId") Long userId);
@PostMapping("/cache/clear")
Response<Void> clearTokenCache(@RequestParam("userId") Long userId);
}

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;
}

View File

@@ -5,4 +5,4 @@
#spring.profiles.active=prod
#<23><><EFBFBD><EFBFBD>application-dev<65>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
spring.profiles.active=local2
spring.profiles.active=dev