|
@@ -1,8 +1,6 @@
|
|
|
package com.boman.system.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
@@ -42,9 +40,39 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|
|
*/
|
|
|
@Override
|
|
|
@DataScope(deptAlias = "d")
|
|
|
- public List<SysDept> selectDeptList(SysDept dept)
|
|
|
- {
|
|
|
- return deptMapper.selectDeptList(dept);
|
|
|
+ public List<SysDept> selectDeptList(SysDept dept) {
|
|
|
+ Long id = dept.getId();
|
|
|
+ if(id == null) {
|
|
|
+ if(StringUtils.isNotEmpty(dept.getDeptName()) || StringUtils.isNotEmpty(dept.getStatus())) {
|
|
|
+ dept.setListByParentId(Boolean.TRUE);
|
|
|
+ return deptMapper.selectDeptList(dept);
|
|
|
+ }
|
|
|
+ dept.setListByParentId(Boolean.FALSE);
|
|
|
+ }else{
|
|
|
+ dept.setListByParentId(Boolean.TRUE);
|
|
|
+ dept.setParentId(id);
|
|
|
+ }
|
|
|
+ List<SysDept> depts = deptMapper.selectDeptList(dept);
|
|
|
+ // 这里的逻辑是:根据id获取到这个下面的所有子部门,每个部门判断是否有下一级别
|
|
|
+ if(depts != null && depts.size() > 0) {
|
|
|
+ List<SysDept> hasChirlds = deptMapper.validateHasChirld(depts);
|
|
|
+ if(hasChirlds != null && hasChirlds.size() > 0) {
|
|
|
+ Map<Long, SysDept> hasChirldMap = new HashMap<>();
|
|
|
+ for (SysDept hasChirld : hasChirlds) {
|
|
|
+ hasChirldMap.put(hasChirld.getId(), hasChirld);
|
|
|
+ }
|
|
|
+ for (SysDept sysDept : depts) {
|
|
|
+ if(hasChirldMap.get(sysDept.getId()) == null) {
|
|
|
+ sysDept.setHasChildren(Boolean.FALSE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ for (SysDept sysDept : depts) {
|
|
|
+ sysDept.setHasChildren(Boolean.FALSE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return depts;
|
|
|
}
|
|
|
|
|
|
/**
|