Search in sources :

Example 11 with UacBizException

use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.

the class UacRoleActionServiceImpl method listByRoleId.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<UacRoleAction> listByRoleId(Long roleId) {
    if (roleId == null) {
        throw new UacBizException(ErrorCodeEnum.UAC10012001);
    }
    UacRoleAction roleMenu = new UacRoleAction();
    roleMenu.setRoleId(roleId);
    return uacRoleActionMapper.select(roleMenu);
}
Also used : UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacRoleAction(com.paascloud.provider.model.domain.UacRoleAction) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with UacBizException

use of com.paascloud.provider.model.exceptions.UacBizException 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 13 with UacBizException

use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.

the class UacRoleMainController method modifyUacRoleStatusById.

/**
 * 修改角色状态.
 *
 * @param modifyStatusDto the modify status dto
 *
 * @return the wrapper
 */
@LogAnnotation
@PostMapping(value = "/modifyRoleStatusById")
@ApiOperation(httpMethod = "POST", value = "根据角色Id修改角色状态")
public Wrapper modifyUacRoleStatusById(@ApiParam(name = "modifyRoleStatusDto", value = "修改角色状态数据") @RequestBody ModifyStatusDto modifyStatusDto) {
    logger.info("根据角色Id修改角色状态 modifyStatusDto={}", modifyStatusDto);
    Long roleId = modifyStatusDto.getId();
    if (roleId == null) {
        throw new UacBizException(ErrorCodeEnum.UAC10012001);
    }
    LoginAuthDto loginAuthDto = getLoginAuthDto();
    Long userId = loginAuthDto.getUserId();
    UacRoleUser ru = uacRoleUserService.getByUserIdAndRoleId(userId, roleId);
    if (ru != null && UacRoleStatusEnum.DISABLE.getType().equals(modifyStatusDto.getStatus())) {
        throw new UacBizException(ErrorCodeEnum.UAC10012002);
    }
    UacRole uacRole = new UacRole();
    uacRole.setId(roleId);
    uacRole.setStatus(modifyStatusDto.getStatus());
    uacRole.setUpdateInfo(loginAuthDto);
    int result = uacRoleService.update(uacRole);
    return super.handleResult(result);
}
Also used : UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacRoleUser(com.paascloud.provider.model.domain.UacRoleUser) LoginAuthDto(com.paascloud.base.dto.LoginAuthDto) UacRole(com.paascloud.provider.model.domain.UacRole) LogAnnotation(com.paascloud.core.annotation.LogAnnotation) ApiOperation(io.swagger.annotations.ApiOperation)

Example 14 with UacBizException

use of com.paascloud.provider.model.exceptions.UacBizException 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 15 with UacBizException

use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.

the class UacRoleUserServiceImpl method saveRoleUser.

@Override
public int saveRoleUser(Long userId, Long roleId) {
    if (userId == null) {
        throw new UacBizException(ErrorCodeEnum.UAC10011001);
    }
    if (roleId == null) {
        throw new UacBizException(ErrorCodeEnum.UAC10012001);
    }
    UacRoleUser roleUser = new UacRoleUser();
    roleUser.setUserId(userId);
    roleUser.setRoleId(roleId);
    return uacRoleUserMapper.insertSelective(roleUser);
}
Also used : UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacRoleUser(com.paascloud.provider.model.domain.UacRoleUser)

Aggregations

UacBizException (com.paascloud.provider.model.exceptions.UacBizException)37 Transactional (org.springframework.transaction.annotation.Transactional)8 UacGroup (com.paascloud.provider.model.domain.UacGroup)6 UacMenu (com.paascloud.provider.model.domain.UacMenu)6 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)5 UacGroupUser (com.paascloud.provider.model.domain.UacGroupUser)5 MqMessageData (com.paascloud.provider.model.domain.MqMessageData)4 UacRoleMenu (com.paascloud.provider.model.domain.UacRoleMenu)4 UacRoleUser (com.paascloud.provider.model.domain.UacRoleUser)4 MenuVo (com.paascloud.provider.model.vo.MenuVo)4 UacRoleAction (com.paascloud.provider.model.domain.UacRoleAction)3 UacUser (com.paascloud.provider.model.domain.UacUser)3 BindAuthVo (com.paascloud.provider.model.vo.BindAuthVo)2 UserBindRoleVo (com.paascloud.provider.model.vo.UserBindRoleVo)2 ApiOperation (io.swagger.annotations.ApiOperation)2 Date (java.util.Date)2 LogAnnotation (com.paascloud.core.annotation.LogAnnotation)1 MqProducerStore (com.paascloud.provider.annotation.MqProducerStore)1 UacAction (com.paascloud.provider.model.domain.UacAction)1 UacRole (com.paascloud.provider.model.domain.UacRole)1