feat:部门权限

This commit is contained in:
dzc committed 2025-06-23 10:44:14 +08:00
1 parent 47d6fd77d0
commit d127f0be1e
2 files changed
+16 -5

No files matched your search

@@ -101,7 +101,7 @@ public class SysDeptController {
} catch (Exception e) {
log.error("获取当前用户ID异常", e);
}
if (ObjectUtil.isNotEmpty(parentId)) {
if (ObjectUtil.isEmpty(parentId)) {
parentId = deptId;
}
return R.ok(sysDeptService.selectTree(deptName, parentId));
@@ -133,9 +133,15 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
*/
@Override
public List<Tree<Long>> selectTree(String deptName, Long parentId) {
// 查询全部部门
List<SysDept> deptAllList = deptMapper
.selectList(Wrappers.<SysDept>lambdaQuery().like(StrUtil.isNotBlank(deptName), SysDept::getName, deptName));
List<SysDept> deptAllList = new ArrayList<>();
if (ObjectUtil.isEmpty(parentId)) {
// 查询全部部门
deptAllList = deptMapper
.selectList(Wrappers.<SysDept>lambdaQuery().like(StrUtil.isNotBlank(deptName), SysDept::getName, deptName));
} else {
deptAllList = listDescendant(parentId);
}
// 查询数据权限内部门
List<Long> deptOwnIdList = deptMapper
.selectListByScope(
@@ -173,7 +179,12 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
return tree;
}).collect(Collectors.toList());
}
if (ObjectUtil.isNotEmpty(parentId)) {
SysDept parentDept = getById(parentId);
if (ObjectUtil.isNotEmpty(parentDept) && ObjectUtil.isNotEmpty(parentDept.getParentId())) {
parentId = parentDept.getParentId();
}
}
return TreeUtil.build(collect, parentId == null ? 0 : parentId);
}