From c7d5171a3d91a77238e5378571e7a864b7076898 Mon Sep 17 00:00:00 2001 From: cheney <1251790704@qq.com> Date: Tue, 21 Mar 2023 16:06:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=9D=E5=A4=96=E5=8F=82=E6=95=B0=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/handler/RestExceptionHandler.java | 8 ++++++++ .../huoran/iasf/service/impl/SysColumnServiceImpl.java | 2 +- .../huoran/iasf/service/impl/SysContentServiceImpl.java | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/huoran/iasf/common/exception/handler/RestExceptionHandler.java b/src/main/java/com/huoran/iasf/common/exception/handler/RestExceptionHandler.java index 1228728..d2eebb7 100644 --- a/src/main/java/com/huoran/iasf/common/exception/handler/RestExceptionHandler.java +++ b/src/main/java/com/huoran/iasf/common/exception/handler/RestExceptionHandler.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; +import javax.validation.ValidationException; import java.util.HashMap; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; @@ -113,4 +114,11 @@ public class RestExceptionHandler { return R.getResult(BaseResponseCode.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getCode(), builder.toString()); } + @ExceptionHandler + @ResponseStatus(HttpStatus.NOT_FOUND) + public R handle(ValidationException e) { + log.error("Exception,exception:{}", e, e); + return new R(404, e.getMessage()); + } + } diff --git a/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java index 5fc460a..a3bda4f 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java @@ -92,7 +92,7 @@ public class SysColumnServiceImpl extends ServiceImpl listWithTreeMenuVisible(PaginationColumnReqVO column) { - if (column.getRole()!=null&&column.getRole().equals("admin") || ObjectUtil.isNotNull(column.isIsadmin()) && column.isIsadmin()){ + if (column.getRole()!=null||column.getRole().equals("admin") || ObjectUtil.isNotNull(column.isIsadmin()) || column.isIsadmin()){ throw new IllegalArgumentException("参数名不能包含admin"); } //查询所有栏目 diff --git a/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java index ef5b05d..d1084c6 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java @@ -75,7 +75,7 @@ public class SysContentServiceImpl extends ServiceImpl page = new Page(reqVO.getPageNum(), reqVO.getPageSize());