From 8fdd10d1c2723ead1d2c3b232f64f292ba3ce1cc Mon Sep 17 00:00:00 2001 From: che_shuai <che_shuai@massclouds> Date: 星期一, 24 七月 2023 14:10:46 +0800 Subject: [PATCH] 修复在国标级联选择通道时,如果添加通道到跟平台根目录(即平台本身),无法触发目录变更事件问题.详见 https://github.com/648540858/wvp-GB28181-pro/issues/958 --- src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java | 33 ++++++++++++++++++++++++++++----- 1 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java b/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java index 0c7c3d2..0333e0d 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java @@ -1,13 +1,14 @@ package com.genersoft.iot.vmp.conf; import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEventListener; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; @@ -32,6 +33,28 @@ return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage()); } + /** + * 榛樿寮傚父澶勭悊 + * @param e 寮傚父 + * @return 缁熶竴杩斿洖缁撴灉 + */ + @ExceptionHandler(IllegalStateException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public WVPResult<String> exceptionHandler(IllegalStateException e) { + return WVPResult.fail(ErrorCode.ERROR400); + } + + /** + * 榛樿寮傚父澶勭悊 + * @param e 寮傚父 + * @return 缁熶竴杩斿洖缁撴灉 + */ + @ExceptionHandler(HttpRequestMethodNotSupportedException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public WVPResult<String> exceptionHandler(HttpRequestMethodNotSupportedException e) { + return WVPResult.fail(ErrorCode.ERROR400); + } + /** * 鑷畾涔夊紓甯稿鐞嗭紝 澶勭悊controller涓繑鍥炵殑閿欒 @@ -40,8 +63,8 @@ */ @ExceptionHandler(ControllerException.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public WVPResult<String> exceptionHandler(ControllerException e) { - return WVPResult.fail(e.getCode(), e.getMsg()); + public ResponseEntity<WVPResult<String>> exceptionHandler(ControllerException e) { + return new ResponseEntity<>(WVPResult.fail(e.getCode(), e.getMsg()), HttpStatus.OK); } /** @@ -51,7 +74,7 @@ */ @ExceptionHandler(BadCredentialsException.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public WVPResult<String> exceptionHandler(BadCredentialsException e) { - return WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMessage()); + public ResponseEntity<WVPResult<String>> exceptionHandler(BadCredentialsException e) { + return new ResponseEntity<>(WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMessage()), HttpStatus.OK); } } -- Gitblit v1.8.0