Search in sources :

Example 1 with UacGroupUser

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

the class UserManager method activeUser.

@MqProducerStore
public void activeUser(final MqMessageData mqMessageData, final UacUser uacUser, final String activeUserKey) {
    log.info("激活用户. mqMessageData={}, user={}", mqMessageData, uacUser);
    int result = uacUserMapper.updateByPrimaryKeySelective(uacUser);
    if (result < 1) {
        throw new UacBizException(ErrorCodeEnum.UAC10011038, uacUser.getId());
    }
    // 绑定一个访客角色默认值roleId=10000
    final Long userId = uacUser.getId();
    Preconditions.checkArgument(userId != null, "用戶Id不能爲空");
    final Long roleId = 10000L;
    UacRoleUser roleUser = new UacRoleUser();
    roleUser.setUserId(userId);
    roleUser.setRoleId(roleId);
    uacRoleUserMapper.insertSelective(roleUser);
    // 绑定一个组织
    UacGroupUser groupUser = new UacGroupUser();
    groupUser.setUserId(userId);
    groupUser.setGroupId(GlobalConstant.Sys.SUPER_MANAGER_GROUP_ID);
    uacGroupUserMapper.insertSelective(groupUser);
    // 删除 activeUserToken
    redisService.deleteKey(activeUserKey);
}
Also used : UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacRoleUser(com.paascloud.provider.model.domain.UacRoleUser) UacGroupUser(com.paascloud.provider.model.domain.UacGroupUser) MqProducerStore(com.paascloud.provider.annotation.MqProducerStore)

Example 2 with UacGroupUser

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

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

the class UacGroupUserServiceImpl method saveUserGroup.

@Override
public void saveUserGroup(Long userId, Long groupId) {
    UacGroupUser groupUser = new UacGroupUser();
    groupUser.setUserId(userId);
    groupUser.setGroupId(groupId);
    uacGroupUserMapper.insertSelective(groupUser);
}
Also used : UacGroupUser(com.paascloud.provider.model.domain.UacGroupUser)

Example 4 with UacGroupUser

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

the class UacGroupServiceImpl method updateUacGroupStatusById.

@Override
public int updateUacGroupStatusById(IdStatusDto idStatusDto, LoginAuthDto loginAuthDto) {
    Long groupId = idStatusDto.getId();
    Integer status = idStatusDto.getStatus();
    UacGroup uacGroup = new UacGroup();
    uacGroup.setId(groupId);
    uacGroup.setStatus(status);
    UacGroup group = uacGroupMapper.selectByPrimaryKey(groupId);
    if (PublicUtil.isEmpty(group)) {
        throw new UacBizException(ErrorCodeEnum.UAC10015001, groupId);
    }
    if (!UacGroupStatusEnum.contains(status)) {
        throw new UacBizException(ErrorCodeEnum.UAC10015002);
    }
    // 查询所有的组织
    List<UacGroup> totalGroupList = uacGroupMapper.selectAll();
    List<GroupZtreeVo> totalList = Lists.newArrayList();
    GroupZtreeVo zTreeVo;
    for (UacGroup vo : totalGroupList) {
        zTreeVo = new GroupZtreeVo();
        zTreeVo.setId(vo.getId());
        totalList.add(zTreeVo);
    }
    UacGroupUser uacGroupUser = new UacGroupUser();
    uacGroupUser.setUserId(loginAuthDto.getUserId());
    UacGroupUser groupUser = uacGroupUserMapper.selectOne(uacGroupUser);
    // 查询当前登陆人所在的组织信息
    UacGroup currentUserUacGroup = uacGroupMapper.selectByPrimaryKey(groupUser.getGroupId());
    // 查询当前登陆人能禁用的所有子节点
    List<GroupZtreeVo> childGroupList = this.getGroupTree(currentUserUacGroup.getId());
    // 计算不能禁用的组织= 所有的组织 - 禁用的所有子节点
    totalList.removeAll(childGroupList);
    // 判断所选的组织是否在不能禁用的列表里
    GroupZtreeVo zTreeVo1 = new GroupZtreeVo();
    zTreeVo1.setId(group.getId());
    if (totalList.contains(zTreeVo1)) {
        throw new UacBizException(ErrorCodeEnum.UAC10011023);
    }
    if (groupUser.getGroupId().equals(uacGroup.getId()) && UacGroupStatusEnum.ENABLE.getStatus() == group.getStatus()) {
        throw new UacBizException(ErrorCodeEnum.UAC10011023);
    }
    uacGroup.setGroupName(group.getGroupName());
    uacGroup.setGroupCode(group.getGroupCode());
    uacGroup.setVersion(group.getVersion() + 1);
    int result = uacGroupMapper.updateByPrimaryKeySelective(uacGroup);
    // 获取当前所选组织的所有子节点
    List<GroupZtreeVo> childUacGroupList = this.getGroupTree(uacGroup.getId());
    // 批量修改组织状态
    if (PublicUtil.isNotEmpty(childUacGroupList)) {
        UacGroup childGroup;
        for (GroupZtreeVo uacGroup1 : childUacGroupList) {
            if (UacGroupStatusEnum.ENABLE.getStatus() == status) {
                UacGroup parentGroup = uacGroupMapper.selectByPrimaryKey(uacGroup1.getpId());
                if (parentGroup.getStatus() == UacGroupStatusEnum.DISABLE.getStatus()) {
                    throw new UacBizException(ErrorCodeEnum.UAC10015003);
                }
            }
            childGroup = new UacGroup();
            childGroup.setStatus(uacGroup.getStatus());
            childGroup.setId(uacGroup1.getId());
            result = uacGroupMapper.updateByPrimaryKeySelective(childGroup);
            if (result < 1) {
                throw new UacBizException(ErrorCodeEnum.UAC10015006, uacGroup1.getId());
            }
        }
    }
    return result;
}
Also used : GroupZtreeVo(com.paascloud.provider.model.vo.GroupZtreeVo) UacGroup(com.paascloud.provider.model.domain.UacGroup) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacGroupUser(com.paascloud.provider.model.domain.UacGroupUser)

Example 5 with UacGroupUser

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

the class UacGroupServiceImpl method getGroupTreeListByUserId.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<MenuVo> getGroupTreeListByUserId(Long userId) {
    UacGroupUser groupUser = uacGroupUserMapper.getByUserId(userId);
    Long groupId = groupUser.getGroupId();
    // 查询当前登陆人所在的组织信息
    UacGroup currentUserUacGroup = uacGroupMapper.selectByPrimaryKey(groupId);
    // 获取当前所选组织的所有子节点
    List<GroupZtreeVo> childUacGroupList = this.getGroupTree(currentUserUacGroup.getId());
    return this.buildGroupTree(childUacGroupList, groupId);
}
Also used : GroupZtreeVo(com.paascloud.provider.model.vo.GroupZtreeVo) UacGroup(com.paascloud.provider.model.domain.UacGroup) UacGroupUser(com.paascloud.provider.model.domain.UacGroupUser) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

UacGroupUser (com.paascloud.provider.model.domain.UacGroupUser)7 UacGroup (com.paascloud.provider.model.domain.UacGroup)5 UacBizException (com.paascloud.provider.model.exceptions.UacBizException)5 GroupZtreeVo (com.paascloud.provider.model.vo.GroupZtreeVo)2 Transactional (org.springframework.transaction.annotation.Transactional)2 MqProducerStore (com.paascloud.provider.annotation.MqProducerStore)1 UacRoleUser (com.paascloud.provider.model.domain.UacRoleUser)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