示例#1
0
 @JsonIgnore
 public static void sortList(
     List<Menu> list, List<Menu> sourcelist, String parentId, boolean cascade) {
   for (int i = 0; i < sourcelist.size(); i++) {
     Menu e = sourcelist.get(i);
     if (e.getParent() != null
         && e.getParent().getId() != null
         && e.getParent().getId().equals(parentId)) {
       list.add(e);
       if (cascade) {
         // 判断是否还有子节点, 有则继续获取子节点
         for (int j = 0; j < sourcelist.size(); j++) {
           Menu child = sourcelist.get(j);
           if (child.getParent() != null
               && child.getParent().getId() != null
               && child.getParent().getId().equals(e.getId())) {
             sortList(list, sourcelist, e.getId(), true);
             break;
           }
         }
       }
     }
   }
 }
示例#2
0
 public String getParentId() {
   return parent != null && parent.getId() != null ? parent.getId() : "0";
 }