Skip to content

Commit

Permalink
feat: 角色配置本部门及以下数据权限
Browse files Browse the repository at this point in the history
  • Loading branch information
lerry903 committed Jun 2, 2019
1 parent 15df551 commit efe585d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public class DataScopeAspect {
*/
private static final String DATA_SCOPE_DEPT = "3";

/**
* 部门及以下数据权限
*/
public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";

/**
* 数据权限过滤关键字
*/
Expand Down Expand Up @@ -85,10 +90,12 @@ private static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String al
break;
} else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
sqlString.append(String.format(
" OR %s.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = %s ) " , alias,
" OR %s.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = %d ) " , alias,
role.getRoleId()));
}else if (DATA_SCOPE_DEPT.equals(dataScope)){
sqlString.append(String.format(" OR %s.dept_id = %s ", alias, user.getDeptId()));
sqlString.append(String.format(" OR %s.dept_id = %d ", alias, user.getDeptId()));
}else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)){
sqlString.append(String.format(" OR %s.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = %d or parent_id = %d )", alias, user.getDeptId(), user.getDeptId()));
}
}

Expand Down

0 comments on commit efe585d

Please sign in to comment.