token保持一致
This commit is contained in:
20
src/main/java/com/ai/da/feign/seller/SellerFeignClient.java
Normal file
20
src/main/java/com/ai/da/feign/seller/SellerFeignClient.java
Normal 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);
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import com.ai.da.common.enums.ProductEnum;
|
|||||||
import com.ai.da.common.response.PageBaseResponse;
|
import com.ai.da.common.response.PageBaseResponse;
|
||||||
import com.ai.da.common.response.ResultEnum;
|
import com.ai.da.common.response.ResultEnum;
|
||||||
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
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.common.utils.*;
|
||||||
import com.ai.da.mapper.primary.*;
|
import com.ai.da.mapper.primary.*;
|
||||||
import com.ai.da.mapper.primary.entity.*;
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
@@ -96,6 +97,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
@Resource
|
@Resource
|
||||||
private JWTTokenHelper jwtTokenHelper;
|
private JWTTokenHelper jwtTokenHelper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SellerFeignClient sellerFeignClient;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AccountLoginLogService accountLoginLogService;
|
private AccountLoginLogService accountLoginLogService;
|
||||||
|
|
||||||
@@ -619,6 +623,12 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
LocalCacheUtils.delTokenCache(userIdStr);
|
LocalCacheUtils.delTokenCache(userIdStr);
|
||||||
// 同时删除 Redis 中的 token,防止服务重启后仍然有效
|
// 同时删除 Redis 中的 token,防止服务重启后仍然有效
|
||||||
redisUtil.deleteLoginToken(accountLogoutDTO.getUserId());
|
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;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,4 @@
|
|||||||
#spring.profiles.active=prod
|
#spring.profiles.active=prod
|
||||||
|
|
||||||
#<23><><EFBFBD><EFBFBD>application-dev<65>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
#<23><><EFBFBD><EFBFBD>application-dev<65>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
spring.profiles.active=local2
|
spring.profiles.active=dev
|
||||||
|
|||||||
Reference in New Issue
Block a user