From 2310087e03ebc785a3e67f6d85ab4166b6f05ca0 Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: 星期三, 07 四月 2021 18:35:13 +0800 Subject: [PATCH] 规范化api, 进行中。。。 --- src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceQuery.java | 131 +++++++++++++++++++++++++++++++++++++++---- 1 files changed, 118 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceQuery.java index 997a43b..bded1b9 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceQuery.java @@ -3,6 +3,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.github.pagehelper.PageInfo; +import io.swagger.annotations.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -21,10 +22,11 @@ import javax.sip.message.Response; +@Api(tags = "鍥芥爣璁惧鏌ヨ1", value = "鍥芥爣璁惧鏌ヨ") @SuppressWarnings("rawtypes") @CrossOrigin @RestController -@RequestMapping("/api") +@RequestMapping("/api/device/query") public class DeviceQuery { private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class); @@ -40,7 +42,16 @@ @Autowired private DeviceOffLineDetector offLineDetector; - + + /** + * 浣跨敤ID鏌ヨ鍥芥爣璁惧 + * @param deviceId 鍥芥爣ID + * @return 鍥芥爣璁惧 + */ + @ApiOperation("浣跨敤ID鏌ヨ鍥芥爣璁惧") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value = "璁惧ID", required = true), + }) @GetMapping("/devices/{deviceId}") public ResponseEntity<Device> devices(@PathVariable String deviceId){ @@ -51,7 +62,18 @@ Device device = storager.queryVideoDevice(deviceId); return new ResponseEntity<>(device,HttpStatus.OK); } - + + /** + * 鍒嗛〉鏌ヨ鍥芥爣璁惧 + * @param page 褰撳墠椤� + * @param count 姣忛〉鏌ヨ鏁伴噺 + * @return 鍒嗛〉鍥芥爣鍒楄〃 + */ + @ApiOperation("鍒嗛〉鏌ヨ鍥芥爣璁惧") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "褰撳墠椤�", required = true), + @ApiImplicitParam(name = "count", value = "姣忛〉鏌ヨ鏁伴噺", required = true), + }) @GetMapping("/devices") public PageInfo<Device> devices(int page, int count){ @@ -73,7 +95,16 @@ * @param channelType 璁惧 false/瀛愮洰褰� true * @return 閫氶亾鍒楄〃 */ + @ApiOperation("鍒嗛〉鏌ヨ閫氶亾") @GetMapping("/devices/{deviceId}/channels") + @ApiImplicitParams({ + @ApiImplicitParam(name="deviceId", value = "璁惧id", required = true), + @ApiImplicitParam(name="page", value = "褰撳墠椤�", required = true), + @ApiImplicitParam(name="count", value = "姣忛〉鏌ヨ鏁伴噺", required = true), + @ApiImplicitParam(name="query", value = "鏌ヨ鍐呭"), + @ApiImplicitParam(name="online", value = "鏄惁鍦ㄧ嚎"), + @ApiImplicitParam(name="channelType", value = "璁惧/瀛愮洰褰�-> false/true"), + }) public ResponseEntity<PageInfo> channels(@PathVariable String deviceId, int page, int count, @RequestParam(required = false) String query, @@ -89,7 +120,16 @@ PageInfo pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, page, count); return new ResponseEntity<>(pageResult,HttpStatus.OK); } - + + /** + * 鍚屾璁惧閫氶亾 + * @param deviceId 璁惧id + * @return + */ + @ApiOperation("鍚屾璁惧閫氶亾") + @ApiImplicitParams({ + @ApiImplicitParam(name="deviceId", value = "璁惧id", required = true), + }) @PostMapping("/devices/{deviceId}/sync") public DeferredResult<ResponseEntity<Device>> devicesSync(@PathVariable String deviceId){ @@ -117,8 +157,17 @@ resultHolder.put(DeferredResultHolder.CALLBACK_CMD_CATALOG+deviceId, result); return result; } - - @PostMapping("/devices/{deviceId}/delete") + + /** + * 绉婚櫎璁惧 + * @param deviceId 璁惧id + * @return + */ + @ApiOperation("绉婚櫎璁惧") + @ApiImplicitParams({ + @ApiImplicitParam(name="deviceId", value = "璁惧id", required = true), + }) + @DeleteMapping("/devices/{deviceId}/delete") public ResponseEntity<String> delete(@PathVariable String deviceId){ if (logger.isDebugEnabled()) { @@ -140,13 +189,27 @@ } /** - * 鍒嗛〉鏌ヨ閫氶亾鏁� + * 鍒嗛〉鏌ヨ瀛愮洰褰曢�氶亾 + * @param deviceId 閫氶亾id * @param channelId 閫氶亾id * @param page 褰撳墠椤� * @param count 姣忛〉鏉℃暟 + * @param query 鏌ヨ鍐呭 + * @param online 鏄惁鍦ㄧ嚎 + * @param channelType 閫氶亾绫诲瀷 * @return 瀛愰�氶亾鍒楄〃 */ - @GetMapping("/subChannels/{deviceId}/{channelId}/channels") + @ApiOperation("鍒嗛〉鏌ヨ瀛愮洰褰曢�氶亾") + @ApiImplicitParams({ + @ApiImplicitParam(name="deviceId", value = "璁惧id", required = true), + @ApiImplicitParam(name="channelId", value = "閫氶亾id", required = true), + @ApiImplicitParam(name="page", value = "褰撳墠椤�", required = true), + @ApiImplicitParam(name="count", value = "姣忛〉鏉℃暟", required = true), + @ApiImplicitParam(name="query", value = "鏌ヨ鍐呭"), + @ApiImplicitParam(name="online", value = "鏄惁鍦ㄧ嚎"), + @ApiImplicitParam(name="channelType", value = "閫氶亾绫诲瀷锛� 瀛愮洰褰�"), + }) + @GetMapping("/sub_channels/{deviceId}/{channelId}/channels") public ResponseEntity<PageInfo> subChannels(@PathVariable String deviceId, @PathVariable String channelId, int page, @@ -168,14 +231,36 @@ return new ResponseEntity<>(pageResult,HttpStatus.OK); } + /** + * 鏇存柊閫氶亾淇℃伅 + * @param deviceId 璁惧id + * @param channel 閫氶亾 + * @return + */ + @ApiOperation("鏇存柊閫氶亾淇℃伅") + @ApiImplicitParams({ + @ApiImplicitParam(name="deviceId", value = "璁惧id", required = true), + @ApiImplicitParam(name="channel", value = "閫氶亾", required = true), + }) @PostMapping("/channel/update/{deviceId}") public ResponseEntity<PageInfo> updateChannel(@PathVariable String deviceId,DeviceChannel channel){ storager.updateChannel(deviceId, channel); return new ResponseEntity<>(null,HttpStatus.OK); } - @GetMapping("/devices/{deviceId}/transport/{streamMode}") - @PostMapping("/devices/{deviceId}/transport/{streamMode}") + /** + * 淇敼鏁版嵁娴佷紶杈撴ā寮� + * @param deviceId 璁惧id + * @param streamMode 鏁版嵁娴佷紶杈撴ā寮� + * @return + */ + @ApiOperation("淇敼鏁版嵁娴佷紶杈撴ā寮�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value = "璁惧id", required = true), + @ApiImplicitParam(name = "streamMode", value = "鏁版嵁娴佷紶杈撴ā寮�, 鍙栧�硷細" + + "UDP锛坲dp浼犺緭锛夛紝TCP-ACTIVE锛坱cp涓诲姩妯″紡,鏆備笉鏀寔锛夛紝TCP-PASSIVE锛坱cp琚姩妯″紡锛�"), + }) + @PostMapping("/transport/{deviceId}/{streamMode}") public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ Device device = storager.queryVideoDevice(deviceId); device.setStreamMode(streamMode); @@ -186,8 +271,12 @@ /** * 璁惧鐘舵�佹煡璇㈣姹侫PI鎺ュ彛 * - * @param deviceId + * @param deviceId 璁惧id */ + @ApiOperation("璁惧鐘舵�佹煡璇�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value = "璁惧id", required = true), + }) @GetMapping("/devices/{deviceId}/status") public DeferredResult<ResponseEntity<String>> deviceStatusApi(@PathVariable String deviceId) { if (logger.isDebugEnabled()) { @@ -216,9 +305,25 @@ /** * 璁惧鎶ヨ鏌ヨ璇锋眰API鎺ュ彛 - * - * @param deviceId + * @param deviceId 璁惧id + * @param startPriority 鎶ヨ璧峰绾у埆锛堝彲閫夛級 + * @param endPriority 鎶ヨ缁堟绾у埆锛堝彲閫夛級 + * @param alarmMethod 鎶ヨ鏂瑰紡鏉′欢锛堝彲閫夛級 + * @param alarmType 鎶ヨ绫诲瀷 + * @param startTime 鎶ヨ鍙戠敓璧峰鏃堕棿锛堝彲閫夛級 + * @param endTime 鎶ヨ鍙戠敓缁堟鏃堕棿锛堝彲閫夛級 + * @return true = 鍛戒护鍙戦�佹垚鍔� */ + @ApiOperation("璁惧鎶ヨ鏌ヨ") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value = "璁惧id", required = true), + @ApiImplicitParam(name = "startPriority", value = "鎶ヨ璧峰绾у埆"), + @ApiImplicitParam(name = "endPriority", value = "鎶ヨ缁堟绾у埆"), + @ApiImplicitParam(name = "alarmMethod", value = "鎶ヨ鏂瑰紡鏉′欢"), + @ApiImplicitParam(name = "alarmType", value = "鎶ヨ绫诲瀷"), + @ApiImplicitParam(name = "startTime", value = "鎶ヨ鍙戠敓璧峰鏃堕棿"), + @ApiImplicitParam(name = "endTime", value = "鎶ヨ鍙戠敓缁堟鏃堕棿"), + }) @GetMapping("/alarm/{deviceId}") public DeferredResult<ResponseEntity<String>> alarmApi(@PathVariable String deviceId, @RequestParam(required = false) String startPriority, -- Gitblit v1.8.0