| | |
| | | grantedAuthorities.add(new SimpleGrantedAuthority(RoleEnum.DEPT_ADMIN.getRoleName())); |
| | | } |
| | | grantedAuthorities.add(new SimpleGrantedAuthority(RoleEnum.fromCode(user.getRole()).getRoleName())); |
| | | // 获取该用户管理部门 |
| | | // 获取该用户管理部门及其下级 |
| | | List<Integer> deptAdminIds = userService.getDeptAdminIds(user.getId()); |
| | | if (! CollectionUtils.isEmpty(deptAdminIds)) { |
| | | deptAdminIds = departmentMapper.getChilds(deptAdminIds); // 查询子部门 |
| | | } |
| | | if (CollectionUtils.isEmpty(deptAdminIds)) { |
| | | // 如果是普通学员,查出所在部门 |
| | | deptAdminIds = userService.getDeptIds(user.getId()); |
| | |
| | | * @return |
| | | */ |
| | | List<CascaderDataVO> list(); |
| | | |
| | | /** |
| | | * 获取这些部门拥有的子部门 |
| | | * |
| | | * @param deptIds |
| | | * @return |
| | | */ |
| | | List<Integer> getChilds(@Param("deptIds") List<Integer> deptIds); |
| | | } |
| | |
| | | SELECT id as value, name as label, parent_id FROM t_department WHERE deleted = 0 |
| | | </select> |
| | | |
| | | <select id="getChilds" resultType="integer"> |
| | | WITH RECURSIVE temp_table AS ( |
| | | SELECT |
| | | id, name, parent_id FROM t_department WHERE id in <foreach collection="deptIds" open="(" item="deptId" close=")" separator=",">#{deptId}</foreach> |
| | | UNION ALL |
| | | SELECT |
| | | so.id, so.name, so.parent_id FROM t_department so INNER JOIN temp_table tb ON so.parent_id = tb.id |
| | | ) |
| | | SELECT |
| | | DISTINCT id |
| | | FROM |
| | | temp_table |
| | | </select> |
| | | |
| | | </mapper> |