日期:2014-05-17 浏览次数:20789 次
//获取表中所有id
protected List<Long> getIdList(String sql, Object ... params) {
return xxx;
}
//获取该menu下的所有子节点
private List<Long> getMenuChildrenIds(long menuId) {
String sql = "select menu_id from test_tb where p_id = ? ";
return getIdList(sql, menuId);
}
public void getAllChildren(long menuId, List<Long> menuIdList) {
List<Long> childrenIds = getMenuChildrenIds(menuId);
for (long menu_Id : childrenIds) {
menuIdList.add(menu_Id);
//计数
int count = geliDao.count("select count(1) from test_tb where p_id = ? ", menu_Id, status);
if (count > 0) {
getAllChildren(menu_Id, menuIdList);
}
}
}
//
public List<Menu> getMenuChildren(long menuId) {
return orm.list(Menu.class, getMenuChildrenIds(menuId ).toArray());
}
//执行,全找出来menuIds,放到list里面
List<Long> menuIds = new ArrayList<Long>();
menuIds.add(menu.getMenuId());
getAllChildren(menu.getMenuId(), menuIds);