package app.util;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.fastjson.JSON;public classMenu {privateInteger pid;privateString menuName;privateInteger parentId;privateInteger position;private List
}public voidsetPid(Integer pid) {this.pid =pid;
}publicString getMenuName() {returnmenuName;
}public voidsetMenuName(String menuName) {this.menuName =menuName;
}publicInteger getParentId() {returnparentId;
}public voidsetParentId(Integer parentId) {this.parentId =parentId;
}publicInteger getPosition() {returnposition;
}public voidsetPosition(Integer position) {this.position =position;
}public List
}public void setChildMenu(List
}publicMenu(Integer parentId,String menuName, Integer pid, Integer position) {
super();this.parentId =parentId;this.menuName =menuName;this.pid =pid;this.position =position;
}publicMenu() {
super();
}public static voidmain(String[] args) {
List
Menu menu1=new Menu(1, "父级1", 0, 1);
Menu menu2=new Menu(2, "父级2", 0, 2);
Menu menu1_1=new Menu(3, "子级1_1", 1, 1);
Menu menu1_2=new Menu(4, "子级1_2", 1, 2);
Menu menu1_2_1=new Menu(5, "子级1_2_1", 4, 2);
Menu menu1_2_2=new Menu(6, "子级1_2_2", 2, 2);
list.add(menu1);
list.add(menu2);
list.add(menu1_1);
list.add(menu1_2);
list.add(menu1_2_1);
list.add(menu1_2_2);
List
String trssJson=JSON.toJSONString(listTree);
System.out.println(trssJson);
}public static List
List
List
menu.setChildMenu(menuLists);
menus.add(menu);
}
}returnmenus;
}
}