根据主键id 根据设备编码(21位) 国标设备id(20位) 删除指定设备
This commit is contained in:
parent
cd43cc9fa8
commit
d2d278ae76
@ -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<Boolean> 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<Boolean> 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<Boolean> deleteByGbDeviceId(@RequestParam Long id){
|
||||
WvpProxyDevice wvpProxyDevice = new WvpProxyDevice();
|
||||
wvpProxyDevice.setId(id);
|
||||
return JsonResponse.success(deviceService.deleteDevice(wvpProxyDevice));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user