From 280f8c26ac0ecbc00087b999434073535bfd9087 Mon Sep 17 00:00:00 2001 From: zhangdaiscott Date: Wed, 31 Mar 2021 12:00:51 +0800 Subject: [PATCH] =?UTF-8?q?online=E6=8A=A5=E8=A1=A8=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E7=A7=9F=E6=88=B7=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=8F=98=E9=87=8F=20issues/I3CL75?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/DataBaseConstant.java | 10 ++++++++++ .../org/jeecg/common/system/util/JwtUtil.java | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DataBaseConstant.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DataBaseConstant.java index 76159660..75223886 100644 --- a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DataBaseConstant.java +++ b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DataBaseConstant.java @@ -111,4 +111,14 @@ public interface DataBaseConstant { */ public static final String BPM_STATUS_TABLE = "bpm_status"; //*********系统建表标准字段**************************************** + + + /** + * 租户ID 实体字段名 + */ + String TENANT_ID = "tenantId"; + /** + * 租户ID 数据库字段名 + */ + String TENANT_ID_TABLE = "tenant_id"; } diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/util/JwtUtil.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/util/JwtUtil.java index e3a9420f..29c47454 100644 --- a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/util/JwtUtil.java +++ b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/util/JwtUtil.java @@ -6,12 +6,8 @@ import com.auth0.jwt.algorithms.Algorithm; import com.auth0.jwt.exceptions.JWTDecodeException; import com.auth0.jwt.interfaces.DecodedJWT; import com.google.common.base.Joiner; - -import java.util.Date; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; - import org.apache.shiro.SecurityUtils; +import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.DataBaseConstant; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.vo.LoginUser; @@ -20,6 +16,10 @@ import org.jeecg.common.util.DateUtils; import org.jeecg.common.util.SpringContextUtils; import org.jeecg.common.util.oConvertUtils; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.util.Date; + /** * @Author Scott * @Date 2018-07-12 14:23 @@ -197,6 +197,14 @@ public class JwtUtil { else if (key.equals(DataBaseConstant.BPM_STATUS)|| key.toLowerCase().equals(DataBaseConstant.BPM_STATUS_TABLE)) { returnValue = "1"; } + //update-begin-author:taoyan date:20210330 for:多租户ID作为系统变量 + else if (key.equals(DataBaseConstant.TENANT_ID) || key.toLowerCase().equals(DataBaseConstant.TENANT_ID_TABLE)){ + returnValue = sysUser.getRelTenantIds(); + if(oConvertUtils.isEmpty(returnValue) || (returnValue!=null && returnValue.indexOf(",")>0)){ + returnValue = SpringContextUtils.getHttpServletRequest().getHeader(CommonConstant.TENANT_ID); + } + } + //update-end-author:taoyan date:20210330 for:多租户ID作为系统变量 if(returnValue!=null){returnValue = returnValue + moshi;} return returnValue; }