From a7f1bd95dfc3081572c89d633ebaf8cc429d8cca Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 26 Dec 2023 23:46:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/service/impl/DeviceServiceImpl.java | 4 +++- .../vmanager/gb28181/device/DeviceQuery.java | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index 71913406..78a7bed6 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -579,7 +579,9 @@ public class DeviceServiceImpl implements IDeviceService { @Transactional public boolean delete(String deviceId) { List commonChannelIdList = deviceChannelMapper.getCommonChannelIdList(deviceId); - commonGbChannelService.deleteByIdList(commonChannelIdList); + if (!commonChannelIdList.isEmpty()) { + commonGbChannelService.deleteByIdList(commonChannelIdList); + } deviceChannelMapper.cleanChannelsByDeviceId(deviceId); deviceMapper.del(deviceId); return true; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java index 469e9103..bdf03890 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java @@ -307,11 +307,14 @@ public class DeviceQuery { */ @Operation(summary = "添加设备信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "device", description = "设备", required = true) - @PostMapping("/device/add/") - public void addDevice(Device device){ + @PostMapping("/device/add") + public void addDevice(@RequestBody Device device){ - if (device == null || device.getDeviceId() == null) { - throw new ControllerException(ErrorCode.ERROR400); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "参数不可为空"); + } + if (device.getDeviceId() == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "DeviceId不可为空"); } // 查看deviceId是否存在 @@ -329,12 +332,15 @@ public class DeviceQuery { */ @Operation(summary = "更新设备信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "device", description = "设备", required = true) - @PostMapping("/device/update/") - public void updateDevice(Device device){ - - if (device != null && device.getDeviceId() != null) { - deviceService.updateCustomDevice(device); + @PostMapping("/device/update") + public void updateDevice(@RequestBody Device device){ + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "参数不可为空"); } + if (device.getDeviceId() == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "DeviceId不可为空"); + } + deviceService.updateCustomDevice(device); } /**