From 966d7ce81bce3f6cbd330944b81ba3cf29af775c Mon Sep 17 00:00:00 2001 From: JustryDeng <13548417409@163.com> Date: Fri, 25 Oct 2024 11:21:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?version=20=3D>=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E6=9B=B4=E6=96=B0=E8=87=B31.1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8085493..18a669a 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ - 1.0.9 + 1.1.0 1.6.0 -- Gitee From 6216d93bbde063899756009b5511a37f2417d8d3 Mon Sep 17 00:00:00 2001 From: JustryDeng <13548417409@163.com> Date: Fri, 25 Oct 2024 14:02:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?reform=20=3D>=20mybatis-plus=E7=A7=9F?= =?UTF-8?q?=E6=88=B7like=E7=BB=84=E4=BB=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0URD?= =?UTF-8?q?=E6=97=B6=E5=BC=BA=E5=88=B6=E5=BF=BD=E7=95=A5=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E7=9A=84=E6=80=BB=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ZooTenantLikeAutoConfiguration.java | 6 ++++-- .../properties/ZooTenantLikeProperties.java | 20 +++++++++++++++++++ .../LikeTenantLineInnerInterceptor.java | 13 +++++++++++- .../zoo-diy-artifact-tenant-like.default.yaml | 2 ++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/ZooTenantLikeAutoConfiguration.java b/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/ZooTenantLikeAutoConfiguration.java index a932dcc..be729eb 100644 --- a/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/ZooTenantLikeAutoConfiguration.java +++ b/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/ZooTenantLikeAutoConfiguration.java @@ -56,7 +56,9 @@ public class ZooTenantLikeAutoConfiguration { * 插件配置 */ @Bean(name = AutoConfigurationConstant.MYBATIS_PLUS_INTERCEPTOR_BEAN_NAME) - public MybatisPlusInterceptor mybatisPlusInterceptor(MybatisPlusInfoHolder mybatisPlusInfoHolder, List fullSqlPreparePreHandlers) { + public MybatisPlusInterceptor mybatisPlusInterceptor(MybatisPlusInfoHolder mybatisPlusInfoHolder, + ZooTenantLikeProperties zooTenantLikeProperties, + List fullSqlPreparePreHandlers) { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); if (!CollectionUtils.isEmpty(fullSqlPreparePreHandlers)) { interceptor.addInnerInterceptor(new SqlPreparePreInterceptor(fullSqlPreparePreHandlers)); @@ -100,7 +102,7 @@ public class ZooTenantLikeAutoConfiguration { } return !tenantTables.contains(tableName); } - })); + }, zooTenantLikeProperties)); // 分页插件 interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); diff --git a/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/properties/ZooTenantLikeProperties.java b/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/properties/ZooTenantLikeProperties.java index 9a9ecfe..c2cd265 100644 --- a/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/properties/ZooTenantLikeProperties.java +++ b/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/properties/ZooTenantLikeProperties.java @@ -1,7 +1,10 @@ package com.ideaaedi.zoo.diy.artifact.tenantlike.properties; import com.ideaaedi.zoo.commonbase.component.auth.AuthUrlWhitelist; +import com.ideaaedi.zoo.commonbase.component.tenantlike.annotation.Tenant; +import com.ideaaedi.zoo.commonbase.util.ZooContext; import com.ideaaedi.zoo.diy.artifact.tenantlike.properties.nested.VisitorTenantInfo; +import com.ideaaedi.zoo.diy.artifact.tenantlike.tenant.TenantProvider; import jakarta.validation.Valid; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -17,6 +20,7 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; @Data @ConfigurationProperties(prefix = "zoo.tenant") public class ZooTenantLikeProperties { + /** * 作为bizTenant的tenant的层级 *

@@ -30,6 +34,22 @@ public class ZooTenantLikeProperties { */ private int bizTenantLevel = 2; + /** + * URD(修改、查询、删除)数据时,是否忽略租户过滤 + *

+     * 注1:当此参数为true时,无论程序中是否还有使用{@link ZooContext.TenantCt}
+     *     或 {@link TenantProvider} 或 {@link Tenant}指定URD租户值的操作,
+     *     最终在进行URD操作时,都会忽略租户过滤。
+     *     即:此字段的优先级最高
+     *
+     * 注2:此参数仅对修改、查询、删除操作生效,对新增操作不影响
+     *      即1:通过{@link ZooContext.TenantCt} 或 {@link TenantProvider}
+     *           或 {@link Tenant}指定新增数据时的租户值的操作,仍然有效
+     *      即2:程序中,新增数据时,该需要租户值的,还是需要;不需要租户值得,还是不需要
+     * 
+ */ + private boolean forceIgnoreUrd = false; + /** * 游客租户信息 *
diff --git a/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/tenant/LikeTenantLineInnerInterceptor.java b/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/tenant/LikeTenantLineInnerInterceptor.java
index e46861d..0f65bf3 100644
--- a/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/tenant/LikeTenantLineInnerInterceptor.java
+++ b/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/java/com/ideaaedi/zoo/diy/artifact/tenantlike/tenant/LikeTenantLineInnerInterceptor.java
@@ -12,6 +12,7 @@ import com.ideaaedi.zoo.commonbase.constant.ZooConstant;
 import com.ideaaedi.zoo.commonbase.entity.codemsg.ZooBaseCodeMsgEnum;
 import com.ideaaedi.zoo.commonbase.exception.ZooException;
 import com.ideaaedi.zoo.commonbase.util.ZooContext;
+import com.ideaaedi.zoo.diy.artifact.tenantlike.properties.ZooTenantLikeProperties;
 import net.sf.jsqlparser.expression.BinaryExpression;
 import net.sf.jsqlparser.expression.DoubleValue;
 import net.sf.jsqlparser.expression.Expression;
@@ -68,9 +69,13 @@ public class LikeTenantLineInnerInterceptor extends TenantLineInnerInterceptor {
     
     private final TenantLineHandler tenantLineHandler;
     
-    public LikeTenantLineInnerInterceptor(TenantLineHandler tenantLineHandler) {
+    private final ZooTenantLikeProperties zooTenantLikeProperties;
+    
+    public LikeTenantLineInnerInterceptor(TenantLineHandler tenantLineHandler,
+                                          ZooTenantLikeProperties zooTenantLikeProperties) {
         super(tenantLineHandler);
         this.tenantLineHandler = tenantLineHandler;
+        this.zooTenantLikeProperties = zooTenantLikeProperties;
     }
     
     @Override
@@ -156,6 +161,9 @@ public class LikeTenantLineInnerInterceptor extends TenantLineInnerInterceptor {
     
     @Override
     protected void processDelete(Delete delete, int index, String sql, Object obj) {
+        if (zooTenantLikeProperties.isForceIgnoreUrd()) {
+            return;
+        }
         if (shouldIgnoreTenant(false)) {
             return;
         }
@@ -164,6 +172,9 @@ public class LikeTenantLineInnerInterceptor extends TenantLineInnerInterceptor {
     
     @Override
     protected void processUpdate(Update update, int index, String sql, Object obj) {
+        if (zooTenantLikeProperties.isForceIgnoreUrd()) {
+            return;
+        }
         if (shouldIgnoreTenant(false)) {
             return;
         }
diff --git a/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/resources/zoo-diy-artifact-tenant-like.default.yaml b/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/resources/zoo-diy-artifact-tenant-like.default.yaml
index 82b5a6d..dc611ec 100644
--- a/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/resources/zoo-diy-artifact-tenant-like.default.yaml
+++ b/zoo-diy-artifact/zoo-diy-artifact-tenant-like/src/main/resources/zoo-diy-artifact-tenant-like.default.yaml
@@ -23,6 +23,8 @@ zoo:
   tenant:
     # 设置从第二层级开始,属于业务租户值
     biz-tenant-level: 2
+    # 全局配置。当进行urd操作(即:修改、查询、删除)时,是否强制忽略租户过滤
+    force-ignore-urd: false
     # 游客用户id & 租户信息配置
     visitor:
       user-id: 0
-- 
Gitee