Search in sources :

Example 31 with UacBizException

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

the class UacGroupServiceImpl method getById.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public UacGroup getById(Long id) {
    UacGroup uacGroup = uacGroupMapper.selectByPrimaryKey(id);
    if (PublicUtil.isEmpty(uacGroup)) {
        throw new UacBizException(ErrorCodeEnum.UAC10015001, id);
    }
    UacGroup parentGroup = uacGroupMapper.selectByPrimaryKey(uacGroup.getPid());
    if (parentGroup != null) {
        uacGroup.setParentGroupCode(parentGroup.getGroupCode());
        uacGroup.setParentGroupName(parentGroup.getGroupName());
    }
    // 处理饿了吗级联菜单回显地址
    Long provinceId = uacGroup.getProvinceId();
    Long cityId = uacGroup.getCityId();
    Long areaId = uacGroup.getAreaId();
    Long streetId = uacGroup.getStreetId();
    List<Long> addressList = Lists.newArrayList();
    if (provinceId != null) {
        addressList.add(provinceId);
    }
    if (cityId != null) {
        addressList.add(cityId);
    }
    if (areaId != null) {
        addressList.add(areaId);
    }
    if (streetId != null) {
        addressList.add(streetId);
    }
    uacGroup.setAddressList(addressList);
    return uacGroup;
}
Also used : UacGroup(com.paascloud.provider.model.domain.UacGroup) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 32 with UacBizException

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

the class UacGroupServiceImpl method deleteUacGroupById.

@Override
public int deleteUacGroupById(Long id) {
    Preconditions.checkArgument(id != null, "组织id为空");
    Preconditions.checkArgument(!Objects.equals(id, GlobalConstant.Sys.SUPER_MANAGER_GROUP_ID), "该组织不能删除");
    // 根据前台传入的组织参数校验该组织是否存在
    UacGroup uacGroup = uacGroupMapper.selectByPrimaryKey(id);
    if (PublicUtil.isEmpty(uacGroup)) {
        throw new UacBizException(ErrorCodeEnum.UAC10015004, id);
    }
    // 判断该组织下是否存在子节点
    UacGroup childGroup = new UacGroup();
    childGroup.setPid(id);
    List<UacGroup> childGroupList = uacGroupMapper.select(childGroup);
    if (PublicUtil.isNotEmpty(childGroupList)) {
        throw new UacBizException(ErrorCodeEnum.UAC10015007, id);
    }
    // 判断该组织下是否存在用户
    UacGroupUser uacGroupUser = new UacGroupUser();
    uacGroupUser.setGroupId(id);
    List<UacGroupUser> uacGroupUserList = uacGroupUserMapper.select(uacGroupUser);
    if (PublicUtil.isNotEmpty(uacGroupUserList)) {
        throw new UacBizException(ErrorCodeEnum.UAC10015008, id);
    }
    return mapper.deleteByPrimaryKey(id);
}
Also used : UacGroup(com.paascloud.provider.model.domain.UacGroup) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacGroupUser(com.paascloud.provider.model.domain.UacGroupUser)

Example 33 with UacBizException

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

the class UacMenuServiceImpl method deleteUacMenuById.

@Override
public int deleteUacMenuById(Long id, LoginAuthDto loginAuthDto) {
    Preconditions.checkArgument(id != null, "菜单id不能为空");
    int result;
    // 获取当前菜单信息
    UacMenu uacMenuQuery = new UacMenu();
    uacMenuQuery.setId(id);
    uacMenuQuery = mapper.selectOne(uacMenuQuery);
    if (PublicUtil.isEmpty(uacMenuQuery)) {
        throw new UacBizException(ErrorCodeEnum.UAC10013003, id);
    }
    // 删除菜单与角色的关联关系
    UacRoleMenu uacRoleMenu = new UacRoleMenu();
    uacRoleMenu.setMenuId(id);
    uacRoleMenuService.delete(uacRoleMenu);
    // 删除菜单
    result = uacMenuMapper.deleteByPrimaryKey(id);
    if (result < 1) {
        logger.error("删除菜单失败 menuId={}", id);
        throw new UacBizException(ErrorCodeEnum.UAC10013008, id);
    }
    // 删除权限
    // TODO 应该先查询再删除
    uacActionService.deleteByMenuId(id);
    // 修改当前删除菜单的父菜单是否是叶子节点
    UacMenu updateParentUacMenu = new UacMenu();
    updateParentUacMenu.setId(uacMenuQuery.getPid());
    updateParentUacMenu.setLeaf(MenuConstant.MENU_LEAF_YES);
    // 是二三级
    if (Objects.equals(MenuConstant.MENU_LEVEL_TWO, uacMenuQuery.getLevel()) || Objects.equals(MenuConstant.MENU_LEVEL_THREE, uacMenuQuery.getLevel())) {
        // 查询是否是叶子节点
        int count = uacMenuMapper.selectMenuChildCountByPid(uacMenuQuery.getPid());
        if (count == 0) {
            uacMenuMapper.updateByPrimaryKeySelective(updateParentUacMenu);
        }
    }
    return result;
}
Also used : UacRoleMenu(com.paascloud.provider.model.domain.UacRoleMenu) UacMenu(com.paascloud.provider.model.domain.UacMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 34 with UacBizException

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

the class UacMenuServiceImpl method updateUacMenuStatusById.

@Override
public void updateUacMenuStatusById(UacMenuStatusDto uacMenuStatusDto, LoginAuthDto loginAuthDto) {
    Long id = uacMenuStatusDto.getId();
    String status = uacMenuStatusDto.getStatus();
    Preconditions.checkArgument(id != null, "菜单ID不能为空");
    Preconditions.checkArgument(StringUtils.isNotEmpty(status), "菜单状态不能为空");
    UacMenu uacMenuQuery = this.selectByKey(id);
    if (MenuConstant.MENU_LEVEL_ROOT.equals(uacMenuQuery.getLevel())) {
        throw new UacBizException(ErrorCodeEnum.UAC10013007);
    }
    // 要处理的菜单集合
    List<UacMenu> menuList = Lists.newArrayList();
    int result;
    if (status.equals(UacMenuStatusEnum.DISABLE.getType())) {
        // 获取菜单以及子菜单
        menuList = this.getAllChildMenuByMenuId(id, UacMenuStatusEnum.ENABLE.getType());
        // 禁用菜单以及子菜单
        result = this.disableMenuList(menuList, loginAuthDto);
    } else {
        // 获取菜单、其子菜单以及父菜单
        UacMenu uacMenu = new UacMenu();
        uacMenu.setPid(id);
        result = this.selectCount(uacMenu);
        // 此菜单含有子菜单
        if (result > 0) {
            menuList = this.getAllChildMenuByMenuId(id, UacMenuStatusEnum.DISABLE.getType());
        }
        List<UacMenu> menuListTemp = this.getAllParentMenuByMenuId(id);
        for (UacMenu menu : menuListTemp) {
            if (!menuList.contains(menu)) {
                menuList.add(menu);
            }
        }
        // 启用菜单、其子菜单以及父菜单
        result = this.enableMenuList(menuList, loginAuthDto);
    }
    if (result < 1) {
        throw new UacBizException(ErrorCodeEnum.UAC10013006, id);
    }
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 35 with UacBizException

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

the class UacRoleActionServiceImpl method insert.

@Override
public void insert(Long roleId, Set<Long> actionIdList) {
    if (roleId == null) {
        throw new UacBizException(ErrorCodeEnum.UAC10012001);
    }
    UacRoleAction uacRoleAction = new UacRoleAction();
    uacRoleAction.setRoleId(roleId);
    for (Long actionId : actionIdList) {
        uacRoleAction.setActionId(actionId);
        uacRoleActionMapper.insert(uacRoleAction);
    }
}
Also used : UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacRoleAction(com.paascloud.provider.model.domain.UacRoleAction)

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