mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 08:13:44 +08:00 
			
		
		
		
	add 新增 忽略数据权限写法 防止异常不执行关闭问题
This commit is contained in:
		@@ -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> T ignore(Supplier<T> handle) {
 | 
			
		||||
        enableIgnore();
 | 
			
		||||
        try {
 | 
			
		||||
            return handle.get();
 | 
			
		||||
        } finally {
 | 
			
		||||
            disableIgnore();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user