From c4582b085f880a72dc97f8bff265d0499ae0794b Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期三, 13 十二月 2023 12:57:07 +0800 Subject: [PATCH] update 优化 删除无用异常类 --- /dev/null | 26 -------------------------- ruoyi-common/ruoyi-common-security/src/main/java/org/dromara/common/security/handler/GlobalExceptionHandler.java | 8 -------- ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/sql/SqlUtil.java | 7 +++---- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/exception/DemoModeException.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/exception/DemoModeException.java deleted file mode 100644 index 9916ddf..0000000 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/exception/DemoModeException.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.dromara.common.core.exception; - -import java.io.Serial; - -/** - * 婕旂ず妯″紡寮傚父 - * - * @author ruoyi - */ -public class DemoModeException extends RuntimeException { - - @Serial - private static final long serialVersionUID = 1L; - - public DemoModeException() { - } -} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/exception/GlobalException.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/exception/GlobalException.java deleted file mode 100644 index 76b1265..0000000 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/exception/GlobalException.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.dromara.common.core.exception; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -import java.io.Serial; - -/** - * 鍏ㄥ眬寮傚父 - * - * @author ruoyi - */ -@Data -@EqualsAndHashCode(callSuper = true) -@NoArgsConstructor -@AllArgsConstructor -public class GlobalException extends RuntimeException { - - @Serial - private static final long serialVersionUID = 1L; - - /** - * 閿欒鎻愮ず - */ - private String message; - - /** - * 閿欒鏄庣粏锛屽唴閮ㄨ皟璇曢敊璇� - */ - private String detailMessage; - - public GlobalException(String message) { - this.message = message; - } - - public String getDetailMessage() { - return detailMessage; - } - - public GlobalException setDetailMessage(String detailMessage) { - this.detailMessage = detailMessage; - return this; - } - - @Override - public String getMessage() { - return message; - } - - public GlobalException setMessage(String message) { - this.message = message; - return this; - } -} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/exception/UtilException.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/exception/UtilException.java deleted file mode 100644 index a9bf2c6..0000000 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/exception/UtilException.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.dromara.common.core.exception; - -import java.io.Serial; - -/** - * 宸ュ叿绫诲紓甯� - * - * @author ruoyi - */ -public class UtilException extends RuntimeException { - - @Serial - private static final long serialVersionUID = 8247610319171014183L; - - public UtilException(Throwable e) { - super(e.getMessage(), e); - } - - public UtilException(String message) { - super(message); - } - - public UtilException(String message, Throwable throwable) { - super(message, throwable); - } -} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/sql/SqlUtil.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/sql/SqlUtil.java index 1ed01a9..3e109b2 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/sql/SqlUtil.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/sql/SqlUtil.java @@ -1,9 +1,8 @@ package org.dromara.common.core.utils.sql; -import org.dromara.common.core.exception.UtilException; -import org.dromara.common.core.utils.StringUtils; import lombok.AccessLevel; import lombok.NoArgsConstructor; +import org.dromara.common.core.utils.StringUtils; /** * sql鎿嶄綔宸ュ叿绫� @@ -28,7 +27,7 @@ */ public static String escapeOrderBySql(String value) { if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) { - throw new UtilException("鍙傛暟涓嶇鍚堣鑼冿紝涓嶈兘杩涜鏌ヨ"); + throw new IllegalArgumentException("鍙傛暟涓嶇鍚堣鑼冿紝涓嶈兘杩涜鏌ヨ"); } return value; } @@ -50,7 +49,7 @@ String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|"); for (String sqlKeyword : sqlKeywords) { if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) { - throw new UtilException("鍙傛暟瀛樺湪SQL娉ㄥ叆椋庨櫓"); + throw new IllegalArgumentException("鍙傛暟瀛樺湪SQL娉ㄥ叆椋庨櫓"); } } } diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/org/dromara/common/security/handler/GlobalExceptionHandler.java b/ruoyi-common/ruoyi-common-security/src/main/java/org/dromara/common/security/handler/GlobalExceptionHandler.java index 1809c61..a4dcfe3 100644 --- a/ruoyi-common/ruoyi-common-security/src/main/java/org/dromara/common/security/handler/GlobalExceptionHandler.java +++ b/ruoyi-common/ruoyi-common-security/src/main/java/org/dromara/common/security/handler/GlobalExceptionHandler.java @@ -10,7 +10,6 @@ import jakarta.validation.ConstraintViolationException; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.domain.R; -import org.dromara.common.core.exception.DemoModeException; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.exception.base.BaseException; import org.dromara.common.core.utils.StreamUtils; @@ -162,11 +161,4 @@ return R.fail(message); } - /** - * 婕旂ず妯″紡寮傚父 - */ - @ExceptionHandler(DemoModeException.class) - public R<Void> handleDemoModeException(DemoModeException e) { - return R.fail("婕旂ず妯″紡锛屼笉鍏佽鎿嶄綔"); - } } -- Gitblit v1.9.3