public Menu getUserMenuTree(Long userId, String rootCode) {
// 1. 获取跟用户相关的所有挂钩菜单的部分,按照LFT升序
List<Menu> menus = this.menuDao.findUserMenu(userId, rootCode);
if (CollectionUtils.isEmpty(menus)) return null;
Stack<Menu> rightStack = new Stack<Menu>();
for (Menu menu : menus) {
if (null == menu.getLft() || null == menu.getRgt()) continue;
while (!rightStack.isEmpty() && rightStack.lastElement().getRgt() < menu.getRgt()) {
rightStack.pop();
}
if (!rightStack.isEmpty()) {
rightStack.lastElement().addChild(menu);
}
rightStack.push(menu);
}
return rightStack.firstElement();
}