zoukankan      html  css  js  c++  java
  • 递归获取菜单栏

    @Override
    public BaseResponse<?> listChildSort(){
    //查找所有最上级菜单
    List<SysPermission> sysPermissionList = sysPermissionMapper.selectByParentId(0);
    List<Children> childrenList = Lists.newArrayList();
    for(SysPermission sysPermission : sysPermissionList){
    //添加该菜单下及其下级菜单的递归集合
    childrenList.add(listChild(sysPermission));
    }
    if(childrenList.size() == 0 ){
    return BaseResponse.createByError("没有数据了");
    }
    return BaseResponse.createBySuccess(childrenList);
    }
    private Children listChild(SysPermission sysPermission){
    //新建递归对象
    Children children = new Children();
    //把当前菜单Id和Name存进该对象
    children.setId(sysPermission.getId()+"");
    children.setName(sysPermission.getName());
    //查找上级菜单为当前菜单ID的菜单
    List<SysPermission> sysPermissionList = sysPermissionMapper.selectByParentId(sysPermission.getId().intValue());
    List<Children> childrenList = Lists.newArrayList();
    //遍历下级菜单
    for(SysPermission sysPermissionChild : sysPermissionList){
    //递归下级菜单,并存入下级菜单集合
    childrenList.add(listChild(sysPermissionChild));
    }
    //将下级菜单集合存进递归对象
    children.setChildren(childrenList.size() > 0 ? childrenList : null);
    return children;
    }
  • 相关阅读:
    标定相关-一些资源
    论文基础-5几何知识
    论文基础-3微积分
    h5页面 判断网页是否由微信或qq内置浏览器打开
    Html5 页面后退并刷新
    h5 页面下拉刷新
    绑定点击事件 传参
    公众号做分享功能
    清微信缓存
    手机端适配
  • 原文地址:https://www.cnblogs.com/ONFE/p/12209152.html
Copyright © 2011-2022 走看看