From 6ecd801c2365feb4e65f6684065aa97f11615797 Mon Sep 17 00:00:00 2001 From: songww <songww@inspur.com> Date: 星期三, 13 五月 2020 20:38:32 +0800 Subject: [PATCH] 增加设备删除接口,只允许删除离线设备;增加视频停止播放接口 --- src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java index 3115933..60b48b1 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java @@ -14,7 +14,9 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.context.request.async.DeferredResult; +import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; @@ -33,6 +35,9 @@ @Autowired private DeferredResultHolder resultHolder; + + @Autowired + private DeviceOffLineDetector offLineDetector; @GetMapping("/devices/{deviceId}") public ResponseEntity<Device> devices(@PathVariable String deviceId){ @@ -69,4 +74,25 @@ resultHolder.put(DeferredResultHolder.CALLBACK_CMD_CATALOG+deviceId, result); return result; } + + @PostMapping("/devices/{deviceId}/delete") + public ResponseEntity<String> delete(@PathVariable String deviceId){ + + if (logger.isDebugEnabled()) { + logger.debug("璁惧淇℃伅鍒犻櫎API璋冪敤锛宒eviceId锛�" + deviceId); + } + + if (offLineDetector.isOnline(deviceId)) { + return new ResponseEntity<String>("涓嶅厑璁稿垹闄ゅ湪绾胯澶囷紒", HttpStatus.NOT_ACCEPTABLE); + } + boolean isSuccess = storager.delete(deviceId); + if (isSuccess) { + JSONObject json = new JSONObject(); + json.put("deviceId", deviceId); + return new ResponseEntity<>(json.toString(),HttpStatus.OK); + } else { + logger.warn("璁惧棰勮API璋冪敤澶辫触锛�"); + return new ResponseEntity<String>("璁惧棰勮API璋冪敤澶辫触锛�", HttpStatus.INTERNAL_SERVER_ERROR); + } + } } -- Gitblit v1.8.0