From 2310087e03ebc785a3e67f6d85ab4166b6f05ca0 Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: 星期三, 07 四月 2021 18:35:13 +0800 Subject: [PATCH] 规范化api, 进行中。。。 --- web_src/src/components/DeviceList.vue | 7 src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java | 10 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 2 src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceConfig.java | 46 +++++- src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java | 2 src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceQuery.java | 131 ++++++++++++++++- pom.xml | 13 - src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java | 6 src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java | 41 +++++ web_src/src/components/channelList.vue | 10 src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java | 43 +++++ web_src/src/components/dialog/devicePlayer.vue | 8 src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceControl.java | 70 +++++++-- src/main/resources/application-dev.yml | 8 + 14 files changed, 321 insertions(+), 76 deletions(-) diff --git a/pom.xml b/pom.xml index c2f5d82..dda226d 100644 --- a/pom.xml +++ b/pom.xml @@ -102,18 +102,15 @@ <!-- <version>3.11</version>--> <!-- </dependency>--> - <!--Swagger2 --> + <!--Swagger3 --> <!--鍦ㄧ嚎鏂囨。 --> <dependency> <groupId>io.springfox</groupId> - <artifactId>springfox-swagger2</artifactId> - <version>2.9.2</version> + <artifactId>springfox-boot-starter</artifactId> + <version>3.0.0</version> </dependency> - <dependency> - <groupId>io.springfox</groupId> - <artifactId>springfox-swagger-ui</artifactId> - <version>2.6.1</version> - </dependency> + + <!--鍙傛暟鏍¢獙 --> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> diff --git a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java index d237b16..89de84e 100644 --- a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java +++ b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java @@ -5,8 +5,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; +import springfox.documentation.oas.annotations.EnableOpenApi; @SpringBootApplication +@EnableOpenApi public class VManageBootstrap extends LogManager { private static String[] args; private static ConfigurableApplicationContext context; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java b/src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java new file mode 100644 index 0000000..70be188 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java @@ -0,0 +1,41 @@ +package com.genersoft.iot.vmp.conf; + +import io.swagger.annotations.ApiOperation; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.builders.RequestParameterBuilder; +import springfox.documentation.schema.ScalarType; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; + +import java.util.ArrayList; +import java.util.List; + +@Configuration +public class Swagger3Config { + + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.OAS_30) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager")) + .paths(PathSelectors.any()) + .build() + .pathMapping("/"); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("WVP-PRO 鎺ュ彛鏂囨。") + .description("鏇村璇峰挩璇㈡湇鍔″紑鍙戣��(18010473990@@163.com)銆�") + .contact(new Contact("Ray銆�", "http://www.ruiyeclub.cn", "ruiyeclub@foxmail.com")) + .version("1.0") + .build(); + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 579e168..27402ba 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -341,7 +341,7 @@ @Override public void playStreamCmd(Device device, String channelId, ZLMHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent) { try { - + if (device == null) return; String ssrc = streamSession.createPlaySsrc(); String streamId = null; if (rtpEnable) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceConfig.java b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceConfig.java index d046c0d..a988550 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceConfig.java @@ -17,16 +17,22 @@ import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpRequest; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.async.DeferredResult; +@Api(tags = "鍥芥爣璁惧閰嶇疆") @CrossOrigin @RestController -@RequestMapping("/api") +@RequestMapping("/api/device/config") public class DeviceConfig { private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class); @@ -42,14 +48,24 @@ /** * 鐪嬪畧浣嶆帶鍒跺懡浠PI鎺ュ彛 - * - * @param deviceId - * @param enabled 鐪嬪畧浣嶄娇鑳�1:寮�鍚�,0:鍏抽棴 - * @param resetTime 鑷姩褰掍綅鏃堕棿闂撮殧锛堝彲閫夛級 - * @param presetIndex 璋冪敤棰勭疆浣嶇紪鍙凤紙鍙�夛級 - * @param channelId 閫氶亾缂栫爜锛堝彲閫夛級 + * @param deviceId 璁惧ID + * @param channelId 閫氶亾ID + * @param name 鍚嶇О + * @param expiration 鍒版湡鏃堕棿 + * @param heartBeatInterval 蹇冭烦闂撮殧 + * @param heartBeatCount 蹇冭烦璁℃暟 + * @return */ - @GetMapping("/config/{deviceId}/basicParam") + @ApiOperation("鐪嬪畧浣嶆帶鍒跺懡浠�") + @GetMapping("/basicParam/{deviceId}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value ="璁惧ID" ), + @ApiImplicitParam(name = "channelId", value ="閫氶亾ID" ), + @ApiImplicitParam(name = "name", value ="鍚嶇О" ), + @ApiImplicitParam(name = "expiration", value ="鍒版湡鏃堕棿" ), + @ApiImplicitParam(name = "heartBeatInterval", value ="蹇冭烦闂撮殧" ), + @ApiImplicitParam(name = "heartBeatCount", value ="蹇冭烦璁℃暟" ), + }) public DeferredResult<ResponseEntity<String>> homePositionApi(@PathVariable String deviceId, @RequestParam(required = false) String channelId, @RequestParam(required = false) String name, @@ -86,10 +102,18 @@ /** * 璁惧閰嶇疆鏌ヨ璇锋眰API鎺ュ彛 - * - * @param deviceId + * @param deviceId 璁惧ID + * @param configType 閰嶇疆绫诲瀷 + * @param channelId 閫氶亾ID + * @return */ - @GetMapping("/config/{deviceId}/query/{configType}") + @ApiOperation("璁惧閰嶇疆鏌ヨ璇锋眰") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value ="璁惧ID" ), + @ApiImplicitParam(name = "channelId", value ="閫氶亾ID" ), + @ApiImplicitParam(name = "configType", value ="閰嶇疆绫诲瀷" ), + }) + @GetMapping("/query/{deviceId}/{configType}") public DeferredResult<ResponseEntity<String>> configDownloadApi(@PathVariable String deviceId, @PathVariable String configType, @RequestParam(required = false) String channelId) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceControl.java b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceControl.java index 7221359..ae517af 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceControl.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceControl.java @@ -17,6 +17,10 @@ import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -25,9 +29,10 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.async.DeferredResult; +@Api(tags = "鍥芥爣璁惧鎺у埗") @CrossOrigin @RestController -@RequestMapping("/api") +@RequestMapping("/api/device/control") public class DeviceControl { private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class); @@ -44,10 +49,13 @@ /** * 杩滅▼鍚姩鎺у埗鍛戒护API鎺ュ彛 * - * @param deviceId + * @param deviceId 璁惧ID */ - @GetMapping("/control/{deviceId}/teleboot") - @PostMapping("/control/{deviceId}/teleboot") + @ApiOperation("杩滅▼鍚姩鎺у埗鍛戒护") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value ="璁惧ID", required = true), + }) + @GetMapping("/teleboot/{deviceId}") public ResponseEntity<String> teleBootApi(@PathVariable String deviceId) { if (logger.isDebugEnabled()) { logger.debug("璁惧杩滅▼鍚姩API璋冪敤"); @@ -68,11 +76,18 @@ /** * 褰曞儚鎺у埗鍛戒护API鎺ュ彛 * - * @param deviceId + * @param deviceId 璁惧ID * @param recordCmdStr Record锛氭墜鍔ㄥ綍鍍忥紝StopRecord锛氬仠姝㈡墜鍔ㄥ綍鍍� * @param channelId 閫氶亾缂栫爜锛堝彲閫夛級 */ - @GetMapping("/control/{deviceId}/record/{recordCmdStr}") + @ApiOperation("褰曞儚鎺у埗鍛戒护") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value ="璁惧ID", required = true), + @ApiImplicitParam(name = "channelId", value ="閫氶亾缂栫爜"), + @ApiImplicitParam(name = "recordCmdStr", value ="鍛戒护锛� 鍙�夊�硷細Record锛堟墜鍔ㄥ綍鍍忥級锛孲topRecord锛堝仠姝㈡墜鍔ㄥ綍鍍忥級", + required = true), + }) + @GetMapping("/record/{deviceId}/{recordCmdStr}") public DeferredResult<ResponseEntity<String>> recordApi(@PathVariable String deviceId, @PathVariable String recordCmdStr, @RequestParam(required = false) String channelId) { if (logger.isDebugEnabled()) { @@ -102,10 +117,15 @@ /** * 鎶ヨ甯冮槻/鎾ら槻鍛戒护API鎺ュ彛 * - * @param deviceId + * @param deviceId 璁惧ID * @param guardCmdStr SetGuard锛氬竷闃诧紝ResetGuard锛氭挙闃� */ - @GetMapping("/control/{deviceId}/guard/{guardCmdStr}") + @ApiOperation("褰曞儚鎺у埗鍛戒护") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value = "璁惧ID", required = true), + @ApiImplicitParam(name = "guardCmdStr", value ="鍛戒护锛� 鍙�夊�硷細SetGuard锛堝竷闃诧級锛孯esetGuard锛堟挙闃诧級", required = true) + }) + @GetMapping("/guard/{deviceId}/{guardCmdStr}") public DeferredResult<ResponseEntity<String>> guardApi(@PathVariable String deviceId, @PathVariable String guardCmdStr) { if (logger.isDebugEnabled()) { logger.debug("甯冮槻/鎾ら槻API璋冪敤"); @@ -134,11 +154,17 @@ /** * 鎶ヨ澶嶄綅API鎺ュ彛 * - * @param deviceId + * @param deviceId 璁惧ID * @param alarmMethod 鎶ヨ鏂瑰紡锛堝彲閫夛級 * @param alarmType 鎶ヨ绫诲瀷锛堝彲閫夛級 */ - @GetMapping("/control/{deviceId}/resetAlarm") + @ApiOperation("鎶ヨ澶嶄綅") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value = "璁惧ID", required = true), + @ApiImplicitParam(name = "alarmMethod", value ="鎶ヨ鏂瑰紡"), + @ApiImplicitParam(name = "alarmType", value ="鎶ヨ绫诲瀷"), + }) + @GetMapping("/reset_alarm/{deviceId}") public DeferredResult<ResponseEntity<String>> resetAlarmApi(@PathVariable String deviceId, @RequestParam(required = false) String alarmMethod, @RequestParam(required = false) String alarmType) { @@ -169,11 +195,15 @@ /** * 寮哄埗鍏抽敭甯PI鎺ュ彛 * - * @param deviceId - * @param channelId + * @param deviceId 璁惧ID + * @param channelId 閫氶亾ID */ - @GetMapping("/control/{deviceId}/iFrame") - @PostMapping("/control/{deviceId}/iFrame") + @ApiOperation("寮哄埗鍏抽敭甯�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value = "璁惧ID", required = true), + @ApiImplicitParam(name = "channelId", value ="閫氶亾ID", required = true), + }) + @GetMapping("/i_frame/{deviceId}") public ResponseEntity<String> iFrame(@PathVariable String deviceId, @RequestParam(required = false) String channelId) { if (logger.isDebugEnabled()) { @@ -196,13 +226,21 @@ /** * 鐪嬪畧浣嶆帶鍒跺懡浠PI鎺ュ彛 * - * @param deviceId + * @param deviceId 璁惧ID * @param enabled 鐪嬪畧浣嶄娇鑳�1:寮�鍚�,0:鍏抽棴 * @param resetTime 鑷姩褰掍綅鏃堕棿闂撮殧锛堝彲閫夛級 * @param presetIndex 璋冪敤棰勭疆浣嶇紪鍙凤紙鍙�夛級 * @param channelId 閫氶亾缂栫爜锛堝彲閫夛級 */ - @GetMapping("/control/{deviceId}/homePosition/{enabled}") + @ApiOperation("鐪嬪畧浣嶆帶鍒�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceId", value = "璁惧ID", required = true), + @ApiImplicitParam(name = "enabled", value = "鏄惁寮�鍚湅瀹堜綅 1:寮�鍚�,0:鍏抽棴", required = true), + @ApiImplicitParam(name = "resetTime", value = "鑷姩褰掍綅鏃堕棿闂撮殧"), + @ApiImplicitParam(name = "presetIndex", value = "璋冪敤棰勭疆浣嶇紪鍙�"), + @ApiImplicitParam(name = "channelId", value ="閫氶亾ID"), + }) + @GetMapping("/home_position/{deviceId}/{enabled}") public DeferredResult<ResponseEntity<String>> homePositionApi(@PathVariable String deviceId, @PathVariable String enabled, @RequestParam(required = false) String resetTime, 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, diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java index 787a094..c61b62f 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java @@ -5,11 +5,16 @@ import com.genersoft.iot.vmp.vmanager.gbStream.bean.GbStreamParam; import com.genersoft.iot.vmp.service.IGbStreamService; import com.github.pagehelper.PageInfo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +@Api(tags = "瑙嗛娴佸叧鑱斿埌绾ц仈骞冲彴") @CrossOrigin @RestController @RequestMapping("/api/gbStream") @@ -24,7 +29,18 @@ private IVideoManagerStorager storager; - @RequestMapping(value = "/list") + /** + * 鏌ヨ鍥芥爣閫氶亾 + * @param page 褰撳墠椤� + * @param count 姣忛〉鏉℃暟 + * @return + */ + @ApiOperation("鏌ヨ鍥芥爣閫氶亾") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "褰撳墠椤�", required = true ), + @ApiImplicitParam(name = "count", value = "姣忛〉鏉℃暟", required = true ), + }) + @GetMapping(value = "/list") @ResponseBody public PageInfo<GbStream> list(@RequestParam(required = false)Integer page, @RequestParam(required = false)Integer count){ @@ -33,11 +49,18 @@ } - @RequestMapping(value = "/del") + /** + * 绉婚櫎鍥芥爣鍏宠仈 + * @param gbStreamParam + * @return + */ + @ApiOperation("绉婚櫎鍥芥爣鍏宠仈") + @ApiImplicitParams({ + @ApiImplicitParam(name = "gbStreamParam", value = "GbStreamParam", required = true ), + }) + @DeleteMapping(value = "/del") @ResponseBody public Object del(@RequestBody GbStreamParam gbStreamParam){ - System.out.println(2222); - System.out.println(gbStreamParam.getGbStreams().size()); if (gbStreamService.delPlatformInfo(gbStreamParam.getGbStreams())) { return "success"; }else { @@ -46,7 +69,17 @@ } - @RequestMapping(value = "/add") + /** + * 淇濆瓨鍥芥爣鍏宠仈 + * @param gbStreamParam + * @return + */ + @ApiOperation("淇濆瓨鍥芥爣鍏宠仈") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "app", value = "瑙嗛娴佸簲鐢ㄥ悕", required = true ), +// @ApiImplicitParam(name = "gbId", value = "鍥芥爣ID", required = true ), +// }) + @PostMapping(value = "/add") @ResponseBody public Object add(@RequestBody GbStreamParam gbStreamParam){ System.out.println(3333); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java index d104b85..df16dd8 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java @@ -33,7 +33,7 @@ @CrossOrigin @RestController -@RequestMapping("/api") +@RequestMapping("/api/play") public class PlayController { private final static Logger logger = LoggerFactory.getLogger(PlayController.class); @@ -59,7 +59,7 @@ @Autowired private IMediaService mediaService; - @GetMapping("/play/{deviceId}/{channelId}") + @GetMapping("/start/{deviceId}/{channelId}") public DeferredResult<ResponseEntity<String>> play(@PathVariable String deviceId, @PathVariable String channelId) { @@ -79,7 +79,7 @@ return playResult.getResult(); } - @PostMapping("/play/{streamId}/stop") + @PostMapping("/stop/{streamId}") public DeferredResult<ResponseEntity<String>> playStop(@PathVariable String streamId) { logger.debug(String.format("璁惧棰勮/鍥炴斁鍋滄API璋冪敤锛宻treamId锛�%s", streamId)); @@ -139,7 +139,7 @@ * @param streamId 娴両D * @return */ - @PostMapping("/play/{streamId}/convert") + @PostMapping("/convert/{streamId}") public ResponseEntity<String> playConvert(@PathVariable String streamId) { StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId); if (streamInfo == null) { @@ -179,7 +179,7 @@ * @param key * @return */ - @PostMapping("/play/convert/stop/{key}") + @PostMapping("/convertStop/{key}") public ResponseEntity<String> playConvertStop(@PathVariable String key) { JSONObject jsonObject = zlmresTfulUtils.delFFmpegSource(key); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java index 9ce2672..e816562 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java @@ -28,7 +28,7 @@ @CrossOrigin @RestController -@RequestMapping("/api") +@RequestMapping("/api/playback") public class PlaybackController { private final static Logger logger = LoggerFactory.getLogger(PlaybackController.class); @@ -51,7 +51,7 @@ @Autowired private DeferredResultHolder resultHolder; - @GetMapping("/playback/{deviceId}/{channelId}") + @GetMapping("/start/{deviceId}/{channelId}") public DeferredResult<ResponseEntity<String>> play(@PathVariable String deviceId, @PathVariable String channelId, String startTime, String endTime) { @@ -89,7 +89,7 @@ return result; } - @RequestMapping("/playback/{ssrc}/stop") + @RequestMapping("/stop/{ssrc}") public ResponseEntity<String> playStop(@PathVariable String ssrc) { cmder.streamByeCmd(ssrc); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index e45bfb5..d4abf20 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -96,4 +96,10 @@ # [鏍规嵁涓氬姟闇�姹傞厤缃甝 userSettings: # 淇濆瓨绉诲姩浣嶇疆鍘嗗彶杞ㄨ抗锛歵rue:淇濈暀鍘嗗彶鏁版嵁锛宖alse:浠呬繚鐣欐渶鍚庣殑浣嶇疆(榛樿) - savePositionHistory: false \ No newline at end of file + savePositionHistory: false + +# 鍦ㄧ嚎鏂囨。锛� swagger-ui锛堢敓浜х幆澧冨缓璁叧闂級 +springfox: + documentation: + swagger-ui: + enabled: true \ No newline at end of file diff --git a/web_src/src/components/DeviceList.vue b/web_src/src/components/DeviceList.vue index 8a3f1c0..21e02aa 100644 --- a/web_src/src/components/DeviceList.vue +++ b/web_src/src/components/DeviceList.vue @@ -136,7 +136,7 @@ getDeviceList: function() { let that = this; this.getDeviceListLoading = true; - this.$axios.get(`/api/devices`,{ + this.$axios.get(`/api/device/query/devices`,{ params: { page: that.currentPage, count: that.count @@ -167,13 +167,12 @@ //gb28181骞冲彴瀵规帴 //鍒锋柊璁惧淇℃伅 refDevice: function(itemData) { - ///api/devices/{deviceId}/sync console.log("鍒锋柊瀵瑰簲璁惧:" + itemData.deviceId); var that = this; that.$refs[itemData.deviceId + 'refbtn' ].loading = true; this.$axios({ method: 'post', - url: '/api/devices/' + itemData.deviceId + '/sync' + url: '/api/device/query/devices/' + itemData.deviceId + '/sync' }).then(function(res) { console.log("鍒锋柊璁惧缁撴灉锛�"+JSON.stringify(res)); if (!res.data.deviceId) { @@ -217,7 +216,7 @@ let that = this; this.$axios({ method: 'get', - url: '/api/devices/' + row.deviceId + '/transport/' + row.streamMode + url: '/api/device/query/transport' + row.deviceId + '/' + row.streamMode }).then(function(res) { }).catch(function(e) { diff --git a/web_src/src/components/channelList.vue b/web_src/src/components/channelList.vue index b06ce25..ebb4318 100644 --- a/web_src/src/components/channelList.vue +++ b/web_src/src/components/channelList.vue @@ -154,7 +154,7 @@ getDeviceChannelList: function () { let that = this; - this.$axios.get(`/api/devices/${this.$route.params.deviceId}/channels`, { + this.$axios.get(`/api/device/query/devices/${this.$route.params.deviceId}/channels`, { params: { page: that.currentPage, count: that.count, @@ -188,7 +188,7 @@ let that = this; this.$axios({ method: 'get', - url: '/api/play/' + deviceId + '/' + channelId + url: '/api/play/start/' + deviceId + '/' + channelId }).then(function (res) { console.log(res.data) let streamId = res.data.streamId; @@ -216,7 +216,7 @@ var that = this; this.$axios({ method: 'post', - url: '/api/play/' + itemData.streamId + '/stop' + url: '/api/play/stop/' + itemData.streamId }).then(function (res) { console.log(JSON.stringify(res)); that.initData(); @@ -251,7 +251,7 @@ showSubchannels: function (channelId) { let that = this; - this.$axios.get(`/api/subChannels/${this.deviceId}/${this.parentChannelId}/channels`, { + this.$axios.get(`/api/device/query/sub_channels/${this.deviceId}/${this.parentChannelId}/channels`, { params: { page: that.currentPage, count: that.count, @@ -282,7 +282,7 @@ console.log(row) this.$axios({ method: 'post', - url: `/api/channel/update/${this.deviceId}`, + url: `/api/device/query/channel/update/${this.deviceId}`, params: row }).then(function (res) { console.log(JSON.stringify(res)); diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue index 6780095..2c5aa57 100644 --- a/web_src/src/components/dialog/devicePlayer.vue +++ b/web_src/src/components/dialog/devicePlayer.vue @@ -261,7 +261,7 @@ this.$refs.videoPlayer.pause() that.$axios({ method: 'post', - url: '/api/play/' + that.streamId + '/convert' + url: '/api/play/convert/' + that.streamId }).then(function (res) { if (res.data.code == 0) { that.convertKey = res.data.key; @@ -298,7 +298,7 @@ that.$refs.videoPlayer.pause() this.$axios({ method: 'post', - url: '/api/play/convert/stop/' + this.convertKey + url: '/api/play/convertStop/' + this.convertKey }).then(function (res) { if (res.data.code == 0) { console.log(res.data.msg) @@ -393,7 +393,7 @@ } else { this.$axios({ method: 'get', - url: '/api/playback/' + this.deviceId + '/' + this.channelId + '?startTime=' + row.startTime + '&endTime=' + + url: '/api/playback/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + row.startTime + '&endTime=' + row.endTime }).then(function (res) { var streamInfo = res.data; @@ -408,7 +408,7 @@ this.videoUrl = ''; this.$axios({ method: 'get', - url: '/api/playback/' + this.streamId + '/stop' + url: '/api/playback/stop/' + this.streamId }).then(function (res) { if (callback) callback() }); -- Gitblit v1.8.0