该设备类型下已有设备,无法修改设备类型名称!!!

This commit is contained in:
2025-12-26 16:21:33 +08:00
parent af42a2199c
commit d7c4d22de3
12 changed files with 19 additions and 31 deletions

View File

@ -79,7 +79,6 @@ public class DeviceTypeController {
public R<DeviceType> getCommunicationMode(@Parameter(name = "设备类型ID", required = true) Long id) {
DeviceType communicationMode = deviceTypeService.getCommunicationMode(id);
return R.ok(communicationMode);
}
}

View File

@ -224,22 +224,13 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
throw new RuntimeException("设备类型不存在");
}
if (!deviceType.getTypeName().equals(resources.getTypeName())) {
int count = deviceMapper.countByDeviceTypeId(deviceType.getId());
if (count > 0) {
throw new RuntimeException("该设备类型下已有绑定设备,无法修改设备类型名称!!!");
throw new RuntimeException("该设备类型下已有设备,无法修改设备类型名称!!!");
}
}
// List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>()
// .eq("device_type", deviceTypeGrants.getDeviceTypeId()));
// if (CollectionUtil.isNotEmpty(devices)) {
// throw new RuntimeException("该设备类型已绑定设备,无法修改!!!");
// }
// 校验设备类型名称
DeviceType dt = deviceTypeMapper.selectOne(new QueryWrapper<DeviceType>().eq("type_name", resources.getTypeName()));
if (dt != null && !dt.getId().equals(deviceType.getId())) {