规范化api, 进行中。。。

This commit is contained in:
panlinlin 2021-04-09 17:59:38 +08:00
parent 2310087e03
commit f10a9238dc
12 changed files with 113 additions and 43 deletions

View File

@ -12,6 +12,10 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.github.pagehelper.util.StringUtil; import com.github.pagehelper.util.StringUtil;
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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -25,9 +29,13 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
/**
* 位置信息管理
*/
@Api(tags = "位置信息管理")
@CrossOrigin @CrossOrigin
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api/position")
public class MobilePositionController { public class MobilePositionController {
private final static Logger logger = LoggerFactory.getLogger(MobilePositionController.class); private final static Logger logger = LoggerFactory.getLogger(MobilePositionController.class);
@ -41,7 +49,20 @@ public class MobilePositionController {
@Autowired @Autowired
private DeferredResultHolder resultHolder; private DeferredResultHolder resultHolder;
@GetMapping("/positions/{deviceId}/history") /**
* 查询历史轨迹
* @param deviceId 设备ID
* @param start 开始时间
* @param end 结束时间
* @return
*/
@ApiOperation("查询历史轨迹")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true),
@ApiImplicitParam(name = "start", value = "开始时间", required = true),
@ApiImplicitParam(name = "end", value = "结束时间", required = true),
})
@GetMapping("/history/{deviceId}")
public ResponseEntity<List<MobilePosition>> positions(@PathVariable String deviceId, public ResponseEntity<List<MobilePosition>> positions(@PathVariable String deviceId,
@RequestParam(required = false) String start, @RequestParam(required = false) String start,
@RequestParam(required = false) String end) { @RequestParam(required = false) String end) {
@ -60,7 +81,16 @@ public class MobilePositionController {
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@GetMapping("/positions/{deviceId}/latest") /**
* 查询设备最新位置
* @param deviceId 设备ID
* @return
*/
@ApiOperation("查询设备最新位置")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true),
})
@GetMapping("/latest/{deviceId}")
public ResponseEntity<MobilePosition> latestPosition(@PathVariable String deviceId) { public ResponseEntity<MobilePosition> latestPosition(@PathVariable String deviceId) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("查询设备" + deviceId + "的最新位置"); logger.debug("查询设备" + deviceId + "的最新位置");
@ -69,7 +99,16 @@ public class MobilePositionController {
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@GetMapping("/positions/{deviceId}/realtime") /**
* 获取移动位置信息
* @param deviceId 设备ID
* @return
*/
@ApiOperation("获取移动位置信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true),
})
@GetMapping("/realtime/{deviceId}")
public DeferredResult<ResponseEntity<MobilePosition>> realTimePosition(@PathVariable String deviceId) { public DeferredResult<ResponseEntity<MobilePosition>> realTimePosition(@PathVariable String deviceId) {
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
cmder.mobilePostitionQuery(device, event -> { cmder.mobilePostitionQuery(device, event -> {
@ -92,7 +131,20 @@ public class MobilePositionController {
return result; return result;
} }
@GetMapping("/positions/{deviceId}/subscribe") /**
* 订阅位置信息
* @param deviceId 设备ID
* @param expires 订阅超时时间
* @param interval 上报时间间隔
* @return true = 命令发送成功
*/
@ApiOperation("订阅位置信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true),
@ApiImplicitParam(name = "expires", value = "订阅超时时间"),
@ApiImplicitParam(name = "interval", value = "上报时间间隔"),
})
@GetMapping("/subscribe/{deviceId}")
public ResponseEntity<String> positionSubscribe(@PathVariable String deviceId, public ResponseEntity<String> positionSubscribe(@PathVariable String deviceId,
@RequestParam String expires, @RequestParam String expires,
@RequestParam String interval) { @RequestParam String interval) {

View File

@ -75,15 +75,12 @@ public class GbStreamController {
* @return * @return
*/ */
@ApiOperation("保存国标关联") @ApiOperation("保存国标关联")
// @ApiImplicitParams({ @ApiImplicitParams({
// @ApiImplicitParam(name = "app", value = "视频流应用名", required = true ), @ApiImplicitParam(name = "gbStreamParam", value = "GbStreamParam", required = true ),
// @ApiImplicitParam(name = "gbId", value = "国标ID", required = true ), })
// })
@PostMapping(value = "/add") @PostMapping(value = "/add")
@ResponseBody @ResponseBody
public Object add(@RequestBody GbStreamParam gbStreamParam){ public Object add(@RequestBody GbStreamParam gbStreamParam){
System.out.println(3333);
System.out.println(gbStreamParam.getGbStreams().size());
if (gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId())) { if (gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId())) {
return "success"; return "success";
}else { }else {

View File

@ -9,6 +9,10 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -16,6 +20,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@Api(tags = "媒体流相关")
@Controller @Controller
@CrossOrigin @CrossOrigin
@RequestMapping(value = "/api/media") @RequestMapping(value = "/api/media")
@ -33,8 +38,17 @@ public class MediaController {
private IMediaService mediaService; private IMediaService mediaService;
/**
* 根据应用名和流id获取播放地址
* @param app 应用名
* @param stream 流id
* @return
*/
@ApiOperation("根据应用名和流id获取播放地址")
@ApiImplicitParams({
@ApiImplicitParam(name = "app", value = "应用名"),
@ApiImplicitParam(name = "stream", value = "流id"),
})
@RequestMapping(value = "/getStreamInfoByAppAndStream") @RequestMapping(value = "/getStreamInfoByAppAndStream")
@ResponseBody @ResponseBody
public StreamInfo getStreamInfoByAppAndStream(String app, String stream){ public StreamInfo getStreamInfoByAppAndStream(String app, String stream){

View File

@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
import com.genersoft.iot.vmp.vmanager.platform.bean.UpdateChannelParam; import com.genersoft.iot.vmp.vmanager.platform.bean.UpdateChannelParam;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -17,9 +18,13 @@ import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
/**
* 级联平台管理
*/
@Api("级联平台管理")
@CrossOrigin @CrossOrigin
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api/platform")
public class PlatformController { public class PlatformController {
private final static Logger logger = LoggerFactory.getLogger(PlatformController.class); private final static Logger logger = LoggerFactory.getLogger(PlatformController.class);
@ -36,7 +41,7 @@ public class PlatformController {
@Autowired @Autowired
private SipConfig sipConfig; private SipConfig sipConfig;
@GetMapping("/platforms/serverconfig") @GetMapping("/server_config")
public ResponseEntity<JSONObject> serverConfig() { public ResponseEntity<JSONObject> serverConfig() {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("deviceIp", sipConfig.getSipIp()); result.put("deviceIp", sipConfig.getSipIp());
@ -46,7 +51,7 @@ public class PlatformController {
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@GetMapping("/platforms/{count}/{page}") @GetMapping("/query/{count}/{page}")
public PageInfo<ParentPlatform> platforms(@PathVariable int page, @PathVariable int count){ public PageInfo<ParentPlatform> platforms(@PathVariable int page, @PathVariable int count){
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
@ -55,7 +60,7 @@ public class PlatformController {
return storager.queryParentPlatformList(page, count); return storager.queryParentPlatformList(page, count);
} }
@RequestMapping("/platforms/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public ResponseEntity<String> savePlatform(@RequestBody ParentPlatform parentPlatform){ public ResponseEntity<String> savePlatform(@RequestBody ParentPlatform parentPlatform){
@ -98,18 +103,19 @@ public class PlatformController {
} }
} }
@RequestMapping("/platforms/delete") @DeleteMapping("/delete/{serverGBId}")
@ResponseBody @ResponseBody
public ResponseEntity<String> deletePlatform(@RequestBody ParentPlatform parentPlatform){ public ResponseEntity<String> deletePlatform(@PathVariable String serverGBId){
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("删除上级平台API调用"); logger.debug("删除上级平台API调用");
} }
if (StringUtils.isEmpty(parentPlatform.getServerGBId()) if (StringUtils.isEmpty(serverGBId)
){ ){
return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST); return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST);
} }
ParentPlatform parentPlatform = storager.queryParentPlatById(serverGBId);
if (parentPlatform == null) return new ResponseEntity<>("fail", HttpStatus.OK);
// 发送离线消息,无论是否成功都删除缓存 // 发送离线消息,无论是否成功都删除缓存
commanderForPlatform.unregister(parentPlatform, (event -> { commanderForPlatform.unregister(parentPlatform, (event -> {
// 清空redis缓存 // 清空redis缓存
@ -133,7 +139,7 @@ public class PlatformController {
} }
} }
@RequestMapping("/platforms/exit/{deviceGbId}") @GetMapping("/exit/{deviceGbId}")
@ResponseBody @ResponseBody
public ResponseEntity<String> exitPlatform(@PathVariable String deviceGbId){ public ResponseEntity<String> exitPlatform(@PathVariable String deviceGbId){
@ -144,7 +150,7 @@ public class PlatformController {
return new ResponseEntity<>(String.valueOf(parentPlatform != null), HttpStatus.OK); return new ResponseEntity<>(String.valueOf(parentPlatform != null), HttpStatus.OK);
} }
@RequestMapping("/platforms/channelList") @GetMapping("/channel_list")
@ResponseBody @ResponseBody
public PageInfo<ChannelReduce> channelList(int page, int count, public PageInfo<ChannelReduce> channelList(int page, int count,
@RequestParam(required = false) String platformId, @RequestParam(required = false) String platformId,
@ -167,7 +173,7 @@ public class PlatformController {
} }
@RequestMapping("/platforms/updateChannelForGB") @PostMapping("/update_channel_for_gb")
@ResponseBody @ResponseBody
public ResponseEntity<String> updateChannelForGB(@RequestBody UpdateChannelParam param){ public ResponseEntity<String> updateChannelForGB(@RequestBody UpdateChannelParam param){
@ -179,7 +185,7 @@ public class PlatformController {
return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK); return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
} }
@RequestMapping("/platforms/delChannelForGB") @DeleteMapping("/del_channel_for_gb")
@ResponseBody @ResponseBody
public ResponseEntity<String> delChannelForGB(@RequestBody UpdateChannelParam param){ public ResponseEntity<String> delChannelForGB(@RequestBody UpdateChannelParam param){

View File

@ -121,7 +121,7 @@ export default {
}, },
deletePlatformCommit: function(platform) { deletePlatformCommit: function(platform) {
var that = this; var that = this;
that.$axios.post(`/api/platforms/delete`, platform) that.$axios.delete(`/api/platform/delete/${platform.serverGBId}`)
.then(function (res) { .then(function (res) {
if (res.data == "success") { if (res.data == "success") {
that.$message({ that.$message({
@ -155,7 +155,7 @@ export default {
getPlatformList: function() { getPlatformList: function() {
let that = this; let that = this;
this.$axios.get(`/api/platforms/${that.count}/${that.currentPage}`) this.$axios.get(`/api/platform/query/${that.count}/${that.currentPage}`)
.then(function (res) { .then(function (res) {
that.total = res.data.total; that.total = res.data.total;
that.platformList = res.data.list; that.platformList = res.data.list;

View File

@ -171,7 +171,7 @@ export default {
this.endTime = null; this.endTime = null;
} }
let self = this; let self = this;
this.$axios.get(`/api/positions/${this.deviceId}/history`, { this.$axios.get(`/api/position/history/${this.deviceId}`, {
params: { params: {
start: self.startTime, start: self.startTime,
end: self.endTime, end: self.endTime,
@ -202,7 +202,7 @@ export default {
this.mapPointList = []; this.mapPointList = [];
this.mobilePositionList = []; this.mobilePositionList = [];
let self = this; let self = this;
this.$axios.get(`/api/positions/${this.deviceId}/latest`) this.$axios.get(`/api/position/latest/${this.deviceId}`)
.then(function (res) { .then(function (res) {
console.log(res.data); console.log(res.data);
self.total = res.data.length; self.total = res.data.length;
@ -226,7 +226,7 @@ export default {
}, },
subscribeMobilePosition: function() { subscribeMobilePosition: function() {
let self = this; let self = this;
this.$axios.get(`/api/positions/${this.deviceId}/subscribe`, { this.$axios.get(`/api/position/subscribe/${this.deviceId}`, {
params: { params: {
expires: self.expired, expires: self.expired,
interval: self.interval, interval: self.interval,
@ -241,7 +241,7 @@ export default {
}, },
unSubscribeMobilePosition: function() { unSubscribeMobilePosition: function() {
let self = this; let self = this;
this.$axios.get(`/api/positions/${this.deviceId}/subscribe`, { this.$axios.get(`/api/position/subscribe/${this.deviceId}`, {
params: { params: {
expires: 0, expires: 0,
interval: self.interval, interval: self.interval,

View File

@ -176,7 +176,7 @@ export default {
var result = false; var result = false;
var that = this; var that = this;
await that.$axios await that.$axios
.post(`/api/platforms/exit/${deviceGbId}`) .post(`/api/platform/exit/${deviceGbId}`)
.then(function (res) { .then(function (res) {
result = res.data; result = res.data;
}) })

View File

@ -119,7 +119,7 @@ export default {
var result = false; var result = false;
var that = this; var that = this;
await that.$axios await that.$axios
.post(`/api/platforms/exit/${deviceGbId}`) .post(`/api/platform/exit/${deviceGbId}`)
.then(function (res) { .then(function (res) {
result = res.data; result = res.data;
}) })

View File

@ -72,7 +72,7 @@ export default {
this.$axios({ this.$axios({
method:"post", method:"post",
url:"/api/platforms/updateChannelForGB", url:"/api/platform/update_channel_for_gb",
data:{ data:{
platformId: that.platformId, platformId: that.platformId,
channelReduces: that.chooseData channelReduces: that.chooseData

View File

@ -149,7 +149,7 @@ export default {
if (Object.keys(addData).length >0) { if (Object.keys(addData).length >0) {
that.$axios({ that.$axios({
method:"post", method:"post",
url:"/api/platforms/updateChannelForGB", url:"/api/platform/update_channel_for_gb",
data:{ data:{
platformId: that.platformId, platformId: that.platformId,
channelReduces: addData channelReduces: addData
@ -162,8 +162,8 @@ export default {
} }
if (Object.keys(delData).length >0) { if (Object.keys(delData).length >0) {
that.$axios({ that.$axios({
method:"post", method:"delete",
url:"/api/platforms/delChannelForGB", url:"/api/platform/del_channel_for_gb",
data:{ data:{
platformId: that.platformId, platformId: that.platformId,
channelReduces: delData channelReduces: delData
@ -182,7 +182,7 @@ export default {
getChannelList: function () { getChannelList: function () {
let that = this; let that = this;
this.$axios.get(`/api/platforms/channelList`, { this.$axios.get(`/api/platform/channel_list`, {
params: { params: {
page: that.currentPage, page: that.currentPage,
count: that.count, count: that.count,

View File

@ -142,7 +142,7 @@ export default {
if (Object.keys(delData).length >0) { if (Object.keys(delData).length >0) {
console.log(delData) console.log(delData)
that.$axios({ that.$axios({
method:"post", method:"delete",
url:"/api/gbStream/del", url:"/api/gbStream/del",
data:{ data:{
gbStreams: delData, gbStreams: delData,
@ -152,6 +152,7 @@ export default {
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
}); });
} }
}, },

View File

@ -164,7 +164,7 @@ export default {
openDialog: function (platform, callback) { openDialog: function (platform, callback) {
var that = this; var that = this;
this.$axios this.$axios
.get(`/api/platforms/serverconfig`) .get(`/api/platform/server_config`)
.then(function (res) { .then(function (res) {
console.log(res); console.log(res);
that.platform.deviceGBId = res.data.username; that.platform.deviceGBId = res.data.username;
@ -189,7 +189,7 @@ export default {
console.log("onSubmit"); console.log("onSubmit");
var that = this; var that = this;
that.$axios that.$axios
.post(`/api/platforms/save`, that.platform) .post(`/api/platform/save`, that.platform)
.then(function (res) { .then(function (res) {
console.log(res); console.log(res);
console.log(res.data == "success"); console.log(res.data == "success");
@ -219,7 +219,7 @@ export default {
var result = false; var result = false;
var that = this; var that = this;
await that.$axios await that.$axios
.post(`/api/platforms/exit/${deviceGbId}`) .post(`/api/platform/exit/${deviceGbId}`)
.then(function (res) { .then(function (res) {
result = res.data; result = res.data;
}) })