Search in sources :

Example 1 with UserBindRoleVo

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

the class UacUserMainController method getBindRole.

/**
 * 获取用户绑定角色页面数据.
 *
 * @param userId the user id
 *
 * @return the bind role
 */
@PostMapping(value = "/getBindRole/{userId}")
@ApiOperation(httpMethod = "POST", value = "获取用户绑定角色页面数据")
public Wrapper<UserBindRoleVo> getBindRole(@ApiParam(name = "userId", value = "角色id") @PathVariable Long userId) {
    logger.info("获取用户绑定角色页面数据. userId={}", userId);
    LoginAuthDto loginAuthDto = super.getLoginAuthDto();
    Long currentUserId = loginAuthDto.getUserId();
    if (Objects.equals(userId, currentUserId)) {
        throw new UacBizException(ErrorCodeEnum.UAC10011023);
    }
    UserBindRoleVo bindUserDto = uacUserService.getUserBindRoleDto(userId);
    return WrapMapper.ok(bindUserDto);
}
Also used : UacBizException(com.paascloud.provider.model.exceptions.UacBizException) LoginAuthDto(com.paascloud.base.dto.LoginAuthDto) UserBindRoleVo(com.paascloud.provider.model.vo.UserBindRoleVo) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with UserBindRoleVo

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

the class UacUserServiceImpl method getUserBindRoleDto.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public UserBindRoleVo getUserBindRoleDto(Long userId) {
    UserBindRoleVo userBindRoleVo = new UserBindRoleVo();
    Set<Long> alreadyBindRoleIdSet = Sets.newHashSet();
    UacUser uacUser = this.queryByUserId(userId);
    if (uacUser == null) {
        logger.error("找不到userId={}, 的用户", userId);
        throw new UacBizException(ErrorCodeEnum.UAC10011003, userId);
    }
    // 查询所有角色包括该用户拥有的角色
    List<BindRoleDto> bindRoleDtoList = uacUserMapper.selectAllNeedBindRole(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);
    // 该角色已经绑定的用户
    List<UacRoleUser> setAlreadyBindRoleSet = uacRoleUserService.listByUserId(userId);
    Set<BindRoleDto> allUserSet = new HashSet<>(bindRoleDtoList);
    for (UacRoleUser uacRoleUser : setAlreadyBindRoleSet) {
        alreadyBindRoleIdSet.add(uacRoleUser.getRoleId());
    }
    userBindRoleVo.setAllRoleSet(allUserSet);
    userBindRoleVo.setAlreadyBindRoleIdSet(alreadyBindRoleIdSet);
    return userBindRoleVo;
}
Also used : UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UserBindRoleVo(com.paascloud.provider.model.vo.UserBindRoleVo) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

UacBizException (com.paascloud.provider.model.exceptions.UacBizException)2 UserBindRoleVo (com.paascloud.provider.model.vo.UserBindRoleVo)2 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Transactional (org.springframework.transaction.annotation.Transactional)1