dept
This commit is contained in:
@@ -41,5 +41,4 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
* @return
|
||||
*/
|
||||
String findAllChild(String pid);
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -94,11 +97,13 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
if (query.getPid() == null){
|
||||
query.setPidIsNull(true);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIsUsed()!=null){
|
||||
query.setPidIsNull(null);
|
||||
}
|
||||
}
|
||||
Page page = this.page(pageQuery.build(SysDept.class), query.build());
|
||||
|
||||
page.setRecords(CopyUtil.copyList(page.getRecords(), DeptVo.class));
|
||||
if (StringUtils.isNotEmpty(query.getName())){
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIsUsed()!=null){
|
||||
page.getRecords().forEach(a->((DeptVo)a).setHasChildren(false) );
|
||||
}
|
||||
return page;
|
||||
@@ -140,7 +145,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
}
|
||||
verification(deptIds);
|
||||
Set<String> depts = new HashSet<>();
|
||||
Set<String> pids = new HashSet<>();
|
||||
List<SysDept> deptList = sysDeptMapper.selectList(new QueryWrapper<SysDept>().in("dept_id", deptIds));
|
||||
for (String deptId : deptIds) {
|
||||
depts.add(deptId);
|
||||
String allChild = sysDeptMapper.findAllChild(deptId);
|
||||
if (StringUtils.isNotEmpty(allChild)){
|
||||
String[] split = allChild.split(",");
|
||||
@@ -148,9 +156,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
}
|
||||
}
|
||||
this.remove(new QueryWrapper<SysDept>().in("dept_id", depts));
|
||||
for (String deptId : deptIds) {
|
||||
sysDeptMapper.updateSubCount(deptId);
|
||||
}
|
||||
deptList.forEach(dept -> {
|
||||
if (StringUtils.isNotEmpty(dept.getPid())){sysDeptMapper.updateSubCount(dept.getPid());}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void verification(Set<String> depeIds) {
|
||||
|
||||
Reference in New Issue
Block a user