Search in sources :

Example 6 with UacBizException

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

the class UacGroupServiceImpl method getGroupBindUserDto.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public GroupBindUserDto getGroupBindUserDto(Long groupId, Long currentUserId) {
    GroupBindUserDto groupBindUserDto = new GroupBindUserDto();
    Set<Long> alreadyBindUserIdSet = Sets.newHashSet();
    UacGroup uacGroup = uacGroupMapper.selectByPrimaryKey(groupId);
    if (PublicUtil.isEmpty(uacGroup)) {
        logger.error("找不到uacGroup={}, 的组织", uacGroup);
        throw new UacBizException(ErrorCodeEnum.UAC10015001, groupId);
    }
    // 查询所有用户包括已禁用的用户
    List<BindUserDto> bindUserDtoList = uacRoleMapper.selectAllNeedBindUser(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID, currentUserId);
    // 该组织已经绑定的用户
    List<UacGroupUser> setAlreadyBindUserSet = uacGroupUserMapper.listByGroupId(groupId);
    Set<BindUserDto> allUserSet = new HashSet<>(bindUserDtoList);
    for (UacGroupUser uacGroupUser : setAlreadyBindUserSet) {
        alreadyBindUserIdSet.add(uacGroupUser.getUserId());
    }
    groupBindUserDto.setAllUserSet(allUserSet);
    groupBindUserDto.setAlreadyBindUserIdSet(alreadyBindUserIdSet);
    return groupBindUserDto;
}
Also used : BindUserDto(com.paascloud.provider.model.dto.role.BindUserDto) GroupBindUserDto(com.paascloud.provider.model.dto.group.GroupBindUserDto) UacGroup(com.paascloud.provider.model.domain.UacGroup) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacGroupUser(com.paascloud.provider.model.domain.UacGroupUser) GroupBindUserDto(com.paascloud.provider.model.dto.group.GroupBindUserDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with UacBizException

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

the class UacMenuServiceImpl method getViewVoById.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ViewMenuVo getViewVoById(Long id) {
    Preconditions.checkArgument(id != null, "菜单ID不能为空");
    UacMenu menu = uacMenuMapper.selectByPrimaryKey(id);
    if (menu == null) {
        logger.error("找不到菜单信息id={}", id);
        throw new UacBizException(ErrorCodeEnum.UAC10013003, id);
    }
    // 获取父级菜单信息
    UacMenu parentMenu = uacMenuMapper.selectByPrimaryKey(menu.getPid());
    ModelMapper modelMapper = new ModelMapper();
    ViewMenuVo menuVo = modelMapper.map(menu, ViewMenuVo.class);
    if (parentMenu != null) {
        menuVo.setParentMenuName(parentMenu.getMenuName());
    }
    return menuVo;
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) ViewMenuVo(com.paascloud.provider.model.vo.ViewMenuVo) ModelMapper(org.modelmapper.ModelMapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with UacBizException

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

the class UacMenuServiceImpl method disableMenuList.

@Override
public int disableMenuList(List<UacMenu> menuList, LoginAuthDto loginAuthDto) {
    UacMenu uacMenuUpdate = new UacMenu();
    int sum = 0;
    for (UacMenu menu : menuList) {
        uacMenuUpdate.setId(menu.getId());
        uacMenuUpdate.setVersion(menu.getVersion() + 1);
        uacMenuUpdate.setStatus(UacMenuStatusEnum.DISABLE.getType());
        uacMenuUpdate.setLastOperator(loginAuthDto.getLoginName());
        uacMenuUpdate.setLastOperatorId(loginAuthDto.getUserId());
        uacMenuUpdate.setUpdateTime(new Date());
        int result = mapper.updateByPrimaryKeySelective(uacMenuUpdate);
        if (result > 0) {
            sum += 1;
        } else {
            throw new UacBizException(ErrorCodeEnum.UAC10013005, menu.getId());
        }
    }
    return sum;
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 9 with UacBizException

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

the class UacMenuServiceImpl method saveUacMenu.

@Override
public int saveUacMenu(UacMenu menu, LoginAuthDto loginAuthDto) {
    Long pid = menu.getPid();
    menu.setUpdateInfo(loginAuthDto);
    UacMenu parentMenu = mapper.selectByPrimaryKey(pid);
    if (PublicUtil.isEmpty(parentMenu)) {
        throw new UacBizException(ErrorCodeEnum.UAC10013001, pid);
    }
    if (menu.isNew()) {
        UacMenu updateMenu = new UacMenu();
        menu.setLevel(parentMenu.getLevel() + 1);
        updateMenu.setLeaf(MenuConstant.MENU_LEAF_NO);
        updateMenu.setId(pid);
        Long menuId = super.generateId();
        menu.setId(menuId);
        int result = mapper.updateByPrimaryKeySelective(updateMenu);
        if (result < 1) {
            throw new UacBizException(ErrorCodeEnum.UAC10013002, menuId);
        }
        menu.setStatus(UacMenuStatusEnum.ENABLE.getType());
        menu.setCreatorId(loginAuthDto.getUserId());
        menu.setCreator(loginAuthDto.getUserName());
        menu.setLastOperatorId(loginAuthDto.getUserId());
        menu.setLastOperator(loginAuthDto.getUserName());
        // 新增的菜单是叶子节点
        menu.setLeaf(MenuConstant.MENU_LEAF_YES);
        return uacMenuMapper.insertSelective(menu);
    } else {
        return uacMenuMapper.updateByPrimaryKeySelective(menu);
    }
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 10 with UacBizException

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

the class UacMenuServiceImpl method enableMenuList.

@Override
public int enableMenuList(List<UacMenu> menuList, LoginAuthDto loginAuthDto) {
    UacMenu uacMenuUpdate = new UacMenu();
    int sum = 0;
    for (UacMenu menu : menuList) {
        uacMenuUpdate.setId(menu.getId());
        uacMenuUpdate.setVersion(menu.getVersion() + 1);
        uacMenuUpdate.setStatus(UacMenuStatusEnum.ENABLE.getType());
        uacMenuUpdate.setLastOperator(loginAuthDto.getLoginName());
        uacMenuUpdate.setLastOperatorId(loginAuthDto.getUserId());
        uacMenuUpdate.setUpdateTime(new Date());
        int result = mapper.updateByPrimaryKeySelective(uacMenuUpdate);
        if (result > 0) {
            sum += 1;
        } else {
            throw new UacBizException(ErrorCodeEnum.UAC10013004, menu.getId());
        }
    }
    return sum;
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

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