Przeglądaj źródła

新增角色配置本部门及以下数据权限

RuoYi 5 lat temu
rodzic
commit
50515e1aff

+ 1 - 0
ruoyi-admin/src/main/resources/templates/system/role/dataScope.html

@@ -27,6 +27,7 @@
 						<option value="1" th:field="*{dataScope}">全部数据权限</option>
 						<option value="2" th:field="*{dataScope}">自定数据权限</option>
 						<option value="3" th:field="*{dataScope}">本部门数据权限</option>
+						<option value="4" th:field="*{dataScope}">本部门及以下数据权限</option>
 					</select>
 					<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 特殊情况下,设置为“自定数据权限”</span>
 				</div>

+ 11 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java

@@ -39,6 +39,11 @@ public class DataScopeAspect
      */
     public static final String DATA_SCOPE_DEPT = "3";
 
+    /**
+     * 部门及以下数据权限
+     */
+    public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
+
     /**
      * 数据权限过滤关键字
      */
@@ -105,6 +110,12 @@ public class DataScopeAspect
             {
                 sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", alias, user.getDeptId()));
             }
+            else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
+            {
+                sqlString.append(StringUtils.format(
+                        " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or parent_id= {} )", alias,
+                        user.getDeptId(), user.getDeptId()));
+            }
         }
 
         if (StringUtils.isNotBlank(sqlString.toString()))

+ 0 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java

@@ -80,7 +80,6 @@ public class GlobalExceptionHandler
     public Object businessException(HttpServletRequest request, BusinessException e)
     {
         log.error(e.getMessage(), e);
-
         if (ServletUtils.isAjaxRequest(request))
         {
             return AjaxResult.error(e.getMessage());