Search in sources :

Example 1 with AuthMenu

use of com.github.liuweijw.core.beans.system.AuthMenu in project fw-cloud-framework by liuweijw.

the class ApiController method findMenuByRole.

/**
 * 通过用户名查询用户菜单
 */
@GetMapping("/findMenuByRole/{roleCode}")
public Set<AuthPermission> findMenuByRole(@PathVariable String roleCode) {
    Set<AuthPermission> permissions = new HashSet<AuthPermission>();
    Set<AuthMenu> menus = menuService.findMenuByRole(roleCode);
    if (null == menus || menus.size() == 0)
        return permissions;
    menus.stream().forEach(r -> {
        permissions.add(new AuthPermission(r.getUrl()));
    });
    return permissions;
}
Also used : AuthMenu(com.github.liuweijw.core.beans.system.AuthMenu) AuthPermission(com.github.liuweijw.core.beans.system.AuthPermission) HashSet(java.util.HashSet) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with AuthMenu

use of com.github.liuweijw.core.beans.system.AuthMenu 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 AuthMenu

use of com.github.liuweijw.core.beans.system.AuthMenu in project fw-cloud-framework by liuweijw.

the class MenuServiceImpl method findMenuByRole.

@Override
public Set<AuthMenu> findMenuByRole(String roleCode) {
    if (StringHelper.isBlank(roleCode))
        return null;
    Role role = roleService.findRoleByCode(roleCode.trim());
    if (null == role)
        return null;
    List<Menu> rList = this.findMenuByRoleId(role.getRoleId());
    if (null == rList || rList.size() == 0)
        return null;
    Set<AuthMenu> mList = new HashSet<AuthMenu>();
    for (Menu m : rList) {
        AuthMenu authMenu = new AuthMenu();
        BeanUtils.copyProperties(m, authMenu);
        mList.add(authMenu);
    }
    return mList;
}
Also used : Role(com.github.liuweijw.business.admin.domain.Role) AuthMenu(com.github.liuweijw.core.beans.system.AuthMenu) 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) HashSet(java.util.HashSet)

Example 4 with AuthMenu

use of com.github.liuweijw.core.beans.system.AuthMenu in project fw-cloud-framework by liuweijw.

the class PermissionFeignApiClient method findMenuByRole.

@Override
@ApiOperation(httpMethod = GET, value = "通过角色获取菜单权限")
@ApiImplicitParam(name = "roleCode", value = "用户roleCode", required = true, dataType = "string", paramType = "path")
public Set<AuthPermission> findMenuByRole(@PathVariable("roleCode") String roleCode) {
    Set<AuthPermission> permissions = new HashSet<AuthPermission>();
    if (StringHelper.isBlank(roleCode))
        return permissions;
    Set<AuthMenu> menus = menuService.findMenuByRole(roleCode);
    if (null == menus || menus.size() == 0)
        return permissions;
    menus.stream().forEach(r -> {
        permissions.add(new AuthPermission(r.getUrl()));
    });
    return permissions;
}
Also used : AuthMenu(com.github.liuweijw.core.beans.system.AuthMenu) AuthPermission(com.github.liuweijw.system.api.model.AuthPermission) HashSet(java.util.HashSet) ApiOperation(io.swagger.annotations.ApiOperation) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam)

Example 5 with AuthMenu

use of com.github.liuweijw.core.beans.system.AuthMenu 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

AuthMenu (com.github.liuweijw.core.beans.system.AuthMenu)5 HashSet (java.util.HashSet)3 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 MenuTree (com.github.liuweijw.business.commons.tree.MenuTree)2 ArrayList (java.util.ArrayList)2 Role (com.github.liuweijw.business.admin.domain.Role)1 AuthPermission (com.github.liuweijw.core.beans.system.AuthPermission)1 AuthPermission (com.github.liuweijw.system.api.model.AuthPermission)1 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)1 ApiOperation (io.swagger.annotations.ApiOperation)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1