|
@@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class SysDeptServiceImpl extends AbstractCrudService<SysDeptMapper, SysDept> implements ISysDeptService {
|
|
|
|
|
|
- private static final Logger log = LoggerFactory.getLogger(SysDeptServiceImpl.class);//还原代码
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(SysDeptServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
private SysDeptMapper deptMapper;
|
|
@@ -63,13 +63,24 @@ public class SysDeptServiceImpl extends AbstractCrudService<SysDeptMapper, SysDe
|
|
|
return deptMapper.selectDeptList(dept);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询部门管理数据
|
|
|
+ *
|
|
|
+ * @param dept 部门信息
|
|
|
+ * @return 部门信息集合
|
|
|
+ */
|
|
|
@Override
|
|
|
public List<SysDept> deptList(SysDept dept) {
|
|
|
dept.setTenantId(SecurityUtils.getTenantId());
|
|
|
return deptMapper.deptList(dept);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 构建前端所需要树结构
|
|
|
+ *
|
|
|
+ * @param depts 部门列表
|
|
|
+ * @return 树结构列表
|
|
|
+ */
|
|
|
@Override
|
|
|
public List<TreeNode> buildDeptUserTreeSelect(List<SysDept> depts, List<SysUser> users) {
|
|
|
List<Long> userIds = new ArrayList<>();
|
|
@@ -85,6 +96,12 @@ public class SysDeptServiceImpl extends AbstractCrudService<SysDeptMapper, SysDe
|
|
|
return deptTrees.stream().map(TreeNode::new).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 填充用户信息到部门树
|
|
|
+ *
|
|
|
+ * @param depts 部门列表
|
|
|
+ * @param users 用户列表
|
|
|
+ */
|
|
|
private void fillUsersToDepts(List<SysDept> depts, List<SysUser> users) {
|
|
|
for (SysDept dept : depts) {
|
|
|
if (dept.getChildren() == null || dept.getChildren().isEmpty()) {
|
|
@@ -99,12 +116,24 @@ public class SysDeptServiceImpl extends AbstractCrudService<SysDeptMapper, SysDe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据部门ID查询信息
|
|
|
+ *
|
|
|
+ * @param deptId 部门ID
|
|
|
+ * @return 部门信息
|
|
|
+ */
|
|
|
private List<SysUser> filterUsersByDept(List<SysUser> users, Long deptId) {
|
|
|
return users.stream()
|
|
|
.filter(user -> user.getDeptId().equals(deptId))
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 构建前端所需要下拉树结构
|
|
|
+ *
|
|
|
+ * @param depts 部门列表
|
|
|
+ * @return 下拉树结构列表
|
|
|
+ */
|
|
|
private List<SysDept> buildDeptTree2(List<SysDept> depts) {
|
|
|
List<SysDept> returnList = new ArrayList<SysDept>();
|
|
|
List<Long> tempList = new ArrayList<Long>();
|
|
@@ -124,6 +153,13 @@ public class SysDeptServiceImpl extends AbstractCrudService<SysDeptMapper, SysDe
|
|
|
return returnList;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @description: 递归列表
|
|
|
+ * @author: fu
|
|
|
+ * @date: 2024/8/8 16:00
|
|
|
+ * @param: [list, t]
|
|
|
+ * @return: void
|
|
|
+ **/
|
|
|
private void recursionFn2(List<SysDept> list, SysDept t) {
|
|
|
List<SysDept> childList = getChildList(list, t);
|
|
|
t.setChildren(childList);
|
|
@@ -173,30 +209,6 @@ public class SysDeptServiceImpl extends AbstractCrudService<SysDeptMapper, SysDe
|
|
|
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
-/* @Override
|
|
|
- public List<TreeSelect> buildDeptUserTreeSelect(List<SysDept> depts, List<SysUser> users) {
|
|
|
- List<SysDept> deptTrees = buildDeptTree(depts);
|
|
|
- List<TreeSelect> treeSelectList = new ArrayList<>();
|
|
|
- for (SysDept dept : deptTrees) {
|
|
|
- TreeSelect treeSelect = new TreeSelect();
|
|
|
- treeSelect.setId(dept.getDeptId());
|
|
|
- treeSelect.setLabel(dept.getDeptName());
|
|
|
- List<TreeSelect> children = new ArrayList<>();
|
|
|
- for (SysUser user : users) {
|
|
|
- if (user.getDeptId().equals(dept.getDeptId())) {
|
|
|
- TreeSelect child = new TreeSelect();
|
|
|
- child.setId(user.getUserId());
|
|
|
- child.setLabel(user.getNickName());
|
|
|
- children.add(child);
|
|
|
- }
|
|
|
- }
|
|
|
- treeSelect.setChildren(children);
|
|
|
- treeSelectList.add(treeSelect);
|
|
|
- }
|
|
|
- return treeSelectList;
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 根据角色ID查询部门树信息
|
|
|
*
|