From 10e2180c72d0f683cf08a4bc586aa8960b2a6d5c Mon Sep 17 00:00:00 2001
From: leesam <leesam@leesam.cn>
Date: 星期三, 10 四月 2024 19:07:37 +0800
Subject: [PATCH] [bugfix]支持context-path配置
---
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java | 36 ++++++++++++++++--------------------
1 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java
old mode 100644
new mode 100755
index e030b17..10c99a5
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java
@@ -1,40 +1,35 @@
package com.genersoft.iot.vmp.vmanager.gb28181.alarm;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
+import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
-import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookListener;
import com.genersoft.iot.vmp.service.IDeviceAlarmService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
-import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
-import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
@Tag(name = "鎶ヨ淇℃伅绠$悊")
-@CrossOrigin
+
@RestController
@RequestMapping("/api/alarm")
public class AlarmController {
@@ -63,7 +58,7 @@
* @return
*/
@DeleteMapping("/delete")
- @Operation(summary = "鍒犻櫎鎶ヨ")
+ @Operation(summary = "鍒犻櫎鎶ヨ", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "id", description = "ID")
@Parameter(name = "deviceIds", description = "澶氫釜璁惧id,閫楀彿鍒嗛殧")
@Parameter(name = "time", description = "缁撴潫鏃堕棿")
@@ -78,11 +73,11 @@
if (ObjectUtils.isEmpty(deviceIds)) {
deviceIds = null;
}
+
if (ObjectUtils.isEmpty(time)) {
time = null;
- }
- if (!DateUtil.verification(time, DateUtil.formatter) ){
- return null;
+ }else if (!DateUtil.verification(time, DateUtil.formatter) ){
+ throw new ControllerException(ErrorCode.ERROR400.getCode(), "time鏍煎紡涓�" + DateUtil.PATTERN);
}
List<String> deviceIdList = null;
if (deviceIds != null) {
@@ -100,7 +95,7 @@
* @return
*/
@GetMapping("/test/notify/alarm")
- @Operation(summary = "娴嬭瘯鍚戜笂绾�/璁惧鍙戦�佹ā鎷熸姤璀﹂�氱煡")
+ @Operation(summary = "娴嬭瘯鍚戜笂绾�/璁惧鍙戦�佹ā鎷熸姤璀﹂�氱煡", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿")
public void delete(@RequestParam String deviceId) {
Device device = storage.queryVideoDevice(deviceId);
@@ -110,7 +105,7 @@
deviceAlarm.setAlarmDescription("test");
deviceAlarm.setAlarmMethod("1");
deviceAlarm.setAlarmPriority("1");
- deviceAlarm.setAlarmTime(DateUtil.formatterISO8601.format(LocalDateTime.now()));
+ deviceAlarm.setAlarmTime(DateUtil.getNow());
deviceAlarm.setAlarmType("1");
deviceAlarm.setLongitude(115.33333);
deviceAlarm.setLatitude(39.33333);
@@ -148,7 +143,7 @@
* @param endTime 缁撴潫鏃堕棿
* @return
*/
- @Operation(summary = "鍒嗛〉鏌ヨ鎶ヨ")
+ @Operation(summary = "鍒嗛〉鏌ヨ鎶ヨ", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "page",description = "褰撳墠椤�",required = true)
@Parameter(name = "count",description = "姣忛〉鏌ヨ鏁伴噺",required = true)
@Parameter(name = "deviceId",description = "璁惧id")
@@ -177,16 +172,17 @@
if (ObjectUtils.isEmpty(alarmType)) {
alarmType = null;
}
+
if (ObjectUtils.isEmpty(startTime)) {
startTime = null;
+ }else if (!DateUtil.verification(startTime, DateUtil.formatter) ){
+ throw new ControllerException(ErrorCode.ERROR400.getCode(), "startTime鏍煎紡涓�" + DateUtil.PATTERN);
}
+
if (ObjectUtils.isEmpty(endTime)) {
endTime = null;
- }
-
-
- if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){
- throw new ControllerException(ErrorCode.ERROR100.getCode(), "寮�濮嬫椂闂存垨缁撴潫鏃堕棿鏍煎紡鏈夎");
+ }else if (!DateUtil.verification(endTime, DateUtil.formatter) ){
+ throw new ControllerException(ErrorCode.ERROR400.getCode(), "endTime鏍煎紡涓�" + DateUtil.PATTERN);
}
return deviceAlarmService.getAllAlarm(page, count, deviceId, alarmPriority, alarmMethod,
--
Gitblit v1.8.0