diff --git a/gb28181-wvp-proxy-api/src/main/java/cn/skcks/docking/gb28181/wvp/api/device/DeviceController.java b/gb28181-wvp-proxy-api/src/main/java/cn/skcks/docking/gb28181/wvp/api/device/DeviceController.java index 19e1738..a1c3d56 100644 --- a/gb28181-wvp-proxy-api/src/main/java/cn/skcks/docking/gb28181/wvp/api/device/DeviceController.java +++ b/gb28181-wvp-proxy-api/src/main/java/cn/skcks/docking/gb28181/wvp/api/device/DeviceController.java @@ -1,5 +1,6 @@ package cn.skcks.docking.gb28181.wvp.api.device; +import cn.skcks.docking.gb28181.annotation.web.JsonMapping; import cn.skcks.docking.gb28181.annotation.web.methods.GetJson; import cn.skcks.docking.gb28181.annotation.web.methods.PostJson; import cn.skcks.docking.gb28181.common.json.JsonResponse; @@ -58,4 +59,28 @@ public class DeviceController { WvpProxyDevice wvpProxyDevice = deviceService.getDeviceByGbDeviceId(gbDeviceId).orElse(null); return JsonResponse.success(wvpProxyDevice); } + + @Operation(summary = "根据设备编码(21位) 删除指定设备") + @JsonMapping(value = "/delete/deviceCode",method = {RequestMethod.GET,RequestMethod.DELETE}) + public JsonResponse deleteByDeviceCode(@RequestParam String deviceCode){ + WvpProxyDevice wvpProxyDevice = new WvpProxyDevice(); + wvpProxyDevice.setDeviceCode(deviceCode); + return JsonResponse.success(deviceService.deleteDevice(wvpProxyDevice)); + } + + @Operation(summary = "根据国标id(20位) 删除指定设备") + @JsonMapping(value = "/delete/gbDeviceId",method = {RequestMethod.GET,RequestMethod.DELETE}) + public JsonResponse deleteByGbDeviceId(@RequestParam String gbDeviceId){ + WvpProxyDevice wvpProxyDevice = new WvpProxyDevice(); + wvpProxyDevice.setGbDeviceId(gbDeviceId); + return JsonResponse.success(deviceService.deleteDevice(wvpProxyDevice)); + } + + @Operation(summary = "根据主键 id 删除指定设备") + @JsonMapping(value = "/delete/id",method = {RequestMethod.GET,RequestMethod.DELETE}) + public JsonResponse deleteByGbDeviceId(@RequestParam Long id){ + WvpProxyDevice wvpProxyDevice = new WvpProxyDevice(); + wvpProxyDevice.setId(id); + return JsonResponse.success(deviceService.deleteDevice(wvpProxyDevice)); + } } diff --git a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/device/DeviceService.java b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/device/DeviceService.java index 0d522e2..e0ea765 100644 --- a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/device/DeviceService.java +++ b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/device/DeviceService.java @@ -75,7 +75,7 @@ public class DeviceService { * @param device 设备 * @return 是否成功 */ - public boolean updateDevice(WvpProxyDevice device){ + public boolean deleteDevice(WvpProxyDevice device){ if(device == null){ return false; } @@ -84,11 +84,11 @@ public class DeviceService { String deviceCode = device.getDeviceCode(); String gbDeviceId = device.getGbDeviceId(); if(id != null){ - return deviceMapper.updateByPrimaryKey(device) > 0; + return deviceMapper.deleteByPrimaryKey(id) > 0; } else if(StringUtils.isNotBlank(deviceCode)){ return deviceMapper.delete(d->d.where(WvpProxyDeviceDynamicSqlSupport.deviceCode,isEqualTo(deviceCode))) > 0; } else if(StringUtils.isNotBlank(gbDeviceId)){ - return deviceMapper.delete(d->d.where(WvpProxyDeviceDynamicSqlSupport.gbDeviceId,isEqualTo(deviceCode))) > 0; + return deviceMapper.delete(d->d.where(WvpProxyDeviceDynamicSqlSupport.gbDeviceId,isEqualTo(gbDeviceId))) > 0; } else { return false; }