update 优化 删除无用异常类
This commit is contained in:
parent
45097ccb8f
commit
c4582b085f
@ -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() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +1,8 @@
|
|||||||
package org.dromara.common.core.utils.sql;
|
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.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sql操作工具类
|
* sql操作工具类
|
||||||
@ -28,7 +27,7 @@ public class SqlUtil {
|
|||||||
*/
|
*/
|
||||||
public static String escapeOrderBySql(String value) {
|
public static String escapeOrderBySql(String value) {
|
||||||
if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) {
|
if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) {
|
||||||
throw new UtilException("参数不符合规范,不能进行查询");
|
throw new IllegalArgumentException("参数不符合规范,不能进行查询");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -50,7 +49,7 @@ public class SqlUtil {
|
|||||||
String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
|
String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
|
||||||
for (String sqlKeyword : sqlKeywords) {
|
for (String sqlKeyword : sqlKeywords) {
|
||||||
if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) {
|
if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) {
|
||||||
throw new UtilException("参数存在SQL注入风险");
|
throw new IllegalArgumentException("参数存在SQL注入风险");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import jakarta.validation.ConstraintViolation;
|
|||||||
import jakarta.validation.ConstraintViolationException;
|
import jakarta.validation.ConstraintViolationException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.domain.R;
|
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.ServiceException;
|
||||||
import org.dromara.common.core.exception.base.BaseException;
|
import org.dromara.common.core.exception.base.BaseException;
|
||||||
import org.dromara.common.core.utils.StreamUtils;
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
@ -162,11 +161,4 @@ public class GlobalExceptionHandler {
|
|||||||
return R.fail(message);
|
return R.fail(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 演示模式异常
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(DemoModeException.class)
|
|
||||||
public R<Void> handleDemoModeException(DemoModeException e) {
|
|
||||||
return R.fail("演示模式,不允许操作");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user