diff --git a/health-watch/health-watch-biz/src/main/java/com/renkang/watch/controller/WatchDeviceController.java b/health-watch/health-watch-biz/src/main/java/com/renkang/watch/controller/WatchDeviceController.java index c0be757..3ff9d19 100644 --- a/health-watch/health-watch-biz/src/main/java/com/renkang/watch/controller/WatchDeviceController.java +++ b/health-watch/health-watch-biz/src/main/java/com/renkang/watch/controller/WatchDeviceController.java @@ -295,6 +295,12 @@ public class WatchDeviceController extends JeecgController add(@RequestBody WatchDevice watchDevice) { + // 校验设备编码是否已存在 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(WatchDevice::getWatchNo, watchDevice.getWatchNo()); + if (watchDeviceService.count(queryWrapper) > 0) { + return Result.error("设备编码已存在,请勿重复添加"); + } // 删除开关 LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(WatchDeviceSwitch::getWatchNo, watchDevice.getWatchNo());