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);
}
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;
}
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);
}
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;
}
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);
}
Aggregations