From 85c5fafda53f21697499ff0587ff6dc0f2b00f0a Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 16 三月 2023 09:34:20 +0800
Subject: [PATCH] 更新前后端分离部署文档
---
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java | 30 ++++++++++++++++++++----------
1 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
index 260047f..6f2fe54 100644
--- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
+++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
@@ -1,18 +1,24 @@
package com.genersoft.iot.vmp.web.gb28181;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import javax.sip.InvalidArgumentException;
+import javax.sip.SipException;
+import java.text.ParseException;
+
/**
* API鍏煎锛氳澶囨帶鍒�
*/
-@CrossOrigin
+
@RestController
@RequestMapping(value = "/api/v1/control")
public class ApiControlController {
@@ -23,7 +29,7 @@
private SIPCommander cmder;
@Autowired
- private IVideoManagerStorager storager;
+ private IVideoManagerStorage storager;
/**
* 璁惧鎺у埗 - 浜戝彴鎺у埗
@@ -35,7 +41,7 @@
* @return
*/
@RequestMapping(value = "/ptz")
- private JSONObject list(String serial,String command,
+ private void list(String serial,String command,
@RequestParam(required = false)Integer channel,
@RequestParam(required = false)String code,
@RequestParam(required = false)Integer speed){
@@ -44,11 +50,11 @@
logger.debug("妯℃嫙鎺ュ彛> 璁惧浜戝彴鎺у埗 API璋冪敤锛宒eviceId锛歿} 锛宑hannelId锛歿} 锛宑ommand锛歿} 锛宻peed锛歿} ",
serial, code, command, speed);
}
+ if (channel == null) {channel = 0;}
+ if (speed == null) {speed = 0;}
Device device = storager.queryVideoDevice(serial);
if (device == null) {
- JSONObject result = new JSONObject();
- result.put("error","device[ " + serial + " ]鏈壘鍒�");
- return result;
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]鏈壘鍒�");
}
int cmdCode = 0;
switch (command){
@@ -89,7 +95,11 @@
break;
}
// 榛樿鍊� 50
- cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed);
- return null;
+ try {
+ cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed);
+ } catch (SipException | InvalidArgumentException | ParseException e) {
+ logger.error("[鍛戒护鍙戦�佸け璐 浜戝彴鎺у埗: {}", e.getMessage());
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), "鍛戒护鍙戦�佸け璐�: " + e.getMessage());
+ }
}
}
--
Gitblit v1.8.0