|
@@ -2,6 +2,7 @@ package cn.efunbox.manage.base.service.impl;
|
|
|
|
|
|
import cn.efunbox.manage.base.entity.Department;
|
|
import cn.efunbox.manage.base.entity.Department;
|
|
import cn.efunbox.manage.base.enums.BaseStatusEnum;
|
|
import cn.efunbox.manage.base.enums.BaseStatusEnum;
|
|
|
|
+import cn.efunbox.manage.base.enums.DeptTypeEnum;
|
|
import cn.efunbox.manage.base.repository.DepartmentRepository;
|
|
import cn.efunbox.manage.base.repository.DepartmentRepository;
|
|
import cn.efunbox.manage.base.service.DepartmentService;
|
|
import cn.efunbox.manage.base.service.DepartmentService;
|
|
import cn.efunbox.manage.base.vo.DeptTreeVO;
|
|
import cn.efunbox.manage.base.vo.DeptTreeVO;
|
|
@@ -23,12 +24,12 @@ public class DepartmentServiceImpl implements DepartmentService {
|
|
DepartmentRepository departmentRepository;
|
|
DepartmentRepository departmentRepository;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ApiResult getDeptTree(Long deptId) {
|
|
|
|
|
|
+ public ApiResult getDeptTree(Long deptId, DeptTypeEnum deptTypeEnum) {
|
|
return ApiResult.ok(recursiveTree(deptId,new ArrayList<BaseStatusEnum>(){{
|
|
return ApiResult.ok(recursiveTree(deptId,new ArrayList<BaseStatusEnum>(){{
|
|
add(BaseStatusEnum.NORMAL);
|
|
add(BaseStatusEnum.NORMAL);
|
|
add(BaseStatusEnum.DEL);
|
|
add(BaseStatusEnum.DEL);
|
|
add(BaseStatusEnum.DISABLE);
|
|
add(BaseStatusEnum.DISABLE);
|
|
- }}));
|
|
|
|
|
|
+ }}, deptTypeEnum));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -70,13 +71,13 @@ public class DepartmentServiceImpl implements DepartmentService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ApiResult getDeptChild(Long deptId) {
|
|
|
|
|
|
+ public ApiResult getDeptChild(Long deptId, DeptTypeEnum deptTypeEnum) {
|
|
List<Department> departments = new ArrayList<>();
|
|
List<Department> departments = new ArrayList<>();
|
|
departments = deptChild(deptId,departments,new ArrayList<BaseStatusEnum>(){{
|
|
departments = deptChild(deptId,departments,new ArrayList<BaseStatusEnum>(){{
|
|
add(BaseStatusEnum.NORMAL);
|
|
add(BaseStatusEnum.NORMAL);
|
|
add(BaseStatusEnum.DEL);
|
|
add(BaseStatusEnum.DEL);
|
|
add(BaseStatusEnum.DISABLE);
|
|
add(BaseStatusEnum.DISABLE);
|
|
- }});
|
|
|
|
|
|
+ }},deptTypeEnum);
|
|
List<Long> deptIds = new ArrayList<>();
|
|
List<Long> deptIds = new ArrayList<>();
|
|
departments.stream().forEach(department -> {
|
|
departments.stream().forEach(department -> {
|
|
deptIds.add(department.getPath());
|
|
deptIds.add(department.getPath());
|
|
@@ -108,28 +109,28 @@ public class DepartmentServiceImpl implements DepartmentService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ApiResult select() {
|
|
|
|
- return ApiResult.ok(departmentRepository.findSelect());
|
|
|
|
|
|
+ public ApiResult select(DeptTypeEnum type) {
|
|
|
|
+ return ApiResult.ok(departmentRepository.findSelect(type.ordinal()));
|
|
}
|
|
}
|
|
|
|
|
|
- private DeptTreeVO recursiveTree(Long cid, List<BaseStatusEnum> status) {
|
|
|
|
|
|
+ private DeptTreeVO recursiveTree(Long cid, List<BaseStatusEnum> status, DeptTypeEnum deptTypeEnum) {
|
|
Department department = departmentRepository.find(cid);
|
|
Department department = departmentRepository.find(cid);
|
|
DeptTreeVO node = new DeptTreeVO();
|
|
DeptTreeVO node = new DeptTreeVO();
|
|
node.setLabel(department.getName());
|
|
node.setLabel(department.getName());
|
|
node.setId(department.getId());
|
|
node.setId(department.getId());
|
|
- List<Department> childTreeNodes = departmentRepository.findByPathAndStatusInOrderByCodeAsc(cid, status);
|
|
|
|
|
|
+ List<Department> childTreeNodes = departmentRepository.findByPathAndTypeAndStatusInOrderByCodeAsc(cid, deptTypeEnum, status);
|
|
for(Department child : childTreeNodes){
|
|
for(Department child : childTreeNodes){
|
|
- DeptTreeVO n = recursiveTree(child.getId(), status); //递归
|
|
|
|
|
|
+ DeptTreeVO n = recursiveTree(child.getId(), status, deptTypeEnum); //递归
|
|
node.getChildren().add(n);
|
|
node.getChildren().add(n);
|
|
}
|
|
}
|
|
return node;
|
|
return node;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<Department> deptChild(Long cid, List<Department> departments, List<BaseStatusEnum> status) {
|
|
|
|
- List<Department> childTreeNodes = departmentRepository.findByPathAndStatusInOrderByCodeAsc(cid, status);
|
|
|
|
|
|
+ private List<Department> deptChild(Long cid, List<Department> departments, List<BaseStatusEnum> status, DeptTypeEnum deptTypeEnum) {
|
|
|
|
+ List<Department> childTreeNodes = departmentRepository.findByPathAndTypeAndStatusInOrderByCodeAsc(cid, deptTypeEnum, status);
|
|
departments.addAll(childTreeNodes);
|
|
departments.addAll(childTreeNodes);
|
|
for(Department child : childTreeNodes){
|
|
for(Department child : childTreeNodes){
|
|
- deptChild(child.getId(), departments, status); //递归
|
|
|
|
|
|
+ deptChild(child.getId(), departments, status, deptTypeEnum); //递归
|
|
}
|
|
}
|
|
return departments;
|
|
return departments;
|
|
}
|
|
}
|