From 3216ed3fb2d9dc9cf61da21bda3175e66ec46426 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期五, 06 十二月 2024 17:04:11 +0800 Subject: [PATCH] IailabClient 配置 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/config/FeignTokenInterceptor.java | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/config/FeignTokenInterceptor.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/config/FeignTokenInterceptor.java index 7a2bbbb..0452221 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/config/FeignTokenInterceptor.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/config/FeignTokenInterceptor.java @@ -3,6 +3,7 @@ import com.iailab.module.shasteel.util.token.IailabClient; import feign.RequestInterceptor; import feign.RequestTemplate; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import org.springframework.web.context.request.RequestContextHolder; @@ -11,6 +12,9 @@ @Configuration public class FeignTokenInterceptor implements RequestInterceptor { + @Autowired + private IailabClient iailabClient; + @Override public void apply(RequestTemplate requestTemplate) { // 从当前请求上下文中获取Token @@ -18,16 +22,14 @@ if (token == null) { // 如果没有获取到Token,从system-server中获取token - token = IailabClient.getToken(); - } - - if (token!= null) { - requestTemplate.header(HttpHeaders.AUTHORIZATION, token); - } - - Long tenantId = IailabClient.getTenantId(); - if (tenantId != null) { - requestTemplate.header("tenant-id", String.valueOf(tenantId)); + token = iailabClient.getToken(); + if (token!= null) { + requestTemplate.header(HttpHeaders.AUTHORIZATION, token); + } + Long tenantId = iailabClient.getTenantId(); + if (tenantId != null) { + requestTemplate.header("tenant-id", String.valueOf(tenantId)); + } } } -- Gitblit v1.9.3