use of com.paascloud.provider.model.domain.UacGroupUser in project paascloud-master by paascloud.
the class UacGroupServiceImpl method bindUacUser4Group.
/**
* Bind uac user 4 group int.
*
* @param groupBindUserReqDto the group bind user req dto
* @param authResDto the auth res dto
*/
@Override
public void bindUacUser4Group(GroupBindUserReqDto groupBindUserReqDto, LoginAuthDto authResDto) {
if (groupBindUserReqDto == null) {
logger.error("参数不能为空");
throw new IllegalArgumentException("参数不能为空");
}
Long groupId = groupBindUserReqDto.getGroupId();
Long loginUserId = authResDto.getUserId();
List<Long> userIdList = groupBindUserReqDto.getUserIdList();
if (null == groupId) {
throw new IllegalArgumentException("組織ID不能为空");
}
UacGroup group = uacGroupMapper.selectByPrimaryKey(groupId);
if (group == null) {
logger.error("找不到角色信息 groupId={}", groupId);
throw new UacBizException(ErrorCodeEnum.UAC10015001, groupId);
}
if (PublicUtil.isNotEmpty(userIdList) && userIdList.contains(loginUserId)) {
logger.error("不能操作当前登录用户 userId={}", loginUserId);
throw new UacBizException(ErrorCodeEnum.UAC10011023);
}
// 查询超级管理员用户Id集合
List<Long> superUserList = uacRoleUserMapper.listSuperUser(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);
List<Long> unionList = Collections3.intersection(userIdList, superUserList);
if (PublicUtil.isNotEmpty(userIdList) && PublicUtil.isNotEmpty(unionList)) {
logger.error("不能操作超级管理员用户 超级用户={}", unionList);
throw new UacBizException(ErrorCodeEnum.UAC10011023);
}
// 1. 先取消对该角色的用户绑定(不包含超级管理员用户)
List<UacGroupUser> groupUsers = uacGroupUserMapper.listByGroupId(groupId);
if (PublicUtil.isNotEmpty(groupUsers)) {
uacGroupUserMapper.deleteExcludeSuperMng(groupId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);
}
if (PublicUtil.isEmpty(userIdList)) {
// 取消该角色的所有用户的绑定
logger.info("取消绑定所有非超级管理员用户成功");
return;
}
// 绑定所选用户
for (Long userId : userIdList) {
UacUser uacUser = uacUserService.queryByUserId(userId);
if (PublicUtil.isEmpty(uacUser)) {
logger.error("找不到绑定的用户 userId={}", userId);
throw new UacBizException(ErrorCodeEnum.UAC10011024, userId);
}
UacGroupUser uacGroupUser = new UacGroupUser();
uacGroupUser.setUserId(userId);
uacGroupUser.setGroupId(groupId);
uacGroupUserMapper.insertSelective(uacGroupUser);
}
}
use of com.paascloud.provider.model.domain.UacGroupUser 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);
}
Aggregations