提交 | 用户 | 时间
|
1ac2bc
|
1 |
package cn.stylefeng.guns.sys.modular.rest.factory; |
懒 |
2 |
|
|
3 |
import cn.hutool.core.bean.BeanUtil; |
|
4 |
import cn.stylefeng.guns.sys.modular.rest.model.MenuTreeNode; |
|
5 |
import cn.stylefeng.roses.core.treebuild.DefaultTreeBuildFactory; |
|
6 |
|
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.List; |
|
9 |
import java.util.Map; |
|
10 |
|
|
11 |
/** |
|
12 |
* 菜单树构建 |
|
13 |
* |
|
14 |
* @author fengshuonan |
|
15 |
* @date 2019-07-26-17:38 |
|
16 |
*/ |
|
17 |
public class MenuFactory { |
|
18 |
|
|
19 |
/** |
|
20 |
* 构造菜单树,菜单列表用 |
|
21 |
* |
|
22 |
* @author fengshuonan |
|
23 |
* @Date 2019-07-26 17:41 |
|
24 |
*/ |
|
25 |
public static List<MenuTreeNode> buildTreeNodes(List<Map<String, Object>> originMap) { |
|
26 |
|
|
27 |
ArrayList<MenuTreeNode> menuTreeNodes = new ArrayList<>(); |
|
28 |
|
|
29 |
for (Map<String, Object> map : originMap) { |
|
30 |
MenuTreeNode menuTreeNode = BeanUtil.mapToBean(map, MenuTreeNode.class, true); |
|
31 |
menuTreeNodes.add(menuTreeNode); |
|
32 |
} |
|
33 |
|
|
34 |
DefaultTreeBuildFactory<MenuTreeNode> treeBuildFactory = new DefaultTreeBuildFactory<>(); |
|
35 |
|
|
36 |
treeBuildFactory.setRootParentId("0"); |
|
37 |
|
|
38 |
return treeBuildFactory.doTreeBuild(menuTreeNodes); |
|
39 |
} |
|
40 |
|
|
41 |
} |