Search in sources :

Example 1 with MenuTree

use of com.github.liuweijw.business.commons.tree.MenuTree in project fw-cloud-framework by liuweijw.

the class MenuServiceImpl method findAllMenuTree.

// 目前只支持二级菜单,若有三级,则改递归即可
@Override
public List<MenuTree> findAllMenuTree() {
    List<Menu> rList = this.findMenuList();
    List<Module> moduleList = this.moduleService.getAllList();
    List<MenuTree> menuTreeList = new ArrayList<MenuTree>();
    rList.forEach(menu -> {
        if (menu.getPid() != 0 && null != moduleList && moduleList.size() > 0) {
            moduleList.forEach(m -> {
                String id = menu.getPath() + "_" + m.getCode();
                menuTreeList.add(new MenuTree(id, menu.getMenuId() + "", m.getName()));
            });
        }
        menuTreeList.add(new MenuTree(menu.getMenuId() + "", menu.getPid() + "", menu.getMenuName()));
    });
    return TreeUtil.build(menuTreeList, "0");
}
Also used : MenuTree(com.github.liuweijw.business.commons.tree.MenuTree) ArrayList(java.util.ArrayList) AuthMenu(com.github.liuweijw.core.beans.system.AuthMenu) QMenu(com.github.liuweijw.business.admin.domain.QMenu) QRoleMenu(com.github.liuweijw.business.admin.domain.QRoleMenu) Menu(com.github.liuweijw.business.admin.domain.Menu) Module(com.github.liuweijw.business.admin.domain.Module)

Example 2 with MenuTree

use of com.github.liuweijw.business.commons.tree.MenuTree in project fw-cloud-framework by liuweijw.

the class MenuServiceImpl method findRoleMenuTree.

@Override
public List<MenuTree> findRoleMenuTree(String roleCode) {
    Set<AuthMenu> menuList = findMenuByRole(roleCode);
    List<MenuTree> menuTreeList = new ArrayList<MenuTree>();
    menuList.forEach(menu -> {
        menuTreeList.add(new MenuTree(menu));
    });
    return TreeUtil.build(menuTreeList, 0);
}
Also used : MenuTree(com.github.liuweijw.business.commons.tree.MenuTree) AuthMenu(com.github.liuweijw.core.beans.system.AuthMenu) ArrayList(java.util.ArrayList)

Example 3 with MenuTree

use of com.github.liuweijw.business.commons.tree.MenuTree in project fw-cloud-framework by liuweijw.

the class MenuController method menuTreeList.

// 获取所有菜单列表 以及功能权限
@GetMapping(value = "/menuTreeList/{roleCode}")
@PrePermissions(value = Functional.VIEW)
public R<MenuTreeBean> menuTreeList(@PathVariable("roleCode") String roleCode) {
    MenuTreeBean menuTreeBean = new MenuTreeBean();
    List<MenuTree> menuTree = menuService.findAllMenuTree();
    menuTreeBean.setMenuList(menuTree);
    Set<String> permissions = new HashSet<String>();
    permissions.addAll(permissionService.findMenuPermissions(roleCode));
    menuTreeBean.setPermissions(permissions.toArray(new String[permissions.size()]));
    return new R<MenuTreeBean>().data(menuTreeBean);
}
Also used : MenuTree(com.github.liuweijw.business.commons.tree.MenuTree) MenuTreeBean(com.github.liuweijw.business.admin.beans.MenuTreeBean) HashSet(java.util.HashSet) GetMapping(org.springframework.web.bind.annotation.GetMapping) PrePermissions(com.github.liuweijw.business.commons.web.aop.PrePermissions)

Example 4 with MenuTree

use of com.github.liuweijw.business.commons.tree.MenuTree in project fw-cloud-framework by liuweijw.

the class MenuController method menuTreeList.

// 获取所有菜单列表
@GetMapping(value = "/menuTreeAllList")
@PrePermissions(value = Functional.VIEW)
public R<MenuTreeBean> menuTreeList() {
    MenuTreeBean menuTreeBean = new MenuTreeBean();
    List<MenuTree> menuTree = menuService.findAllMenuTreeList();
    menuTreeBean.setMenuList(menuTree);
    return new R<MenuTreeBean>().data(menuTreeBean);
}
Also used : MenuTree(com.github.liuweijw.business.commons.tree.MenuTree) MenuTreeBean(com.github.liuweijw.business.admin.beans.MenuTreeBean) GetMapping(org.springframework.web.bind.annotation.GetMapping) PrePermissions(com.github.liuweijw.business.commons.web.aop.PrePermissions)

Example 5 with MenuTree

use of com.github.liuweijw.business.commons.tree.MenuTree in project fw-cloud-framework by liuweijw.

the class MenuServiceImpl method findAllMenuTreeList.

@Override
public List<MenuTree> findAllMenuTreeList() {
    List<Menu> rList = this.findMenuList();
    List<MenuTree> menuTreeList = new ArrayList<MenuTree>();
    rList.forEach(menu -> {
        AuthMenu authMenu = new AuthMenu();
        BeanUtils.copyProperties(menu, authMenu);
        menuTreeList.add(new MenuTree(authMenu));
    });
    return TreeUtil.build(menuTreeList, "0");
}
Also used : MenuTree(com.github.liuweijw.business.commons.tree.MenuTree) AuthMenu(com.github.liuweijw.core.beans.system.AuthMenu) ArrayList(java.util.ArrayList) AuthMenu(com.github.liuweijw.core.beans.system.AuthMenu) QMenu(com.github.liuweijw.business.admin.domain.QMenu) QRoleMenu(com.github.liuweijw.business.admin.domain.QRoleMenu) Menu(com.github.liuweijw.business.admin.domain.Menu)

Aggregations

MenuTree (com.github.liuweijw.business.commons.tree.MenuTree)5 AuthMenu (com.github.liuweijw.core.beans.system.AuthMenu)3 ArrayList (java.util.ArrayList)3 MenuTreeBean (com.github.liuweijw.business.admin.beans.MenuTreeBean)2 Menu (com.github.liuweijw.business.admin.domain.Menu)2 QMenu (com.github.liuweijw.business.admin.domain.QMenu)2 QRoleMenu (com.github.liuweijw.business.admin.domain.QRoleMenu)2 PrePermissions (com.github.liuweijw.business.commons.web.aop.PrePermissions)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 Module (com.github.liuweijw.business.admin.domain.Module)1 HashSet (java.util.HashSet)1