部门结构树递归方式改为循环方式,提升性能

This commit is contained in:
zsz
2022-02-23 17:41:54 +08:00
parent c8c57b545a
commit 0f2f0372e6
6 changed files with 50 additions and 26 deletions

View File

@ -125,6 +125,11 @@
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -3,6 +3,8 @@ package com.ruoyi.common.core.domain;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.lang.tree.Tree;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysMenu;
@ -44,6 +46,16 @@ public class TreeSelect implements Serializable
this.label = menu.getMenuName();
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public TreeSelect(Tree<Long> dept) {
this.id = dept.getId();
this.label = dept.getName().toString();
List<Tree<Long>> children = dept.getChildren();
if (children != null && !children.isEmpty()) {
this.children = children.stream().map(TreeSelect::new).collect(Collectors.toList());
}
}
public Long getId()
{