[Fix]修复“删除有掉线提醒的实例时会导致所有提醒都无法显示”的Bug
This commit is contained in:
@@ -11,12 +11,14 @@ import com.mzaxd.noodles.domain.entity.Container;
|
|||||||
import com.mzaxd.noodles.domain.vo.*;
|
import com.mzaxd.noodles.domain.vo.*;
|
||||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
||||||
import com.mzaxd.noodles.mapper.HostMachineMapper;
|
import com.mzaxd.noodles.mapper.HostMachineMapper;
|
||||||
|
import com.mzaxd.noodles.mapper.NotificationMapper;
|
||||||
import com.mzaxd.noodles.service.ContainerService;
|
import com.mzaxd.noodles.service.ContainerService;
|
||||||
import com.mzaxd.noodles.mapper.ContainerMapper;
|
import com.mzaxd.noodles.mapper.ContainerMapper;
|
||||||
import com.mzaxd.noodles.service.HostMachineService;
|
import com.mzaxd.noodles.service.HostMachineService;
|
||||||
import com.mzaxd.noodles.service.SshLinkService;
|
import com.mzaxd.noodles.service.SshLinkService;
|
||||||
import com.mzaxd.noodles.util.BeanCopyUtils;
|
import com.mzaxd.noodles.util.BeanCopyUtils;
|
||||||
import com.mzaxd.noodles.util.SshLinkUtil;
|
import com.mzaxd.noodles.util.SshLinkUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@@ -32,6 +34,7 @@ import java.util.Objects;
|
|||||||
* @createDate 2023-02-02 06:26:00
|
* @createDate 2023-02-02 06:26:00
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container>
|
public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container>
|
||||||
implements ContainerService {
|
implements ContainerService {
|
||||||
|
|
||||||
@@ -47,6 +50,9 @@ public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container
|
|||||||
@Resource
|
@Resource
|
||||||
private SshLinkService sshLinkService;
|
private SshLinkService sshLinkService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private NotificationMapper notificationMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseResult containerListSummaryStatistics() {
|
public ResponseResult containerListSummaryStatistics() {
|
||||||
//设置查询所有在线vm的条件
|
//设置查询所有在线vm的条件
|
||||||
@@ -109,6 +115,12 @@ public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container
|
|||||||
@Override
|
@Override
|
||||||
public ResponseResult deleteContainerById(Integer id) {
|
public ResponseResult deleteContainerById(Integer id) {
|
||||||
if (removeById(id)) {
|
if (removeById(id)) {
|
||||||
|
//删除掉线提醒
|
||||||
|
LambdaQueryWrapper<Notification> notificationLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
notificationLambdaQueryWrapper.eq(Notification::getInstanceId, id);
|
||||||
|
notificationLambdaQueryWrapper.eq(Notification::getInstanceType, SystemConstant.INSTANCETYPE_CONTAINER);
|
||||||
|
notificationMapper.delete(notificationLambdaQueryWrapper);
|
||||||
|
log.info("删除id为{}的虚拟机的所有掉线提醒", id);
|
||||||
return ResponseResult.okResult("删除成功");
|
return ResponseResult.okResult("删除成功");
|
||||||
}
|
}
|
||||||
return ResponseResult.errorResult(AppHttpCodeEnum.SYSTEM_ERROR);
|
return ResponseResult.errorResult(AppHttpCodeEnum.SYSTEM_ERROR);
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ import com.mzaxd.noodles.domain.message.Server;
|
|||||||
import com.mzaxd.noodles.domain.vo.*;
|
import com.mzaxd.noodles.domain.vo.*;
|
||||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
||||||
import com.mzaxd.noodles.exception.SystemException;
|
import com.mzaxd.noodles.exception.SystemException;
|
||||||
import com.mzaxd.noodles.mapper.HostDetectorMapper;
|
import com.mzaxd.noodles.mapper.*;
|
||||||
import com.mzaxd.noodles.mapper.HostMachineMapper;
|
|
||||||
import com.mzaxd.noodles.mapper.OsMapper;
|
|
||||||
import com.mzaxd.noodles.mapper.SshLinkMapper;
|
|
||||||
import com.mzaxd.noodles.service.*;
|
import com.mzaxd.noodles.service.*;
|
||||||
import com.mzaxd.noodles.util.BeanCopyUtils;
|
import com.mzaxd.noodles.util.BeanCopyUtils;
|
||||||
import com.mzaxd.noodles.util.SshLinkUtil;
|
import com.mzaxd.noodles.util.SshLinkUtil;
|
||||||
@@ -74,6 +71,9 @@ public class HostMachineServiceImpl extends ServiceImpl<HostMachineMapper, HostM
|
|||||||
@Resource
|
@Resource
|
||||||
private SshLinkMapper sshLinkMapper;
|
private SshLinkMapper sshLinkMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private NotificationMapper notificationMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseResult getHostDrawer() {
|
public ResponseResult getHostDrawer() {
|
||||||
LambdaQueryWrapper<HostMachine> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<HostMachine> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -340,8 +340,16 @@ public class HostMachineServiceImpl extends ServiceImpl<HostMachineMapper, HostM
|
|||||||
log.info("删除hostId为{}的host信息", id);
|
log.info("删除hostId为{}的host信息", id);
|
||||||
osMapper.deleteById(hostMachine.getOsId());
|
osMapper.deleteById(hostMachine.getOsId());
|
||||||
}
|
}
|
||||||
log.info("删除id为{}的host", id);
|
//删除掉线提醒
|
||||||
|
LambdaQueryWrapper<Notification> notificationLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
notificationLambdaQueryWrapper.eq(Notification::getInstanceId, id);
|
||||||
|
notificationLambdaQueryWrapper.eq(Notification::getInstanceType, SystemConstant.INSTANCETYPE_HOST);
|
||||||
|
notificationMapper.delete(notificationLambdaQueryWrapper);
|
||||||
|
log.info("删除id为{}的物理机的所有掉线提醒", id);
|
||||||
|
|
||||||
|
//删除物理机
|
||||||
hostMachineMapper.deleteById(id);
|
hostMachineMapper.deleteById(id);
|
||||||
|
log.info("删除id为{}的host", id);
|
||||||
return ResponseResult.okResult(SystemConstant.SUCCESS_CODE, "删除成功");
|
return ResponseResult.okResult(SystemConstant.SUCCESS_CODE, "删除成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,8 +461,15 @@ public class HostMachineServiceImpl extends ServiceImpl<HostMachineMapper, HostM
|
|||||||
if (Objects.nonNull(getById(id).getSshId())) {
|
if (Objects.nonNull(getById(id).getSshId())) {
|
||||||
sshLinkMapper.deleteById(getById(id).getSshId());
|
sshLinkMapper.deleteById(getById(id).getSshId());
|
||||||
}
|
}
|
||||||
log.info("删除id为{}的vm", id);
|
//删除掉线提醒
|
||||||
|
LambdaQueryWrapper<Notification> notificationLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
notificationLambdaQueryWrapper.eq(Notification::getInstanceId, id);
|
||||||
|
notificationLambdaQueryWrapper.eq(Notification::getInstanceType, SystemConstant.INSTANCETYPE_VM);
|
||||||
|
notificationMapper.delete(notificationLambdaQueryWrapper);
|
||||||
|
log.info("删除id为{}的虚拟机的所有掉线提醒", id);
|
||||||
|
|
||||||
hostMachineMapper.deleteById(id);
|
hostMachineMapper.deleteById(id);
|
||||||
|
log.info("删除id为{}的vm", id);
|
||||||
return ResponseResult.okResult(SystemConstant.SUCCESS_CODE, "删除成功");
|
return ResponseResult.okResult(SystemConstant.SUCCESS_CODE, "删除成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user