优化请求头的 tenant-id 的解析逻辑,避免前端传错类型

This commit is contained in:
YunaiV 2023-04-15 09:48:21 +08:00
parent d2ba90db5d
commit fdea0ae0ea

View File

@ -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.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
@ -40,7 +41,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) {