From 233ab192705efeb10450dac89c9a7d4b09d69e1b Mon Sep 17 00:00:00 2001 From: zlt2000 Date: Sat, 4 Mar 2023 22:46:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8Azlt-web=E7=9A=84=E7=88=B6=E7=BA=A7?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../properties/DataScopeProperties.java | 10 ++--- .../central/common/utils/LoginUserUtils.java | 12 +++++ zlt-web/layui-web/pom.xml | 3 +- zlt-web/pom.xml | 45 +++---------------- zlt-web/react-web/pom.xml | 6 +-- 6 files changed, 27 insertions(+), 51 deletions(-) diff --git a/pom.xml b/pom.xml index 9392c069..5c6ebe8e 100644 --- a/pom.xml +++ b/pom.xml @@ -489,7 +489,7 @@ zlt-business - + zlt-web zlt-job diff --git a/zlt-commons/zlt-common-core/src/main/java/com/central/common/properties/DataScopeProperties.java b/zlt-commons/zlt-common-core/src/main/java/com/central/common/properties/DataScopeProperties.java index 0b0e5e0a..2d3720a3 100644 --- a/zlt-commons/zlt-common-core/src/main/java/com/central/common/properties/DataScopeProperties.java +++ b/zlt-commons/zlt-common-core/src/main/java/com/central/common/properties/DataScopeProperties.java @@ -32,26 +32,26 @@ public class DataScopeProperties { */ private Boolean enabledSqlDebug = Boolean.FALSE; /** - * 在includeTables的匹配符中过滤某几个表不需要权限的,仅enabled=true + * 配置那些表不执行权限控制 */ private Set ignoreTables = Collections.emptySet(); /** - * 指定某几条sql不执行权限控制, 仅enabled=true生效 + * 指定那些sql不执行权限控制 */ private Set ignoreSqls = INGORE_SQL_ID; /** - * 指定某几个表接受权限控制,仅enabled=true,默认当开启时全部表 + * 配置那些表执行数据权限控制,默认是*则表示全部 */ private Set includeTables = Collections.singleton("*"); /** - * 指定某几条sql执行权限控制,仅enabled=true生效 + * 指定那些sql执行数据权限控制 * 1. 为空时:所有sql都添加权限控制 * 2. 有值时:只有配置的sql添加权限控制 */ private Set includeSqls = Collections.emptySet(); /** - * 指定需要的字段名 + * 指定创建人id的字段名 */ private String creatorIdColumnName = "creator_id"; diff --git a/zlt-commons/zlt-common-core/src/main/java/com/central/common/utils/LoginUserUtils.java b/zlt-commons/zlt-common-core/src/main/java/com/central/common/utils/LoginUserUtils.java index 3fdf1be4..b05ecdfd 100644 --- a/zlt-commons/zlt-common-core/src/main/java/com/central/common/utils/LoginUserUtils.java +++ b/zlt-commons/zlt-common-core/src/main/java/com/central/common/utils/LoginUserUtils.java @@ -8,6 +8,8 @@ import com.central.common.model.SysUser; import org.springframework.security.authentication.AnonymousAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; @@ -66,4 +68,14 @@ public class LoginUserUtils { } return user; } + + public static SysUser getCurrentUser(boolean isFull) { + // 从请求上下文里获取 Request 对象 + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletRequest contextRequest = requestAttributes.getRequest(); + if (contextRequest != null) { + return LoginUserUtils.getCurrentUser(contextRequest, isFull); + } + return null; + } } diff --git a/zlt-web/layui-web/pom.xml b/zlt-web/layui-web/pom.xml index b0cf64fe..a092bf30 100644 --- a/zlt-web/layui-web/pom.xml +++ b/zlt-web/layui-web/pom.xml @@ -6,7 +6,7 @@ com.zlt zlt-web - 5.4.0 + 5.5.0 layui-web Layui开发的前端 @@ -14,7 +14,6 @@ org.springframework.boot spring-boot-starter-web - 2.5.14 layui-web diff --git a/zlt-web/react-web/pom.xml b/zlt-web/react-web/pom.xml index e71c856c..4d8d5387 100644 --- a/zlt-web/react-web/pom.xml +++ b/zlt-web/react-web/pom.xml @@ -5,7 +5,7 @@ zlt-web com.zlt - 5.4.0 + 5.5.0 4.0.0 @@ -22,7 +22,7 @@ spring-boot-starter-web - + \ No newline at end of file