From 32a228485b878708c61e37a9f3e098ddd93f15d7 Mon Sep 17 00:00:00 2001 From: litianxiang Date: Mon, 20 Apr 2026 10:26:04 +0800 Subject: [PATCH] =?UTF-8?q?token=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/da/feign/seller/SellerFeignClient.java | 20 +++++++++++++++++++ .../da/service/impl/AccountServiceImpl.java | 10 ++++++++++ src/main/resources/application.properties | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/ai/da/feign/seller/SellerFeignClient.java diff --git a/src/main/java/com/ai/da/feign/seller/SellerFeignClient.java b/src/main/java/com/ai/da/feign/seller/SellerFeignClient.java new file mode 100644 index 00000000..358d08bf --- /dev/null +++ b/src/main/java/com/ai/da/feign/seller/SellerFeignClient.java @@ -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 checkDesignerQualification(@RequestParam("userId") Long userId); + + @PostMapping("/cache/clear") + Response clearTokenCache(@RequestParam("userId") Long userId); +} diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index 246f3e94..5d4af0d8 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -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 impl @Resource private JWTTokenHelper jwtTokenHelper; + @Resource + private SellerFeignClient sellerFeignClient; + @Resource private AccountLoginLogService accountLoginLogService; @@ -619,6 +623,12 @@ public class AccountServiceImpl extends ServiceImpl 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; } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 57276cce..974fee23 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,4 +5,4 @@ #spring.profiles.active=prod #����application-dev�ļ�(��������) -spring.profiles.active=local2 +spring.profiles.active=dev