From e07dbb01b76f37de832160abba42cd171f677a51 Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Thu, 31 Jul 2025 10:27:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E8=AE=BE=E5=A4=87=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DeviceTypeServiceImpl.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeServiceImpl.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeServiceImpl.java index fcc373e..6d06c19 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeServiceImpl.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeServiceImpl.java @@ -107,6 +107,13 @@ public class DeviceTypeServiceImpl extends ServiceImpl typeName = deviceTypeMapper.selectList(new QueryWrapper().eq("type_name", resources.getTypeName())); + if (CollectionUtil.isNotEmpty(typeName)) { + throw new RuntimeException("设备类型名称已存在,无法新增!!!"); + } + LoginUser loginUser = LoginHelper.getLoginUser(); resources.setCustomerId(loginUser.getUserId()); resources.setOwnerCustomerId(loginUser.getUserId()); @@ -141,11 +148,23 @@ public class DeviceTypeServiceImpl extends ServiceImpl devices = deviceMapper.selectList(new QueryWrapper() + .eq("device_type", deviceTypeGrants.getDeviceTypeId())); + if (CollectionUtil.isNotEmpty(devices)) { + throw new RuntimeException("该设备类型已绑定设备,无法修改!!!"); + } + + // 校验设备类型名称 + DeviceType dt = deviceTypeMapper.selectOne(new QueryWrapper().eq("type_name", resources.getTypeName())); + if (dt != null && !dt.getId().equals(deviceType.getId())) { + throw new RuntimeException("设备类型名称已存在,无法修改!!!"); + } + if (!Objects.equals(deviceType.getCustomerId(), LoginHelper.getUserId())) { throw new RuntimeException("无权修改该设备类型"); } - // if (deviceMapper.countByTypeId(resources.getId()) > 0) - // throw new RuntimeException("该设备类型已被使用,无法删除"); + BeanUtil.copyProperties(resources, deviceType); deviceTypeMapper.updateById(deviceType); }