From dd37247e65374dd4ef7e8e8b9212d8f29023e301 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期一, 27 十二月 2021 09:50:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into satoken

---
 ruoyi-common/src/main/java/com/ruoyi/common/enums/DataScopeType.java |   72 ++++++++++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataScopeType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataScopeType.java
new file mode 100644
index 0000000..7cf3d5e
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataScopeType.java
@@ -0,0 +1,72 @@
+package com.ruoyi.common.enums;
+
+import com.ruoyi.common.utils.StringUtils;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 鏁版嵁鏉冮檺绫诲瀷
+ *
+ * 璇硶鏀寔 spel 妯℃澘琛ㄨ揪寮�
+ *
+ * 鍐呯疆鏁版嵁 user 褰撳墠鐢ㄦ埛 鍐呭鍙傝�� SysUser
+ * 濡傞渶鎵╁睍鏁版嵁 鍙娇鐢� {@link com.ruoyi.common.helper.DataPermissionHelper} 鎿嶄綔
+ * 鍐呯疆鏈嶅姟 sdss 绯荤粺鏁版嵁鏉冮檺鏈嶅姟 鍐呭鍙傝�� SysDataScopeService
+ * 濡傞渶鎵╁睍鏇村鑷畾涔夋湇鍔� 鍙互鍙傝�� sdss 鑷缂栧啓
+ *
+ * @author Lion Li
+ * @version 3.5.0
+ */
+@Getter
+@AllArgsConstructor
+public enum DataScopeType {
+
+    /**
+     * 鍏ㄩ儴鏁版嵁鏉冮檺
+     */
+    ALL("1", "", ""),
+
+    /**
+     * 鑷畾鏁版嵁鏉冮檺
+     */
+    CUSTOM("2", " #{#deptName} IN ( #{@sdss.getRoleCustom( #user.roleId )} ) ", ""),
+
+    /**
+     * 閮ㄩ棬鏁版嵁鏉冮檺
+     */
+    DEPT("3", " #{#deptName} = #{#user.deptId} ", ""),
+
+    /**
+     * 閮ㄩ棬鍙婁互涓嬫暟鎹潈闄�
+     */
+    DEPT_AND_CHILD("4", " #{#deptName} IN ( #{@sdss.getDeptAndChild( #user.deptId )} )", ""),
+
+    /**
+     * 浠呮湰浜烘暟鎹潈闄�
+     */
+    SELF("5", " #{#userName} = #{#user.userId} " , " 1 = 0 ");
+
+    private final String code;
+
+    /**
+     * 璇硶 閲囩敤 spel 妯℃澘琛ㄨ揪寮�
+     */
+    private final String sqlTemplate;
+
+    /**
+     * 涓嶆弧瓒� sqlTemplate 鍒欏~鍏�
+     */
+    private final String elseSql;
+
+    public static DataScopeType findCode(String code) {
+        if (StringUtils.isBlank(code)) {
+            return null;
+        }
+        for (DataScopeType type : values()) {
+            if (type.getCode().equals(code)) {
+                return type;
+            }
+        }
+        return null;
+    }
+}

--
Gitblit v1.9.3