Search in sources :

Example 11 with MenuVo

use of com.paascloud.provider.model.vo.MenuVo in project paascloud-master by paascloud.

the class UacRoleServiceImpl method getActionTreeByRoleId.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public BindAuthVo getActionTreeByRoleId(Long roleId) {
    BindAuthVo bindAuthVo = new BindAuthVo();
    if (roleId == null) {
        throw new UacBizException(ErrorCodeEnum.UAC10012001);
    }
    UacRole roleById = this.getRoleById(roleId);
    if (roleById == null) {
        logger.error("找不到角色信息 roleId={}", roleId);
        throw new UacBizException(ErrorCodeEnum.UAC10012005, roleId);
    }
    List<UacMenu> uacMenus = uacMenuService.listMenuListByRoleId(roleId);
    if (PublicUtil.isEmpty(uacMenus)) {
        throw new UacBizException(ErrorCodeEnum.UAC10013009);
    }
    // 查询所有的权限信息
    List<UacAction> uacActions = uacActionService.listActionList(uacMenus);
    // 合并菜单和按钮权限 递归生成树结构
    List<MenuVo> menuVoList = this.getAuthList(uacMenus, uacActions);
    List<MenuVo> tree = TreeUtil.getChildMenuVos(menuVoList, 0L);
    // 获取所有绑定的菜单和按钮权限Id集合
    List<Long> checkedAuthList = uacActionService.getCheckedActionList(roleId);
    bindAuthVo.setAuthTree(tree);
    bindAuthVo.setCheckedAuthList(checkedAuthList);
    return bindAuthVo;
}
Also used : MenuVo(com.paascloud.provider.model.vo.MenuVo) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) BindAuthVo(com.paascloud.provider.model.vo.BindAuthVo) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with MenuVo

use of com.paascloud.provider.model.vo.MenuVo in project paascloud-master by paascloud.

the class TreeUtil method getChildMenuVos.

/**
 * 根据父节点的ID获取所有子节点
 *
 * @param list     具有树形结构特点的集合
 * @param parentId 父节点ID
 *
 * @return 树形结构集合 child menu vos
 */
public static List<MenuVo> getChildMenuVos(List<MenuVo> list, Long parentId) {
    List<MenuVo> returnList = Lists.newArrayList();
    for (MenuVo menuVo : list) {
        if (menuVo.getPid() == null) {
            continue;
        }
        if (Objects.equals(menuVo.getPid(), parentId)) {
            recursionFn(list, menuVo);
            returnList.add(menuVo);
        }
    }
    return returnList;
}
Also used : MenuVo(com.paascloud.provider.model.vo.MenuVo)

Example 13 with MenuVo

use of com.paascloud.provider.model.vo.MenuVo in project paascloud-master by paascloud.

the class TreeUtil method recursionFn.

/**
 * 递归列表
 */
private static void recursionFn(List<MenuVo> list, MenuVo t) {
    // 得到子节点列表
    List<MenuVo> childList = getChildList(list, t);
    t.setSubMenu(childList);
    if (PublicUtil.isNotEmpty(childList)) {
        t.setHasMenu(true);
    }
    for (MenuVo tChild : childList) {
        // 判断是否有子节点
        if (hasChild(list, tChild)) {
            for (MenuVo n : childList) {
                recursionFn(list, n);
            }
            tChild.setHasMenu(true);
        }
    }
}
Also used : MenuVo(com.paascloud.provider.model.vo.MenuVo)

Aggregations

MenuVo (com.paascloud.provider.model.vo.MenuVo)13 Transactional (org.springframework.transaction.annotation.Transactional)5 UacBizException (com.paascloud.provider.model.exceptions.UacBizException)4 UacMenu (com.paascloud.provider.model.domain.UacMenu)3 ViewMenuVo (com.paascloud.provider.model.vo.ViewMenuVo)3 UacUser (com.paascloud.provider.model.domain.UacUser)2 BindAuthVo (com.paascloud.provider.model.vo.BindAuthVo)2 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)1 UacRole (com.paascloud.provider.model.domain.UacRole)1 UserMenuChildrenDto (com.paascloud.provider.model.dto.menu.UserMenuChildrenDto)1 UserMenuDto (com.paascloud.provider.model.dto.menu.UserMenuDto)1 LoginRespDto (com.paascloud.provider.model.dto.user.LoginRespDto)1 GroupZtreeVo (com.paascloud.provider.model.vo.GroupZtreeVo)1 UserVo (com.paascloud.provider.model.vo.UserVo)1 ApiOperation (io.swagger.annotations.ApiOperation)1