From 1e32aaa77e120618855f453845be5c9879c563e9 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 15 Apr 2023 09:47:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=B7=E6=B1=82=E5=A4=B4?= =?UTF-8?q?=E7=9A=84=20tenant-id=20=E7=9A=84=E8=A7=A3=E6=9E=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E9=81=BF=E5=85=8D=E5=89=8D=E7=AB=AF=E4=BC=A0?= =?UTF-8?q?=E9=94=99=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/framework/web/core/util/WebFrameworkUtils.java | 3 ++- .../java/cn/iocoder/yudao/gateway/util/WebFrameworkUtils.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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 68e5b6b47..cf3b57c62 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 @@ -1,5 +1,6 @@ package cn.iocoder.yudao.framework.web.core.util; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.enums.RpcConstants; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; @@ -41,7 +42,7 @@ public class WebFrameworkUtils { */ public static Long getTenantId(HttpServletRequest request) { String tenantId = request.getHeader(HEADER_TENANT_ID); - return StrUtil.isNotEmpty(tenantId) ? Long.valueOf(tenantId) : null; + return NumberUtil.isNumber(tenantId) ? Long.valueOf(tenantId) : null; } public static void setLoginUserId(ServletRequest request, Long userId) { diff --git a/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/util/WebFrameworkUtils.java b/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/util/WebFrameworkUtils.java index 19e835683..bc28664bc 100644 --- a/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/util/WebFrameworkUtils.java +++ b/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/util/WebFrameworkUtils.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.gateway.util; import cn.hutool.core.net.NetUtil; import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.extra.servlet.ServletUtil; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import lombok.extern.slf4j.Slf4j; @@ -44,7 +45,7 @@ public class WebFrameworkUtils { public static Long getTenantId(ServerWebExchange exchange) { String tenantId = exchange.getRequest().getHeaders().getFirst(HEADER_TENANT_ID); - return tenantId != null ? Long.parseLong(tenantId) : null; + return NumberUtil.isNumber(tenantId) ? Long.valueOf(tenantId) : null; } /**