优化组织人员树
This commit is contained in:
parent
ca002de02b
commit
5fcd300883
|
|
@ -3,6 +3,7 @@ package com.bonus.system.service.impl;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
|
|
@ -86,9 +87,23 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
public List<TreeSelect> selectDeptUserTree(SysUser sysUser)
|
||||
{
|
||||
List<SysDept> depts = deptMapper.selectDeptUserList(sysUser.getRoleIds());
|
||||
for (int i = 0; i < 5; i++) {
|
||||
depts = getFilterDepts(depts);
|
||||
}
|
||||
return buildDeptTreeSelect(depts);
|
||||
}
|
||||
|
||||
private static List<SysDept> getFilterDepts(List<SysDept> depts) {
|
||||
List<SysDept> newDepts = new ArrayList<>();
|
||||
Set<Long> pids = depts.stream().map(SysDept::getParentId).collect(Collectors.toSet());
|
||||
for (SysDept sysDept : depts) {
|
||||
if (sysDept.getLevel().equals(99) || pids.contains(sysDept.getDeptId())) {
|
||||
newDepts.add(sysDept);
|
||||
}
|
||||
}
|
||||
return newDepts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue