From 1087f539af4c79645c338c60dc0c1902274fcebb Mon Sep 17 00:00:00 2001 From: chenhaojie Date: Wed, 16 Oct 2024 15:05:52 +0800 Subject: [PATCH] =?UTF-8?q?[301]=20=E8=AE=BE=E5=A4=87=E7=BC=96=E7=A0=81=20?= =?UTF-8?q?=E6=B2=A1=E5=81=9A=E5=94=AF=E4=B8=80=E6=80=A7=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=EF=BC=8C=E5=8F=AF=E4=BB=A5=E6=96=B0=E5=A2=9E=E7=9B=B8=E5=90=8C?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E7=9A=84=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equipment/service/impl/SysEquipmentServiceImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java b/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java index 947ef728..4badc526 100644 --- a/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java +++ b/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java @@ -65,7 +65,7 @@ public class SysEquipmentServiceImpl implements SysEquipmentService { SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY); // 判断设备编码是否存在 if (sysEquipmentMapper.queryEquipmentByCode(sysEquipment.getCode()) > 0) { - throw new ServiceException("设备编码已存在"); + throw new RuntimeException("设备编码已存在"); } sysEquipment.setCreatedTime(new Date()); sysEquipment.setUpdatedTime(new Date()); @@ -83,6 +83,10 @@ public class SysEquipmentServiceImpl implements SysEquipmentService { SysEquipment sysEquipment = new SysEquipment(); BeanCopyUtils.copy(sysEquipmentDto, sysEquipment); SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY); + // 判断设备编码是否存在 + if (sysEquipmentMapper.queryEquipmentByCode(sysEquipment.getCode()) > 0) { + throw new RuntimeException("设备编码已存在"); + } sysEquipment.setUpdatedTime(new Date()); sysEquipment.setUpdatedBy(sysUserVo.getAccount()); sysEquipmentMapper.updateById(sysEquipment); @@ -95,7 +99,7 @@ public class SysEquipmentServiceImpl implements SysEquipmentService { public void deleteSysEquipment(SysEquipmentDto sysEquipmentDto) { // 设备下面有子设备则不能删除 if (sysEquipmentMapper.queryChildEquipmentCount(sysEquipmentDto.getId()) > 0) { - throw new ServiceException("该设备下有子设备,不能删除"); + throw new RuntimeException("该设备下有子设备,不能删除"); } sysEquipmentMapper.deleteById(sysEquipmentDto.getId()); }