|
@@ -8,6 +8,7 @@ import cn.efunbox.manage.base.vo.DeptTreeVO;
|
|
import cn.efunbox.manage.common.result.ApiCode;
|
|
import cn.efunbox.manage.common.result.ApiCode;
|
|
import cn.efunbox.manage.common.result.ApiResult;
|
|
import cn.efunbox.manage.common.result.ApiResult;
|
|
import cn.efunbox.manage.common.utils.SnowflakeIdUtil;
|
|
import cn.efunbox.manage.common.utils.SnowflakeIdUtil;
|
|
|
|
+import com.sun.xml.internal.rngom.parse.host.Base;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -25,7 +26,11 @@ public class DepartmentServiceImpl implements DepartmentService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ApiResult getDeptTree(Long deptId) {
|
|
public ApiResult getDeptTree(Long deptId) {
|
|
- return ApiResult.ok(recursiveTree(deptId));
|
|
|
|
|
|
+ return ApiResult.ok(recursiveTree(deptId,new ArrayList<BaseStatusEnum>(){{
|
|
|
|
+ add(BaseStatusEnum.NORMAL);
|
|
|
|
+ add(BaseStatusEnum.DEL);
|
|
|
|
+ add(BaseStatusEnum.DISABLE);
|
|
|
|
+ }}));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -65,7 +70,11 @@ public class DepartmentServiceImpl implements DepartmentService {
|
|
@Override
|
|
@Override
|
|
public ApiResult getDeptChild(Long deptId) {
|
|
public ApiResult getDeptChild(Long deptId) {
|
|
List<Department> departments = new ArrayList<>();
|
|
List<Department> departments = new ArrayList<>();
|
|
- departments = deptChild(deptId,departments);
|
|
|
|
|
|
+ departments = deptChild(deptId,departments,new ArrayList<BaseStatusEnum>(){{
|
|
|
|
+ add(BaseStatusEnum.NORMAL);
|
|
|
|
+ add(BaseStatusEnum.DEL);
|
|
|
|
+ add(BaseStatusEnum.DISABLE);
|
|
|
|
+ }});
|
|
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());
|
|
@@ -101,24 +110,24 @@ public class DepartmentServiceImpl implements DepartmentService {
|
|
return ApiResult.ok(departmentRepository.findSelect());
|
|
return ApiResult.ok(departmentRepository.findSelect());
|
|
}
|
|
}
|
|
|
|
|
|
- private DeptTreeVO recursiveTree(Long cid) {
|
|
|
|
|
|
+ private DeptTreeVO recursiveTree(Long cid, List<BaseStatusEnum> status) {
|
|
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.findByPathOrderBySortAsc(cid);
|
|
|
|
|
|
+ List<Department> childTreeNodes = departmentRepository.findByPathAndStatusInOrderBySortAsc(cid, status);
|
|
for(Department child : childTreeNodes){
|
|
for(Department child : childTreeNodes){
|
|
- DeptTreeVO n = recursiveTree(child.getId()); //递归
|
|
|
|
|
|
+ DeptTreeVO n = recursiveTree(child.getId(), status); //递归
|
|
node.getChildren().add(n);
|
|
node.getChildren().add(n);
|
|
}
|
|
}
|
|
return node;
|
|
return node;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<Department> deptChild(Long cid, List<Department> departments) {
|
|
|
|
- List<Department> childTreeNodes = departmentRepository.findByPathOrderBySortAsc(cid);
|
|
|
|
|
|
+ private List<Department> deptChild(Long cid, List<Department> departments, List<BaseStatusEnum> status) {
|
|
|
|
+ List<Department> childTreeNodes = departmentRepository.findByPathAndStatusInOrderBySortAsc(cid, status);
|
|
departments.addAll(childTreeNodes);
|
|
departments.addAll(childTreeNodes);
|
|
for(Department child : childTreeNodes){
|
|
for(Department child : childTreeNodes){
|
|
- deptChild(child.getId(), departments); //递归
|
|
|
|
|
|
+ deptChild(child.getId(), departments, status); //递归
|
|
}
|
|
}
|
|
return departments;
|
|
return departments;
|
|
}
|
|
}
|