设备编码 没做唯一性校验,可以新增相同编码的设备
This commit is contained in:
chenhaojie 2024-10-16 15:05:52 +08:00
parent 0faf0601ff
commit 1087f539af

View File

@ -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());
}