Search in sources :

Example 11 with UacGroup

use of com.paascloud.provider.model.domain.UacGroup 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 12 with UacGroup

use of com.paascloud.provider.model.domain.UacGroup in project paascloud-master by paascloud.

the class UacGroupServiceImpl method getGroupTree.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<GroupZtreeVo> getGroupTree(Long groupId) {
    // 1. 如果是仓库则 直接把仓库信息封装成ztreeVo返回
    List<GroupZtreeVo> tree = Lists.newArrayList();
    UacGroup uacGroup = uacGroupMapper.selectByPrimaryKey(groupId);
    GroupZtreeVo zTreeMenuVo = buildGroupZTreeVoByGroup(uacGroup);
    if (0L == uacGroup.getPid()) {
        zTreeMenuVo.setOpen(true);
    }
    tree.add(zTreeMenuVo);
    // 2.如果是组织id则遍历组织+仓库的树结构
    // 如果是组织 则查询父id为
    UacGroup uacGroupQuery = new UacGroup();
    uacGroupQuery.setPid(groupId);
    List<UacGroup> groupList = uacGroupMapper.select(uacGroupQuery);
    if (PublicUtil.isNotEmpty(groupList)) {
        tree = buildNode(groupList, tree);
    }
    return tree;
}
Also used : GroupZtreeVo(com.paascloud.provider.model.vo.GroupZtreeVo) UacGroup(com.paascloud.provider.model.domain.UacGroup) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

UacGroup (com.paascloud.provider.model.domain.UacGroup)12 UacBizException (com.paascloud.provider.model.exceptions.UacBizException)6 UacGroupUser (com.paascloud.provider.model.domain.UacGroupUser)5 GroupZtreeVo (com.paascloud.provider.model.vo.GroupZtreeVo)5 Transactional (org.springframework.transaction.annotation.Transactional)5 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)2 ApiOperation (io.swagger.annotations.ApiOperation)2 LogAnnotation (com.paascloud.core.annotation.LogAnnotation)1 UacUser (com.paascloud.provider.model.domain.UacUser)1 GroupBindUserDto (com.paascloud.provider.model.dto.group.GroupBindUserDto)1 BindUserDto (com.paascloud.provider.model.dto.role.BindUserDto)1