From 093e7212cfc74862ba41e319a51bfa77282a3302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Fri, 21 Apr 2023 09:42:55 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=96=B0=E5=A2=9E=20=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90=E5=86=99=E6=B3=95=20?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=BC=82=E5=B8=B8=E4=B8=8D=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/helper/DataPermissionHelper.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/helper/DataPermissionHelper.java b/ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/helper/DataPermissionHelper.java index 32e1bca3..7f6ab1f0 100644 --- a/ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/helper/DataPermissionHelper.java +++ b/ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/helper/DataPermissionHelper.java @@ -10,6 +10,7 @@ import lombok.NoArgsConstructor; import java.util.HashMap; import java.util.Map; +import java.util.function.Supplier; /** * 数据权限助手 @@ -61,4 +62,32 @@ public class DataPermissionHelper { InterceptorIgnoreHelper.clearIgnoreStrategy(); } + /** + * 在忽略数据权限中执行 + * + * @param handle 处理执行方法 + */ + public static void ignore(Runnable handle) { + enableIgnore(); + try { + handle.run(); + } finally { + disableIgnore(); + } + } + + /** + * 在忽略数据权限中执行 + * + * @param handle 处理执行方法 + */ + public static T ignore(Supplier handle) { + enableIgnore(); + try { + return handle.get(); + } finally { + disableIgnore(); + } + } + }