From 61c80ad97b7aa044c9492834c6d753024db37adf Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 11 Jun 2022 22:54:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=20"tenant-id"=20=E7=9A=84?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tenant/core/mq/TenantRedisMessageInterceptor.java | 4 ++-- .../framework/tenant/core/web/TenantContextWebFilter.java | 2 -- .../swagger/config/YudaoSwaggerAutoConfiguration.java | 4 +++- .../yudao/framework/web/core/util/WebFrameworkUtils.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/TenantRedisMessageInterceptor.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/TenantRedisMessageInterceptor.java index 15c72f992..c493b41d1 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/TenantRedisMessageInterceptor.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/TenantRedisMessageInterceptor.java @@ -5,6 +5,8 @@ import cn.iocoder.yudao.framework.mq.core.interceptor.RedisMessageInterceptor; import cn.iocoder.yudao.framework.mq.core.message.AbstractRedisMessage; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_TENANT_ID; + /** * 多租户 {@link AbstractRedisMessage} 拦截器 * @@ -15,8 +17,6 @@ import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; */ public class TenantRedisMessageInterceptor implements RedisMessageInterceptor { - private static final String HEADER_TENANT_ID = "tenant-id"; - @Override public void sendMessageBefore(AbstractRedisMessage message) { Long tenantId = TenantContextHolder.getTenantId(); diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/web/TenantContextWebFilter.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/web/TenantContextWebFilter.java index 272419c09..8e37727d9 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/web/TenantContextWebFilter.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/web/TenantContextWebFilter.java @@ -18,8 +18,6 @@ import java.io.IOException; */ public class TenantContextWebFilter extends OncePerRequestFilter { - private static final String HEADER_TENANT_ID = "tenant-id"; - @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java index 8b0815b73..f2fc32a8c 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java @@ -22,6 +22,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; import java.util.Collections; import java.util.List; +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_TENANT_ID; import static springfox.documentation.builders.RequestHandlerSelectors.basePackage; /** @@ -114,7 +115,8 @@ public class YudaoSwaggerAutoConfiguration { // ========== globalRequestParameters ========== private static List globalRequestParameters() { - RequestParameterBuilder tenantParameter = new RequestParameterBuilder().name("tenant-id").description("租户编号") + RequestParameterBuilder tenantParameter = new RequestParameterBuilder() + .name(HEADER_TENANT_ID).description("租户编号") .in(ParameterType.HEADER).example(new ExampleBuilder().value(1L).build()); return Collections.singletonList(tenantParameter.build()); } diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java index f5ac676fa..e11a3236a 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java @@ -23,7 +23,7 @@ public class WebFrameworkUtils { private static final String REQUEST_ATTRIBUTE_COMMON_RESULT = "common_result"; - private static final String HEADER_TENANT_ID = "tenant-id"; + public static final String HEADER_TENANT_ID = "tenant-id"; private static WebProperties properties;