|
|
@@ -2,6 +2,7 @@ package thyyxxk.webserver.utils;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
+import thyyxxk.webserver.entity.login.VueMenu;
|
|
|
import thyyxxk.webserver.entity.settings.permissions.MenuItem;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
@@ -42,4 +43,31 @@ public class TreeUtil {
|
|
|
}
|
|
|
return ResultVoUtil.success(resultList);
|
|
|
}
|
|
|
+
|
|
|
+ public static ResultVo<List<VueMenu>> getVueMenuTree(List<VueMenu> tempList) {
|
|
|
+ List<VueMenu> resultList = new ArrayList<>();
|
|
|
+ Map<Integer, VueMenu> treeMap = new HashMap<>(tempList.size());
|
|
|
+ for (VueMenu item : tempList) {
|
|
|
+ JSONObject meta = new JSONObject();
|
|
|
+ if (StringUtil.notBlank(item.getMetaIcon())) {
|
|
|
+ meta.put("icon", item.getMetaIcon());
|
|
|
+ }
|
|
|
+ meta.put("title", item.getMetaTitle());
|
|
|
+ item.setMeta(meta);
|
|
|
+ treeMap.put(item.getId(), item);
|
|
|
+ if (0 == item.getParent()) {
|
|
|
+ resultList.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (VueMenu item : tempList) {
|
|
|
+ VueMenu template = treeMap.get(item.getParent());
|
|
|
+ if (null != template) {
|
|
|
+ if (null == template.getChildren()) {
|
|
|
+ template.setChildren(new ArrayList<>());
|
|
|
+ }
|
|
|
+ template.getChildren().add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(resultList);
|
|
|
+ }
|
|
|
}
|