Commit fdea0ae0ea04cfe8eb11bb329e8b02645cd87441
1 parent
d2ba90db
优化请求头的 tenant-id 的解析逻辑,避免前端传错类型
Showing
1 changed file
with
2 additions
and
1 deletions
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java
| 1 | package cn.iocoder.yudao.framework.web.core.util; | 1 | package cn.iocoder.yudao.framework.web.core.util; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.util.NumberUtil; | ||
| 3 | import cn.hutool.core.util.StrUtil; | 4 | import cn.hutool.core.util.StrUtil; |
| 4 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 5 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| @@ -40,7 +41,7 @@ public class WebFrameworkUtils { | @@ -40,7 +41,7 @@ public class WebFrameworkUtils { | ||
| 40 | */ | 41 | */ |
| 41 | public static Long getTenantId(HttpServletRequest request) { | 42 | public static Long getTenantId(HttpServletRequest request) { |
| 42 | String tenantId = request.getHeader(HEADER_TENANT_ID); | 43 | String tenantId = request.getHeader(HEADER_TENANT_ID); |
| 43 | - return StrUtil.isNotEmpty(tenantId) ? Long.valueOf(tenantId) : null; | 44 | + return NumberUtil.isNumber(tenantId) ? Long.valueOf(tenantId) : null; |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | public static void setLoginUserId(ServletRequest request, Long userId) { | 47 | public static void setLoginUserId(ServletRequest request, Long userId) { |