fix(watch): 添加设备时校验watchNo唯一性,避免数据库唯一约束冲突
This commit is contained in:
+6
@@ -295,6 +295,12 @@ public class WatchDeviceController extends JeecgController<WatchDevice, IWatchDe
|
||||
@RequiresPermissions("watch:watch_device:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody WatchDevice watchDevice) {
|
||||
// 校验设备编码是否已存在
|
||||
LambdaQueryWrapper<WatchDevice> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WatchDevice::getWatchNo, watchDevice.getWatchNo());
|
||||
if (watchDeviceService.count(queryWrapper) > 0) {
|
||||
return Result.error("设备编码已存在,请勿重复添加");
|
||||
}
|
||||
// 删除开关
|
||||
LambdaUpdateWrapper<WatchDeviceSwitch> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(WatchDeviceSwitch::getWatchNo, watchDevice.getWatchNo());
|
||||
|
||||
Reference in New Issue
Block a user