添加一个默认空属性,用来判断节点显示

This commit is contained in:
RuoYi
2019-12-26 15:59:03 +08:00
parent 71c31dfd66
commit 3755597c76
3 changed files with 11 additions and 7 deletions

View File

@ -49,11 +49,15 @@ public class SysDeptServiceImpl implements ISysDeptService
public List<SysDept> buildDeptTree(List<SysDept> depts)
{
List<SysDept> returnList = new ArrayList<SysDept>();
if (StringUtils.isNotEmpty(depts) && StringUtils.isNotNull(depts.stream().findFirst()))
{
depts.stream().findFirst().get().setParentId(null);
}
for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();)
{
SysDept t = (SysDept) iterator.next();
// 根据传入的某个父节点ID,遍历该父节点的所有子节点
if (t.getParentId() == 0)
if (StringUtils.isNull(t.getParentId()) || t.getParentId() == 0)
{
recursionFn(depts, t);
returnList.add(t);
@ -271,7 +275,7 @@ public class SysDeptServiceImpl implements ISysDeptService
while (it.hasNext())
{
SysDept n = (SysDept) it.next();
if (n.getParentId().longValue() == t.getDeptId().longValue())
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
{
tlist.add(n);
}