解决方案 »
- 请问FMS直播录制的功能是如何实现的?
- 各位大侠,真的是没有办法了,还是发个帖子来求救吧!!servlet问题,具体描述如下:
- 【跪求代码】类似博客的发帖功能,能够让用户输入文字和图片的,有没有推荐的开源代码啊?
- struts应用javamail中文乱码问题
- JSP网页显示空白,而HTML网页显示正常
- hibernate中文参考手册也太烂了,看不明白
- 为何在bean中连接数据库后不能用first(),last()
- 求一个完整的JAVA代码,功能是一台电脑上的JSP程序,想使用另一个电脑上的JAVA类
- weblogic部署问题
- jsp代码为何不被编译?
- ie6和ie8浏览器是不是不支持jsp对cookie的操作?
- 项目部署不到tomcat上面
id code pid
1 001 0
2 002 0
3 001001 1
4 001002 1
5 002001 2
6 002001001 5比如查id为6的根菜单 只要取code=前3位就行
//获取表中所有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);
大概就是这么个意思了,我也胡乱贴上去的,希望对你有帮助
循环遍历取父ID,拼成string 或者 json
再或者只有更改表结构,
如A id:01
B id:0101
C id:010101