Search in sources :

Example 1 with BindAuthVo

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

the class UacRoleServiceImpl method getMenuTreeByRoleId.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public BindAuthVo getMenuTreeByRoleId(Long roleId) {
    BindAuthVo bindAuthVo = new BindAuthVo();
    Preconditions.checkArgument(roleId != null, ErrorCodeEnum.UAC10012001.msg());
    UacRole roleById = this.getRoleById(roleId);
    if (roleById == null) {
        logger.error("找不到角色信息 roleId={}", roleId);
        throw new UacBizException(ErrorCodeEnum.UAC10012005, roleId);
    }
    // 查询所有的菜单信息
    List<UacMenu> uacMenus = uacMenuService.selectAll();
    // 合并菜单和按钮权限 递归生成树结构
    List<MenuVo> menuVoList = this.getAuthList(uacMenus, null);
    List<MenuVo> tree = TreeUtil.getChildMenuVos(menuVoList, 0L);
    // 获取所有绑定的菜单和按钮权限Id集合
    List<Long> checkedAuthList = uacActionService.getCheckedMenuList(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 2 with BindAuthVo

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

the class UacRoleCommonController method getActionTreeByRoleId.

/**
 * 获取权限树
 *
 * @param roleId the role id
 *
 * @return the auth tree by role id
 */
@PostMapping(value = "/getActionTreeByRoleId/{roleId}")
@ApiOperation(httpMethod = "POST", value = "获取权限树")
public Wrapper<BindAuthVo> getActionTreeByRoleId(@ApiParam(name = "roleId", value = "角色id") @PathVariable Long roleId) {
    logger.info("roleId={}", roleId);
    BindAuthVo bindAuthVo = uacRoleService.getActionTreeByRoleId(roleId);
    return WrapMapper.ok(bindAuthVo);
}
Also used : BindAuthVo(com.paascloud.provider.model.vo.BindAuthVo) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with BindAuthVo

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

the class UacRoleCommonController method getMenuTreeByRoleId.

/**
 * 获取菜单树.
 *
 * @param roleId the role id
 *
 * @return the menu tree by role id
 */
@PostMapping(value = "/getMenuTreeByRoleId/{roleId}")
@ApiOperation(httpMethod = "POST", value = "获取菜单树")
public Wrapper<BindAuthVo> getMenuTreeByRoleId(@ApiParam(name = "roleId", value = "角色id") @PathVariable Long roleId) {
    logger.info("roleId={}", roleId);
    BindAuthVo bindAuthVo = uacRoleService.getMenuTreeByRoleId(roleId);
    return WrapMapper.ok(bindAuthVo);
}
Also used : BindAuthVo(com.paascloud.provider.model.vo.BindAuthVo) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with BindAuthVo

use of com.paascloud.provider.model.vo.BindAuthVo 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)

Aggregations

BindAuthVo (com.paascloud.provider.model.vo.BindAuthVo)4 UacBizException (com.paascloud.provider.model.exceptions.UacBizException)2 MenuVo (com.paascloud.provider.model.vo.MenuVo)2 ApiOperation (io.swagger.annotations.ApiOperation)2 Transactional (org.springframework.transaction.annotation.Transactional)2