Commit f10a9238dce358b197142564259d975358c48cb3

Authored by panlinlin
1 parent 2310087e

规范化api, 进行中。。。

src/main/java/com/genersoft/iot/vmp/vmanager/MobilePosition/MobilePositionController.java
... ... @@ -12,6 +12,10 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
12 12 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
13 13 import com.github.pagehelper.util.StringUtil;
14 14  
  15 +import io.swagger.annotations.Api;
  16 +import io.swagger.annotations.ApiImplicitParam;
  17 +import io.swagger.annotations.ApiImplicitParams;
  18 +import io.swagger.annotations.ApiOperation;
15 19 import org.slf4j.Logger;
16 20 import org.slf4j.LoggerFactory;
17 21 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -25,9 +29,13 @@ import org.springframework.web.bind.annotation.RequestParam;
25 29 import org.springframework.web.bind.annotation.RestController;
26 30 import org.springframework.web.context.request.async.DeferredResult;
27 31  
  32 +/**
  33 + * 位置信息管理
  34 + */
  35 +@Api(tags = "位置信息管理")
28 36 @CrossOrigin
29 37 @RestController
30   -@RequestMapping("/api")
  38 +@RequestMapping("/api/position")
31 39 public class MobilePositionController {
32 40  
33 41 private final static Logger logger = LoggerFactory.getLogger(MobilePositionController.class);
... ... @@ -40,8 +48,21 @@ public class MobilePositionController {
40 48  
41 49 @Autowired
42 50 private DeferredResultHolder resultHolder;
43   -
44   - @GetMapping("/positions/{deviceId}/history")
  51 +
  52 + /**
  53 + * 查询历史轨迹
  54 + * @param deviceId 设备ID
  55 + * @param start 开始时间
  56 + * @param end 结束时间
  57 + * @return
  58 + */
  59 + @ApiOperation("查询历史轨迹")
  60 + @ApiImplicitParams({
  61 + @ApiImplicitParam(name = "deviceId", value = "设备ID", required = true),
  62 + @ApiImplicitParam(name = "start", value = "开始时间", required = true),
  63 + @ApiImplicitParam(name = "end", value = "结束时间", required = true),
  64 + })
  65 + @GetMapping("/history/{deviceId}")
45 66 public ResponseEntity<List<MobilePosition>> positions(@PathVariable String deviceId,
46 67 @RequestParam(required = false) String start,
47 68 @RequestParam(required = false) String end) {
... ... @@ -60,7 +81,16 @@ public class MobilePositionController {
60 81 return new ResponseEntity<>(result, HttpStatus.OK);
61 82 }
62 83  
63   - @GetMapping("/positions/{deviceId}/latest")
  84 + /**
  85 + * 查询设备最新位置
  86 + * @param deviceId 设备ID
  87 + * @return
  88 + */
  89 + @ApiOperation("查询设备最新位置")
  90 + @ApiImplicitParams({
  91 + @ApiImplicitParam(name = "deviceId", value = "设备ID", required = true),
  92 + })
  93 + @GetMapping("/latest/{deviceId}")
64 94 public ResponseEntity<MobilePosition> latestPosition(@PathVariable String deviceId) {
65 95 if (logger.isDebugEnabled()) {
66 96 logger.debug("查询设备" + deviceId + "的最新位置");
... ... @@ -69,7 +99,16 @@ public class MobilePositionController {
69 99 return new ResponseEntity<>(result, HttpStatus.OK);
70 100 }
71 101  
72   - @GetMapping("/positions/{deviceId}/realtime")
  102 + /**
  103 + * 获取移动位置信息
  104 + * @param deviceId 设备ID
  105 + * @return
  106 + */
  107 + @ApiOperation("获取移动位置信息")
  108 + @ApiImplicitParams({
  109 + @ApiImplicitParam(name = "deviceId", value = "设备ID", required = true),
  110 + })
  111 + @GetMapping("/realtime/{deviceId}")
73 112 public DeferredResult<ResponseEntity<MobilePosition>> realTimePosition(@PathVariable String deviceId) {
74 113 Device device = storager.queryVideoDevice(deviceId);
75 114 cmder.mobilePostitionQuery(device, event -> {
... ... @@ -92,7 +131,20 @@ public class MobilePositionController {
92 131 return result;
93 132 }
94 133  
95   - @GetMapping("/positions/{deviceId}/subscribe")
  134 + /**
  135 + * 订阅位置信息
  136 + * @param deviceId 设备ID
  137 + * @param expires 订阅超时时间
  138 + * @param interval 上报时间间隔
  139 + * @return true = 命令发送成功
  140 + */
  141 + @ApiOperation("订阅位置信息")
  142 + @ApiImplicitParams({
  143 + @ApiImplicitParam(name = "deviceId", value = "设备ID", required = true),
  144 + @ApiImplicitParam(name = "expires", value = "订阅超时时间"),
  145 + @ApiImplicitParam(name = "interval", value = "上报时间间隔"),
  146 + })
  147 + @GetMapping("/subscribe/{deviceId}")
96 148 public ResponseEntity<String> positionSubscribe(@PathVariable String deviceId,
97 149 @RequestParam String expires,
98 150 @RequestParam String interval) {
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java
... ... @@ -75,15 +75,12 @@ public class GbStreamController {
75 75 * @return
76 76 */
77 77 @ApiOperation("保存国标关联")
78   -// @ApiImplicitParams({
79   -// @ApiImplicitParam(name = "app", value = "视频流应用名", required = true ),
80   -// @ApiImplicitParam(name = "gbId", value = "国标ID", required = true ),
81   -// })
  78 + @ApiImplicitParams({
  79 + @ApiImplicitParam(name = "gbStreamParam", value = "GbStreamParam", required = true ),
  80 + })
82 81 @PostMapping(value = "/add")
83 82 @ResponseBody
84 83 public Object add(@RequestBody GbStreamParam gbStreamParam){
85   - System.out.println(3333);
86   - System.out.println(gbStreamParam.getGbStreams().size());
87 84 if (gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId())) {
88 85 return "success";
89 86 }else {
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/media/MediaController.java
... ... @@ -9,6 +9,10 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
9 9 import com.genersoft.iot.vmp.service.IMediaService;
10 10 import com.genersoft.iot.vmp.service.IStreamProxyService;
11 11 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
  12 +import io.swagger.annotations.Api;
  13 +import io.swagger.annotations.ApiImplicitParam;
  14 +import io.swagger.annotations.ApiImplicitParams;
  15 +import io.swagger.annotations.ApiOperation;
12 16 import org.slf4j.Logger;
13 17 import org.slf4j.LoggerFactory;
14 18 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -16,6 +20,7 @@ import org.springframework.stereotype.Controller;
16 20 import org.springframework.web.bind.annotation.*;
17 21  
18 22  
  23 +@Api(tags = "媒体流相关")
19 24 @Controller
20 25 @CrossOrigin
21 26 @RequestMapping(value = "/api/media")
... ... @@ -33,8 +38,17 @@ public class MediaController {
33 38 private IMediaService mediaService;
34 39  
35 40  
36   -
37   -
  41 + /**
  42 + * 根据应用名和流id获取播放地址
  43 + * @param app 应用名
  44 + * @param stream 流id
  45 + * @return
  46 + */
  47 + @ApiOperation("根据应用名和流id获取播放地址")
  48 + @ApiImplicitParams({
  49 + @ApiImplicitParam(name = "app", value = "应用名"),
  50 + @ApiImplicitParam(name = "stream", value = "流id"),
  51 + })
38 52 @RequestMapping(value = "/getStreamInfoByAppAndStream")
39 53 @ResponseBody
40 54 public StreamInfo getStreamInfoByAppAndStream(String app, String stream){
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
... ... @@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
8 8 import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
9 9 import com.genersoft.iot.vmp.vmanager.platform.bean.UpdateChannelParam;
10 10 import com.github.pagehelper.PageInfo;
  11 +import io.swagger.annotations.Api;
11 12 import org.slf4j.Logger;
12 13 import org.slf4j.LoggerFactory;
13 14 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -17,9 +18,13 @@ import org.springframework.util.StringUtils;
17 18 import org.springframework.web.bind.annotation.*;
18 19 import com.genersoft.iot.vmp.conf.SipConfig;
19 20  
  21 +/**
  22 + * 级联平台管理
  23 + */
  24 +@Api("级联平台管理")
20 25 @CrossOrigin
21 26 @RestController
22   -@RequestMapping("/api")
  27 +@RequestMapping("/api/platform")
23 28 public class PlatformController {
24 29  
25 30 private final static Logger logger = LoggerFactory.getLogger(PlatformController.class);
... ... @@ -36,7 +41,7 @@ public class PlatformController {
36 41 @Autowired
37 42 private SipConfig sipConfig;
38 43  
39   - @GetMapping("/platforms/serverconfig")
  44 + @GetMapping("/server_config")
40 45 public ResponseEntity<JSONObject> serverConfig() {
41 46 JSONObject result = new JSONObject();
42 47 result.put("deviceIp", sipConfig.getSipIp());
... ... @@ -46,7 +51,7 @@ public class PlatformController {
46 51 return new ResponseEntity<>(result, HttpStatus.OK);
47 52 }
48 53  
49   - @GetMapping("/platforms/{count}/{page}")
  54 + @GetMapping("/query/{count}/{page}")
50 55 public PageInfo<ParentPlatform> platforms(@PathVariable int page, @PathVariable int count){
51 56  
52 57 if (logger.isDebugEnabled()) {
... ... @@ -55,7 +60,7 @@ public class PlatformController {
55 60 return storager.queryParentPlatformList(page, count);
56 61 }
57 62  
58   - @RequestMapping("/platforms/save")
  63 + @PostMapping("/save")
59 64 @ResponseBody
60 65 public ResponseEntity<String> savePlatform(@RequestBody ParentPlatform parentPlatform){
61 66  
... ... @@ -98,18 +103,19 @@ public class PlatformController {
98 103 }
99 104 }
100 105  
101   - @RequestMapping("/platforms/delete")
  106 + @DeleteMapping("/delete/{serverGBId}")
102 107 @ResponseBody
103   - public ResponseEntity<String> deletePlatform(@RequestBody ParentPlatform parentPlatform){
  108 + public ResponseEntity<String> deletePlatform(@PathVariable String serverGBId){
104 109  
105 110 if (logger.isDebugEnabled()) {
106 111 logger.debug("删除上级平台API调用");
107 112 }
108   - if (StringUtils.isEmpty(parentPlatform.getServerGBId())
  113 + if (StringUtils.isEmpty(serverGBId)
109 114 ){
110 115 return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST);
111 116 }
112   -
  117 + ParentPlatform parentPlatform = storager.queryParentPlatById(serverGBId);
  118 + if (parentPlatform == null) return new ResponseEntity<>("fail", HttpStatus.OK);
113 119 // 发送离线消息,无论是否成功都删除缓存
114 120 commanderForPlatform.unregister(parentPlatform, (event -> {
115 121 // 清空redis缓存
... ... @@ -133,7 +139,7 @@ public class PlatformController {
133 139 }
134 140 }
135 141  
136   - @RequestMapping("/platforms/exit/{deviceGbId}")
  142 + @GetMapping("/exit/{deviceGbId}")
137 143 @ResponseBody
138 144 public ResponseEntity<String> exitPlatform(@PathVariable String deviceGbId){
139 145  
... ... @@ -144,7 +150,7 @@ public class PlatformController {
144 150 return new ResponseEntity<>(String.valueOf(parentPlatform != null), HttpStatus.OK);
145 151 }
146 152  
147   - @RequestMapping("/platforms/channelList")
  153 + @GetMapping("/channel_list")
148 154 @ResponseBody
149 155 public PageInfo<ChannelReduce> channelList(int page, int count,
150 156 @RequestParam(required = false) String platformId,
... ... @@ -167,7 +173,7 @@ public class PlatformController {
167 173 }
168 174  
169 175  
170   - @RequestMapping("/platforms/updateChannelForGB")
  176 + @PostMapping("/update_channel_for_gb")
171 177 @ResponseBody
172 178 public ResponseEntity<String> updateChannelForGB(@RequestBody UpdateChannelParam param){
173 179  
... ... @@ -179,7 +185,7 @@ public class PlatformController {
179 185 return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
180 186 }
181 187  
182   - @RequestMapping("/platforms/delChannelForGB")
  188 + @DeleteMapping("/del_channel_for_gb")
183 189 @ResponseBody
184 190 public ResponseEntity<String> delChannelForGB(@RequestBody UpdateChannelParam param){
185 191  
... ...
web_src/src/components/ParentPlatformList.vue
... ... @@ -121,7 +121,7 @@ export default {
121 121 },
122 122 deletePlatformCommit: function(platform) {
123 123 var that = this;
124   - that.$axios.post(`/api/platforms/delete`, platform)
  124 + that.$axios.delete(`/api/platform/delete/${platform.serverGBId}`)
125 125 .then(function (res) {
126 126 if (res.data == "success") {
127 127 that.$message({
... ... @@ -155,7 +155,7 @@ export default {
155 155 getPlatformList: function() {
156 156 let that = this;
157 157  
158   - this.$axios.get(`/api/platforms/${that.count}/${that.currentPage}`)
  158 + this.$axios.get(`/api/platform/query/${that.count}/${that.currentPage}`)
159 159 .then(function (res) {
160 160 that.total = res.data.total;
161 161 that.platformList = res.data.list;
... ...
web_src/src/components/devicePosition.vue
... ... @@ -171,7 +171,7 @@ export default {
171 171 this.endTime = null;
172 172 }
173 173 let self = this;
174   - this.$axios.get(`/api/positions/${this.deviceId}/history`, {
  174 + this.$axios.get(`/api/position/history/${this.deviceId}`, {
175 175 params: {
176 176 start: self.startTime,
177 177 end: self.endTime,
... ... @@ -202,7 +202,7 @@ export default {
202 202 this.mapPointList = [];
203 203 this.mobilePositionList = [];
204 204 let self = this;
205   - this.$axios.get(`/api/positions/${this.deviceId}/latest`)
  205 + this.$axios.get(`/api/position/latest/${this.deviceId}`)
206 206 .then(function (res) {
207 207 console.log(res.data);
208 208 self.total = res.data.length;
... ... @@ -226,7 +226,7 @@ export default {
226 226 },
227 227 subscribeMobilePosition: function() {
228 228 let self = this;
229   - this.$axios.get(`/api/positions/${this.deviceId}/subscribe`, {
  229 + this.$axios.get(`/api/position/subscribe/${this.deviceId}`, {
230 230 params: {
231 231 expires: self.expired,
232 232 interval: self.interval,
... ... @@ -241,7 +241,7 @@ export default {
241 241 },
242 242 unSubscribeMobilePosition: function() {
243 243 let self = this;
244   - this.$axios.get(`/api/positions/${this.deviceId}/subscribe`, {
  244 + this.$axios.get(`/api/position/subscribe/${this.deviceId}`, {
245 245 params: {
246 246 expires: 0,
247 247 interval: self.interval,
... ...
web_src/src/components/dialog/StreamProxyEdit.vue
... ... @@ -176,7 +176,7 @@ export default {
176 176 var result = false;
177 177 var that = this;
178 178 await that.$axios
179   - .post(`/api/platforms/exit/${deviceGbId}`)
  179 + .post(`/api/platform/exit/${deviceGbId}`)
180 180 .then(function (res) {
181 181 result = res.data;
182 182 })
... ...
web_src/src/components/dialog/addStreamTOGB.vue
... ... @@ -119,7 +119,7 @@ export default {
119 119 var result = false;
120 120 var that = this;
121 121 await that.$axios
122   - .post(`/api/platforms/exit/${deviceGbId}`)
  122 + .post(`/api/platform/exit/${deviceGbId}`)
123 123 .then(function (res) {
124 124 result = res.data;
125 125 })
... ...
web_src/src/components/dialog/chooseChannel.vue
... ... @@ -72,7 +72,7 @@ export default {
72 72  
73 73 this.$axios({
74 74 method:"post",
75   - url:"/api/platforms/updateChannelForGB",
  75 + url:"/api/platform/update_channel_for_gb",
76 76 data:{
77 77 platformId: that.platformId,
78 78 channelReduces: that.chooseData
... ...
web_src/src/components/dialog/chooseChannelForGb.vue
... ... @@ -149,7 +149,7 @@ export default {
149 149 if (Object.keys(addData).length >0) {
150 150 that.$axios({
151 151 method:"post",
152   - url:"/api/platforms/updateChannelForGB",
  152 + url:"/api/platform/update_channel_for_gb",
153 153 data:{
154 154 platformId: that.platformId,
155 155 channelReduces: addData
... ... @@ -162,8 +162,8 @@ export default {
162 162 }
163 163 if (Object.keys(delData).length >0) {
164 164 that.$axios({
165   - method:"post",
166   - url:"/api/platforms/delChannelForGB",
  165 + method:"delete",
  166 + url:"/api/platform/del_channel_for_gb",
167 167 data:{
168 168 platformId: that.platformId,
169 169 channelReduces: delData
... ... @@ -182,7 +182,7 @@ export default {
182 182 getChannelList: function () {
183 183 let that = this;
184 184  
185   - this.$axios.get(`/api/platforms/channelList`, {
  185 + this.$axios.get(`/api/platform/channel_list`, {
186 186 params: {
187 187 page: that.currentPage,
188 188 count: that.count,
... ...
web_src/src/components/dialog/chooseChannelForStream.vue
... ... @@ -142,7 +142,7 @@ export default {
142 142 if (Object.keys(delData).length >0) {
143 143 console.log(delData)
144 144 that.$axios({
145   - method:"post",
  145 + method:"delete",
146 146 url:"/api/gbStream/del",
147 147 data:{
148 148 gbStreams: delData,
... ... @@ -152,6 +152,7 @@ export default {
152 152 }).catch(function (error) {
153 153 console.log(error);
154 154 });
  155 +
155 156 }
156 157  
157 158 },
... ...
web_src/src/components/dialog/platformEdit.vue
... ... @@ -164,7 +164,7 @@ export default {
164 164 openDialog: function (platform, callback) {
165 165 var that = this;
166 166 this.$axios
167   - .get(`/api/platforms/serverconfig`)
  167 + .get(`/api/platform/server_config`)
168 168 .then(function (res) {
169 169 console.log(res);
170 170 that.platform.deviceGBId = res.data.username;
... ... @@ -189,7 +189,7 @@ export default {
189 189 console.log("onSubmit");
190 190 var that = this;
191 191 that.$axios
192   - .post(`/api/platforms/save`, that.platform)
  192 + .post(`/api/platform/save`, that.platform)
193 193 .then(function (res) {
194 194 console.log(res);
195 195 console.log(res.data == "success");
... ... @@ -219,7 +219,7 @@ export default {
219 219 var result = false;
220 220 var that = this;
221 221 await that.$axios
222   - .post(`/api/platforms/exit/${deviceGbId}`)
  222 + .post(`/api/platform/exit/${deviceGbId}`)
223 223 .then(function (res) {
224 224 result = res.data;
225 225 })
... ...