diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBoot401Exception.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBoot401Exception.java deleted file mode 100644 index 6f7205b..0000000 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBoot401Exception.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.jeecg.common.exception; - -/** - * @Description: jeecg-boot自定义401异常 - * @author: jeecg-boot - */ -public class JeecgBoot401Exception extends RuntimeException { - private static final long serialVersionUID = 1L; - - public JeecgBoot401Exception(String message){ - super(message); - } - - public JeecgBoot401Exception(Throwable cause) - { - super(cause); - } - - public JeecgBoot401Exception(String message, Throwable cause) - { - super(message,cause); - } -} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootAssertException.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootAssertException.java deleted file mode 100644 index b090ea1..0000000 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootAssertException.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.jeecg.common.exception; - -/** - * jeecgboot断言异常 - * for [QQYUN-10990]AIRAG - * @author chenrui - * @date 2025/2/14 14:31 - */ -public class JeecgBootAssertException extends JeecgBootException { - private static final long serialVersionUID = 1L; - - - public JeecgBootAssertException(String message) { - super(message); - } - - public JeecgBootAssertException(String message, int errCode) { - super(message, errCode); - } - -} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgCaptchaException.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgCaptchaException.java deleted file mode 100644 index cf2777a..0000000 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgCaptchaException.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.jeecg.common.exception; - -import lombok.Data; - -/** - * @author kezhijie@wuhandsj.com - * @date 2024/1/2 11:38 - */ -@Data -public class JeecgCaptchaException extends RuntimeException{ - - private Integer code; - - private static final long serialVersionUID = -9093410345065209053L; - - public JeecgCaptchaException(Integer code, String message) { - super(message); - this.code = code; - } - - public JeecgCaptchaException(String message, Throwable cause) { - super(message, cause); - } - - public JeecgCaptchaException(Throwable cause) { - super(cause); - } -} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgSqlInjectionException.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgSqlInjectionException.java deleted file mode 100644 index db9a287..0000000 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgSqlInjectionException.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.jeecg.common.exception; - -/** - * @Description: jeecg-boot自定义SQL注入异常 - * @author: jeecg-boot - */ -public class JeecgSqlInjectionException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public JeecgSqlInjectionException(String message){ - super(message); - } - - public JeecgSqlInjectionException(Throwable cause) - { - super(cause); - } - - public JeecgSqlInjectionException(String message, Throwable cause) - { - super(message,cause); - } -} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STAS401Exception.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STAS401Exception.java new file mode 100644 index 0000000..daacf40 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STAS401Exception.java @@ -0,0 +1,22 @@ +package org.jeecg.common.exception; + +/** + * 自定义401异常 + */ +public class STAS401Exception extends RuntimeException { + private static final long serialVersionUID = 1L; + + public STAS401Exception(String message){ + super(message); + } + + public STAS401Exception(Throwable cause) + { + super(cause); + } + + public STAS401Exception(String message, Throwable cause) + { + super(message,cause); + } +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASAssertException.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASAssertException.java new file mode 100644 index 0000000..038a0c1 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASAssertException.java @@ -0,0 +1,18 @@ +package org.jeecg.common.exception; + +/** + * 断言异常 + */ +public class STASAssertException extends STASException { + private static final long serialVersionUID = 1L; + + + public STASAssertException(String message) { + super(message); + } + + public STASAssertException(String message, int errCode) { + super(message, errCode); + } + +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootException.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASBizTipException.java similarity index 56% rename from jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootException.java rename to jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASBizTipException.java index 4b57f43..533d661 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootException.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASBizTipException.java @@ -3,10 +3,9 @@ package org.jeecg.common.exception; import org.jeecg.common.constant.CommonConstant; /** - * @Description: jeecg-boot自定义异常 - * @author: jeecg-boot + * 业务提醒异常(用于操作业务提醒) */ -public class JeecgBootException extends RuntimeException { +public class STASBizTipException extends RuntimeException { private static final long serialVersionUID = 1L; /** @@ -14,11 +13,11 @@ public class JeecgBootException extends RuntimeException { */ private int errCode = CommonConstant.SC_INTERNAL_SERVER_ERROR_500; - public JeecgBootException(String message){ + public STASBizTipException(String message){ super(message); } - public JeecgBootException(String message, int errCode){ + public STASBizTipException(String message, int errCode){ super(message); this.errCode = errCode; } @@ -27,12 +26,12 @@ public class JeecgBootException extends RuntimeException { return errCode; } - public JeecgBootException(Throwable cause) + public STASBizTipException(Throwable cause) { super(cause); } - public JeecgBootException(String message,Throwable cause) + public STASBizTipException(String message, Throwable cause) { super(message,cause); } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASCaptchaException.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASCaptchaException.java new file mode 100644 index 0000000..0ffb67d --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASCaptchaException.java @@ -0,0 +1,24 @@ +package org.jeecg.common.exception; + +import lombok.Data; + +@Data +public class STASCaptchaException extends RuntimeException{ + + private Integer code; + + private static final long serialVersionUID = -9093410345065209053L; + + public STASCaptchaException(Integer code, String message) { + super(message); + this.code = code; + } + + public STASCaptchaException(String message, Throwable cause) { + super(message, cause); + } + + public STASCaptchaException(Throwable cause) { + super(cause); + } +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootBizTipException.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASException.java similarity index 52% rename from jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootBizTipException.java rename to jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASException.java index 7278709..6f17e34 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootBizTipException.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASException.java @@ -3,11 +3,9 @@ package org.jeecg.common.exception; import org.jeecg.common.constant.CommonConstant; /** - * @Description: 业务提醒异常(用于操作业务提醒) - * @date: 2024-04-26 - * @author: scott + * 自定义异常 */ -public class JeecgBootBizTipException extends RuntimeException { +public class STASException extends RuntimeException { private static final long serialVersionUID = 1L; /** @@ -15,11 +13,11 @@ public class JeecgBootBizTipException extends RuntimeException { */ private int errCode = CommonConstant.SC_INTERNAL_SERVER_ERROR_500; - public JeecgBootBizTipException(String message){ + public STASException(String message){ super(message); } - public JeecgBootBizTipException(String message, int errCode){ + public STASException(String message, int errCode){ super(message); this.errCode = errCode; } @@ -28,12 +26,12 @@ public class JeecgBootBizTipException extends RuntimeException { return errCode; } - public JeecgBootBizTipException(Throwable cause) + public STASException(Throwable cause) { super(cause); } - public JeecgBootBizTipException(String message, Throwable cause) + public STASException(String message, Throwable cause) { super(message,cause); } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASExceptionHandler.java similarity index 93% rename from jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java rename to jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASExceptionHandler.java index 1401a98..350dbe0 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASExceptionHandler.java @@ -39,13 +39,10 @@ import java.util.stream.Collectors; /** * 异常处理器 - * - * @Author scott - * @Date 2019 */ @RestControllerAdvice @Slf4j -public class JeecgBootExceptionHandler { +public class STASExceptionHandler { @Resource BaseCommonService baseCommonService; @@ -54,9 +51,9 @@ public class JeecgBootExceptionHandler { * 验证码错误异常 */ - @ExceptionHandler(JeecgCaptchaException.class) + @ExceptionHandler(STASCaptchaException.class) @ResponseStatus(HttpStatus.OK) - public Result handleJeecgCaptchaException(JeecgCaptchaException e) { + public Result handleJeecgCaptchaException(STASCaptchaException e) { log.error(e.getMessage(), e); return Result.error(e.getCode(), e.getMessage()); } @@ -78,8 +75,8 @@ public class JeecgBootExceptionHandler { /** * 处理自定义异常 */ - @ExceptionHandler(JeecgBootException.class) - public Result handleJeecgBootException(JeecgBootException e){ + @ExceptionHandler(STASException.class) + public Result handleJeecgBootException(STASException e){ log.error(e.getMessage(), e); addSysLog(e); return Result.error(e.getErrCode(), e.getMessage()); @@ -88,8 +85,8 @@ public class JeecgBootExceptionHandler { /** * 处理自定义异常 */ - @ExceptionHandler(JeecgBootBizTipException.class) - public Result handleJeecgBootBizTipException(JeecgBootBizTipException e){ + @ExceptionHandler(STASBizTipException.class) + public Result handleJeecgBootBizTipException(STASBizTipException e){ log.error(e.getMessage()); return Result.error(e.getErrCode(), e.getMessage()); } @@ -107,9 +104,9 @@ public class JeecgBootExceptionHandler { /** * 处理自定义异常 */ - @ExceptionHandler(JeecgBoot401Exception.class) + @ExceptionHandler(STAS401Exception.class) @ResponseStatus(HttpStatus.UNAUTHORIZED) - public Result handleJeecgBoot401Exception(JeecgBoot401Exception e){ + public Result handleJeecgBoot401Exception(STAS401Exception e){ log.error(e.getMessage(), e); addSysLog(e); return new Result(401,e.getMessage()); @@ -206,7 +203,7 @@ public class JeecgBootExceptionHandler { * @param exception * @return */ - @ExceptionHandler(JeecgSqlInjectionException.class) + @ExceptionHandler(STASSqlInjectionException.class) public Result handleSQLException(Exception exception) { String msg = exception.getMessage().toLowerCase(); final String extractvalue = "extractvalue"; diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASFileUploadException.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASFileUploadException.java new file mode 100644 index 0000000..ebeeec9 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASFileUploadException.java @@ -0,0 +1,38 @@ +package org.jeecg.common.exception; + +import org.jeecg.common.constant.CommonConstant; + +/** + * 自定义文件上传异常 + */ +public class STASFileUploadException extends RuntimeException { + private static final long serialVersionUID = 1L; + + /** + * 返回给前端的错误code + */ + private int errCode = CommonConstant.SC_INTERNAL_SERVER_ERROR_500; + + public STASFileUploadException(String message){ + super(message); + } + + public STASFileUploadException(String message, int errCode){ + super(message); + this.errCode = errCode; + } + + public int getErrCode() { + return errCode; + } + + public STASFileUploadException(Throwable cause) + { + super(cause); + } + + public STASFileUploadException(String message, Throwable cause) + { + super(message,cause); + } +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASSqlInjectionException.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASSqlInjectionException.java new file mode 100644 index 0000000..8f7559c --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/STASSqlInjectionException.java @@ -0,0 +1,22 @@ +package org.jeecg.common.exception; + +/** + * 自定义SQL注入异常 + */ +public class STASSqlInjectionException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public STASSqlInjectionException(String message){ + super(message); + } + + public STASSqlInjectionException(Throwable cause) + { + super(cause); + } + + public STASSqlInjectionException(String message, Throwable cause) + { + super(message,cause); + } +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/query/QueryGenerator.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/query/QueryGenerator.java index 76b9d50..0773099 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/query/QueryGenerator.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/query/QueryGenerator.java @@ -14,7 +14,7 @@ import java.util.stream.Collectors; import org.apache.commons.beanutils.PropertyUtils; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.DataBaseConstant; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.util.JeecgDataAutorUtils; import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.system.util.SqlConcatUtil; @@ -277,7 +277,7 @@ public class QueryGenerator { //判断column是不是当前实体的 log.debug("当前字段有:"+ allFields); if (!allColumnExist(column, allFields)) { - throw new JeecgBootException("请注意,将要排序的列字段不存在:" + column); + throw new STASException("请注意,将要排序的列字段不存在:" + column); } //update-end-author:taoyan date:2022-5-16 for: issues/3676 获取系统用户列表时,使用SQL注入生效 diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/util/JwtUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/util/JwtUtil.java index d5d409e..3645d19 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/util/JwtUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/util/JwtUtil.java @@ -1,20 +1,14 @@ package org.jeecg.common.system.util; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson2.JSONObject; import com.auth0.jwt.JWT; -import com.auth0.jwt.JWTVerifier; -import com.auth0.jwt.algorithms.Algorithm; import com.auth0.jwt.exceptions.JWTDecodeException; import com.auth0.jwt.interfaces.DecodedJWT; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Joiner; import java.io.IOException; import java.io.OutputStream; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; import jakarta.servlet.ServletResponse; import jakarta.servlet.http.HttpServletRequest; @@ -22,13 +16,12 @@ import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; import lombok.extern.slf4j.Slf4j; -import org.jeecg.common.api.CommonAPI; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.DataBaseConstant; import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.constant.TenantConstant; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.SysUserCacheInfo; import org.jeecg.common.util.DateUtils; @@ -37,19 +30,11 @@ import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.security.self.SelfAuthenticationProvider; import org.jeecg.config.security.self.SelfAuthenticationToken; import org.jeecg.config.security.utils.SecureUtil; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.oauth2.core.*; import org.springframework.security.oauth2.jwt.JwtDecoder; -import org.springframework.security.oauth2.server.authorization.OAuth2TokenType; import org.springframework.security.oauth2.server.authorization.authentication.OAuth2AccessTokenAuthenticationToken; import org.springframework.security.oauth2.server.authorization.authentication.OAuth2ClientAuthenticationToken; -import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository; -import org.springframework.security.oauth2.server.authorization.context.AuthorizationServerContextHolder; -import org.springframework.security.oauth2.server.authorization.token.DefaultOAuth2TokenContext; -import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenContext; -import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenGenerator; /** * @Author Scott @@ -153,13 +138,13 @@ public class JwtUtil { * * @param request * @return - * @throws JeecgBootException + * @throws STASException */ - public static String getUserNameByToken(HttpServletRequest request) throws JeecgBootException { + public static String getUserNameByToken(HttpServletRequest request) throws STASException { String accessToken = request.getHeader("X-Access-Token"); String username = getUsername(accessToken); if (oConvertUtils.isEmpty(username)) { - throw new JeecgBootException("未获取到用户"); + throw new STASException("未获取到用户"); } return username; } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/AssertUtils.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/AssertUtils.java index ac502ea..56717bf 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/AssertUtils.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/AssertUtils.java @@ -1,7 +1,7 @@ package org.jeecg.common.util; -import org.jeecg.common.exception.JeecgBootAssertException; +import org.jeecg.common.exception.STASAssertException; /** * 断言检查工具 @@ -16,13 +16,13 @@ public class AssertUtils { * * @param msg * @param obj - * @throws JeecgBootAssertException + * @throws STASAssertException * @author chenrui * @date 2017-06-22 10:05:56 */ public static void assertEmpty(String msg, Object obj) { if (oConvertUtils.isObjectNotEmpty(obj)) { - throw new JeecgBootAssertException(msg); + throw new STASAssertException(msg); } } @@ -32,13 +32,13 @@ public class AssertUtils { * * @param msg * @param obj - * @throws JeecgBootAssertException + * @throws STASAssertException * @author chenrui * @date 2017-06-22 10:05:56 */ public static void assertNotEmpty(String msg, Object obj) { if (oConvertUtils.isObjectEmpty(obj)) { - throw new JeecgBootAssertException(msg); + throw new STASAssertException(msg); } } @@ -57,7 +57,7 @@ public class AssertUtils { if (oConvertUtils.isEqual(expected, actual)) { return; } - throw new JeecgBootAssertException(message); + throw new STASAssertException(message); } /** @@ -72,7 +72,7 @@ public class AssertUtils { public static void assertNotEquals(String message, Object expected, Object actual) { if (oConvertUtils.isEqual(expected, actual)) { - throw new JeecgBootAssertException(message); + throw new STASAssertException(message); } } @@ -91,7 +91,7 @@ public class AssertUtils { if (expected == actual) { return; } - throw new JeecgBootAssertException(message); + throw new STASAssertException(message); } /** @@ -106,7 +106,7 @@ public class AssertUtils { public static void assertNotSame(String message, Object unexpected, Object actual) { if (unexpected == actual) { - throw new JeecgBootAssertException(message); + throw new STASAssertException(message); } } @@ -118,7 +118,7 @@ public class AssertUtils { */ public static void assertTrue(String message, boolean condition) { if (!condition) { - throw new JeecgBootAssertException(message); + throw new STASAssertException(message); } } @@ -140,7 +140,7 @@ public class AssertUtils { * @param obj * @param objs * @param - * @throws JeecgBootAssertException + * @throws STASAssertException * @author chenrui * @date 2018/1/31 22:14 */ @@ -148,7 +148,7 @@ public class AssertUtils { assertNotEmpty(message, obj); assertNotEmpty(message, objs); if (!oConvertUtils.isIn(obj, objs)) { - throw new JeecgBootAssertException(message); + throw new STASAssertException(message); } } @@ -159,7 +159,7 @@ public class AssertUtils { * @param obj * @param objs * @param - * @throws JeecgBootAssertException + * @throws STASAssertException * @author chenrui * @date 2018/1/31 22:14 */ @@ -168,7 +168,7 @@ public class AssertUtils { assertNotEmpty(message, obj); assertNotEmpty(message, objs); if (oConvertUtils.isIn(obj, objs)) { - throw new JeecgBootAssertException(message); + throw new STASAssertException(message); } } @@ -186,7 +186,7 @@ public class AssertUtils { if (oConvertUtils.isGt(src, des)) { return; } - throw new JeecgBootAssertException(message); + throw new STASAssertException(message); } /** @@ -202,7 +202,7 @@ public class AssertUtils { if (oConvertUtils.isGe(src, des)) { return; } - throw new JeecgBootAssertException(message); + throw new STASAssertException(message); } @@ -217,7 +217,7 @@ public class AssertUtils { */ public static void assertLt(String message, Number src, Number des) { if (oConvertUtils.isGe(src, des)) { - throw new JeecgBootAssertException(message); + throw new STASAssertException(message); } } @@ -232,7 +232,7 @@ public class AssertUtils { */ public static void assertLe(String message, Number src, Number des) { if (oConvertUtils.isGt(src, des)) { - throw new JeecgBootAssertException(message); + throw new STASAssertException(message); } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/CommonUtils.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/CommonUtils.java index b7e790f..ac769a8 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/CommonUtils.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/CommonUtils.java @@ -11,7 +11,7 @@ import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.DataBaseConstant; import org.jeecg.common.constant.ServiceNameConstants; import org.jeecg.common.constant.SymbolConstant; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.util.filter.SsrfFileTypeFilter; import org.jeecg.common.util.oss.OssBootUtil; import org.jeecgframework.poi.util.PoiPublicUtil; @@ -140,7 +140,7 @@ public class CommonUtils { } } catch (Exception e) { log.error(e.getMessage(), e); - throw new JeecgBootException(e.getMessage()); + throw new STASException(e.getMessage()); } return url; } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/FileDownloadUtils.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/FileDownloadUtils.java index acdfeb4..ed9db2f 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/FileDownloadUtils.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/FileDownloadUtils.java @@ -3,7 +3,7 @@ package org.jeecg.common.util; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FilenameUtils; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import java.io.*; import java.net.URL; @@ -110,7 +110,7 @@ public class FileDownloadUtils { } } catch (IOException e) { log.error(e.getMessage(), e); - throw new JeecgBootException(e); + throw new STASException(e); } } @@ -142,11 +142,11 @@ public class FileDownloadUtils { return storePath; } catch (IOException e) { log.error(e.getMessage(), e); - throw new JeecgBootException(e); + throw new STASException(e); } } catch (IOException e) { log.error(e.getMessage(), e); - throw new JeecgBootException(e); + throw new STASException(e); } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/SqlInjectionUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/SqlInjectionUtil.java index c11c62e..46baa32 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/SqlInjectionUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/SqlInjectionUtil.java @@ -4,7 +4,7 @@ import cn.hutool.core.util.ReUtil; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.SymbolConstant; -import org.jeecg.common.exception.JeecgSqlInjectionException; +import org.jeecg.common.exception.STASSqlInjectionException; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; @@ -103,7 +103,7 @@ public class SqlInjectionUtil { if (value.indexOf(xssArr[i]) > -1) { log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr[i]); log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value); - throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); + throw new STASSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); } } // 三、SQL注入检测存在绕过风险 (自定义传入普通文本校验) @@ -113,7 +113,7 @@ public class SqlInjectionUtil { if (value.indexOf(xssArr2[i]) > -1) { log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr2[i]); log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value); - throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); + throw new STASSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); } } } @@ -124,7 +124,7 @@ public class SqlInjectionUtil { if (Pattern.matches(regular, value)) { log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, regularOriginal); log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value); - throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); + throw new STASSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); } } return; @@ -205,7 +205,7 @@ public class SqlInjectionUtil { if (isExistSqlInjectKeyword(value, xssArr[i])) { log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr[i]); log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value); - throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); + throw new STASSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); } } @@ -215,7 +215,7 @@ public class SqlInjectionUtil { if (Pattern.matches(regular, value)) { log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, regularOriginal); log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value); - throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); + throw new STASSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); } } return; @@ -241,7 +241,7 @@ public class SqlInjectionUtil { if (isExistSqlInjectKeyword(value, xssArr[i])) { log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr[i]); log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value); - throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); + throw new STASSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); } } @@ -251,7 +251,7 @@ public class SqlInjectionUtil { if (Pattern.matches(regular, value)) { log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, regularOriginal); log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value); - throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); + throw new STASSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); } } return; @@ -274,7 +274,7 @@ public class SqlInjectionUtil { if(matcher.find()){ String error = "请注意,值可能存在SQL注入风险---> \\*.*\\"; log.error(error); - throw new JeecgSqlInjectionException(error); + throw new STASSqlInjectionException(error); } } @@ -312,7 +312,7 @@ public class SqlInjectionUtil { if (!isValidTableName) { String errorMsg = "表名不合法,存在SQL注入风险!--->" + table; log.error(errorMsg); - throw new JeecgSqlInjectionException(errorMsg); + throw new STASSqlInjectionException(errorMsg); } //进一步验证是否存在SQL注入风险 @@ -349,7 +349,7 @@ public class SqlInjectionUtil { if (!isValidField) { String errorMsg = "字段不合法,存在SQL注入风险!--->" + field; log.error(errorMsg); - throw new JeecgSqlInjectionException(errorMsg); + throw new STASSqlInjectionException(errorMsg); } //进一步验证是否存在SQL注入风险 diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TokenUtils.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TokenUtils.java index 95ddab7..0a3ee6e 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TokenUtils.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TokenUtils.java @@ -8,7 +8,7 @@ import org.jeecg.common.constant.CacheConstant; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.TenantConstant; import org.jeecg.common.desensitization.util.SensitiveInfoUtil; -import org.jeecg.common.exception.JeecgBoot401Exception; +import org.jeecg.common.exception.STAS401Exception; import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.system.vo.LoginUser; @@ -95,28 +95,28 @@ public class TokenUtils { */ public static boolean verifyToken(String token, CommonAPI commonApi, RedisUtil redisUtil) { if (StringUtils.isBlank(token)) { - throw new JeecgBoot401Exception("token不能为空!"); + throw new STAS401Exception("token不能为空!"); } // 解密获得username,用于和数据库进行对比 String username = JwtUtil.getUsername(token); if (username == null) { - throw new JeecgBoot401Exception("token非法无效!"); + throw new STAS401Exception("token非法无效!"); } // 查询用户信息 //LoginUser user = TokenUtils.getLoginUser(username, commonApi, redisUtil); LoginUser user = commonApi.getUserByName(username); if (user == null) { - throw new JeecgBoot401Exception("用户不存在!"); + throw new STAS401Exception("用户不存在!"); } // 判断用户状态 if (user.getStatus() != 1) { - throw new JeecgBoot401Exception("账号已被锁定,请联系管理员!"); + throw new STAS401Exception("账号已被锁定,请联系管理员!"); } // 校验token是否超时失效 & 或者账号密码是否错误 if (!jwtTokenRefresh(token, username, user.getPassword(), redisUtil)) { - throw new JeecgBoot401Exception(CommonConstant.TOKEN_IS_INVALID_MSG); + throw new STAS401Exception(CommonConstant.TOKEN_IS_INVALID_MSG); } return true; } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/dynamic/db/DynamicDBUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/dynamic/db/DynamicDBUtil.java index cf6a2eb..71f52f3 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/dynamic/db/DynamicDBUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/dynamic/db/DynamicDBUtil.java @@ -3,15 +3,13 @@ package org.jeecg.common.util.dynamic.db; import com.alibaba.druid.pool.DruidDataSource; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; -import org.jeecg.common.exception.JeecgBootException; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.vo.DynamicDataSourceModel; import org.jeecg.common.util.ReflectHelper; import org.jeecg.common.util.oConvertUtils; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; -import javax.sql.DataSource; import java.sql.SQLException; import java.util.HashMap; import java.util.List; @@ -40,7 +38,7 @@ public class DynamicDBUtil { String url = dbSource.getDbUrl(); // url配置成 “123” 会触发Druid死循环,一直去重复尝试连接 if (oConvertUtils.isEmpty(url) || !url.toLowerCase().startsWith("jdbc:")) { - throw new JeecgBootException("数据源URL配置格式不正确!"); + throw new STASException("数据源URL配置格式不正确!"); } String dbUser = dbSource.getDbUsername(); @@ -90,7 +88,7 @@ public class DynamicDBUtil { DataSourceCachePool.putCacheBasicDataSource(dbKey, dataSource); }else{ - throw new JeecgBootException("动态数据源连接失败,dbKey:"+dbKey); + throw new STASException("动态数据源连接失败,dbKey:"+dbKey); } log.info("--------getDbSourceBydbKey------------------创建DB数据库连接-------------------"); return dataSource; diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/AbstractQueryBlackListHandler.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/AbstractQueryBlackListHandler.java index 8b7e5e2..27b57ca 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/AbstractQueryBlackListHandler.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/AbstractQueryBlackListHandler.java @@ -2,7 +2,7 @@ package org.jeecg.common.util.security; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; -import org.jeecg.common.exception.JeecgSqlInjectionException; +import org.jeecg.common.exception.STASSqlInjectionException; import java.util.*; import java.util.regex.Matcher; @@ -86,7 +86,7 @@ public abstract class AbstractQueryBlackListHandler { // 返回黑名单校验结果(不合法直接抛出异常) if(!flag){ log.error(this.getError()); - throw new JeecgSqlInjectionException(this.getError()); + throw new STASSqlInjectionException(this.getError()); } return flag; } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/JdbcSecurityUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/JdbcSecurityUtil.java index ab948f7..b651bca 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/JdbcSecurityUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/JdbcSecurityUtil.java @@ -1,6 +1,6 @@ package org.jeecg.common.util.security; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.util.oConvertUtils; /** @@ -37,7 +37,7 @@ public class JdbcSecurityUtil { String key = temp.split("=")[0]; for(String prop: notAllowedProps){ if(prop.equalsIgnoreCase(key)){ - throw new JeecgBootException("连接地址有安全风险,【"+key+"】"); + throw new STASException("连接地址有安全风险,【"+key+"】"); } } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/app/AppGrantAuthenticationProvider.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/app/AppGrantAuthenticationProvider.java index 659a8f0..93aa4e2 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/app/AppGrantAuthenticationProvider.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/app/AppGrantAuthenticationProvider.java @@ -5,8 +5,7 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.CommonAPI; import org.jeecg.common.constant.CacheConstant; import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.exception.JeecgBootException; -import org.jeecg.common.exception.JeecgCaptchaException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.SysDepartModel; import org.jeecg.common.util.Md5Util; @@ -14,11 +13,9 @@ import org.jeecg.common.util.PasswordUtil; import org.jeecg.common.util.RedisUtil; import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.JeecgBaseConfig; -import org.jeecg.config.security.password.PasswordGrantAuthenticationToken; import org.jeecg.modules.base.service.BaseCommonService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; -import org.springframework.http.HttpStatus; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; @@ -298,19 +295,19 @@ public class AppGrantAuthenticationProvider implements AuthenticationProvider { //情况1:根据用户信息查询,该用户不存在 if (Objects.isNull(loginUser)) { baseCommonService.addLog("用户登录失败,用户不存在!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户不存在,请注册"); + throw new STASException("该用户不存在,请注册"); } //情况2:根据用户信息查询,该用户已注销 //update-begin---author:王帅 Date:20200601 for:if条件永远为falsebug------------ if (CommonConstant.DEL_FLAG_1.equals(loginUser.getDelFlag())) { //update-end---author:王帅 Date:20200601 for:if条件永远为falsebug------------ baseCommonService.addLog("用户登录失败,用户名:" + loginUser.getUsername() + "已注销!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户已注销"); + throw new STASException("该用户已注销"); } //情况3:根据用户信息查询,该用户已冻结 if (CommonConstant.USER_FREEZE.equals(loginUser.getStatus())) { baseCommonService.addLog("用户登录失败,用户名:" + loginUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户已冻结"); + throw new STASException("该用户已冻结"); } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/password/PasswordGrantAuthenticationProvider.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/password/PasswordGrantAuthenticationProvider.java index 16bd81e..e0e4716 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/password/PasswordGrantAuthenticationProvider.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/password/PasswordGrantAuthenticationProvider.java @@ -5,8 +5,7 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.CommonAPI; import org.jeecg.common.constant.CacheConstant; import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.exception.JeecgBootException; -import org.jeecg.common.exception.JeecgCaptchaException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.SysDepartModel; import org.jeecg.common.util.Md5Util; @@ -17,13 +16,10 @@ import org.jeecg.config.JeecgBaseConfig; import org.jeecg.modules.base.service.BaseCommonService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; -import org.springframework.http.HttpStatus; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.oauth2.core.*; import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames; import org.springframework.security.oauth2.server.authorization.OAuth2Authorization; @@ -98,11 +94,11 @@ public class PasswordGrantAuthenticationProvider implements AuthenticationProvid // 检查登录失败次数 if(isLoginFailOvertimes(username)){ - throw new JeecgBootException("该用户登录失败次数过多,请于10分钟后再次登录!"); + throw new STASException("该用户登录失败次数过多,请于10分钟后再次登录!"); } if(captcha==null){ - throw new JeecgBootException("验证码无效"); + throw new STASException("验证码无效"); } String lowerCaseCaptcha = captcha.toLowerCase(); // 加入密钥作为混淆,避免简单的拼接,被外部利用,用户自定义该密钥即可 @@ -296,19 +292,19 @@ public class PasswordGrantAuthenticationProvider implements AuthenticationProvid //情况1:根据用户信息查询,该用户不存在 if (Objects.isNull(loginUser)) { baseCommonService.addLog("用户登录失败,用户不存在!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户不存在,请注册"); + throw new STASException("该用户不存在,请注册"); } //情况2:根据用户信息查询,该用户已注销 //update-begin---author:王帅 Date:20200601 for:if条件永远为falsebug------------ if (CommonConstant.DEL_FLAG_1.equals(loginUser.getDelFlag())) { //update-end---author:王帅 Date:20200601 for:if条件永远为falsebug------------ baseCommonService.addLog("用户登录失败,用户名:" + loginUser.getUsername() + "已注销!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户已注销"); + throw new STASException("该用户已注销"); } //情况3:根据用户信息查询,该用户已冻结 if (CommonConstant.USER_FREEZE.equals(loginUser.getStatus())) { baseCommonService.addLog("用户登录失败,用户名:" + loginUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户已冻结"); + throw new STASException("该用户已冻结"); } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/phone/PhoneGrantAuthenticationProvider.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/phone/PhoneGrantAuthenticationProvider.java index 250f9b2..3e012b4 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/phone/PhoneGrantAuthenticationProvider.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/phone/PhoneGrantAuthenticationProvider.java @@ -4,20 +4,15 @@ import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.CommonAPI; import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.exception.JeecgBootException; -import org.jeecg.common.exception.JeecgCaptchaException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.SysDepartModel; -import org.jeecg.common.util.Md5Util; -import org.jeecg.common.util.PasswordUtil; import org.jeecg.common.util.RedisUtil; import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.JeecgBaseConfig; -import org.jeecg.config.security.password.PasswordGrantAuthenticationToken; import org.jeecg.modules.base.service.BaseCommonService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; -import org.springframework.http.HttpStatus; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; @@ -82,7 +77,7 @@ public class PhoneGrantAuthenticationProvider implements AuthenticationProvider String phone = (String) additionalParameter.get("mobile"); if(isLoginFailOvertimes(phone)){ - throw new JeecgBootException("该用户登录失败次数过多,请于10分钟后再次登录!"); + throw new STASException("该用户登录失败次数过多,请于10分钟后再次登录!"); } //请求参数权限范围 @@ -270,19 +265,19 @@ public class PhoneGrantAuthenticationProvider implements AuthenticationProvider //情况1:根据用户信息查询,该用户不存在 if (Objects.isNull(loginUser)) { baseCommonService.addLog("用户登录失败,用户不存在!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户不存在,请注册"); + throw new STASException("该用户不存在,请注册"); } //情况2:根据用户信息查询,该用户已注销 //update-begin---author:王帅 Date:20200601 for:if条件永远为falsebug------------ if (CommonConstant.DEL_FLAG_1.equals(loginUser.getDelFlag())) { //update-end---author:王帅 Date:20200601 for:if条件永远为falsebug------------ baseCommonService.addLog("用户登录失败,用户名:" + loginUser.getUsername() + "已注销!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户已注销"); + throw new STASException("该用户已注销"); } //情况3:根据用户信息查询,该用户已冻结 if (CommonConstant.USER_FREEZE.equals(loginUser.getStatus())) { baseCommonService.addLog("用户登录失败,用户名:" + loginUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户已冻结"); + throw new STASException("该用户已冻结"); } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/self/SelfAuthenticationProvider.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/self/SelfAuthenticationProvider.java index c031d42..3ff783d 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/self/SelfAuthenticationProvider.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/self/SelfAuthenticationProvider.java @@ -2,8 +2,8 @@ package org.jeecg.config.security.self; import org.jeecg.common.api.CommonAPI; import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.exception.JeecgBoot401Exception; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STAS401Exception; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.RedisUtil; import org.jeecg.config.JeecgBaseConfig; @@ -106,7 +106,7 @@ public class SelfAuthenticationProvider implements AuthenticationProvider { OAuth2TokenContext tokenContext = tokenContextBuilder.tokenType(OAuth2TokenType.ACCESS_TOKEN).build(); OAuth2Token generatedAccessToken = this.tokenGenerator.generate(tokenContext); if (generatedAccessToken == null) { - throw new JeecgBoot401Exception("无法生成刷新token,请联系管理员。"); + throw new STAS401Exception("无法生成刷新token,请联系管理员。"); } OAuth2AccessToken accessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, generatedAccessToken.getTokenValue(), generatedAccessToken.getIssuedAt(), @@ -169,19 +169,19 @@ public class SelfAuthenticationProvider implements AuthenticationProvider { //情况1:根据用户信息查询,该用户不存在 if (Objects.isNull(loginUser)) { baseCommonService.addLog("用户登录失败,用户不存在!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户不存在,请注册"); + throw new STASException("该用户不存在,请注册"); } //情况2:根据用户信息查询,该用户已注销 //update-begin---author:王帅 Date:20200601 for:if条件永远为falsebug------------ if (CommonConstant.DEL_FLAG_1.equals(loginUser.getDelFlag())) { //update-end---author:王帅 Date:20200601 for:if条件永远为falsebug------------ baseCommonService.addLog("用户登录失败,用户名:" + loginUser.getUsername() + "已注销!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户已注销"); + throw new STASException("该用户已注销"); } //情况3:根据用户信息查询,该用户已冻结 if (CommonConstant.USER_FREEZE.equals(loginUser.getStatus())) { baseCommonService.addLog("用户登录失败,用户名:" + loginUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户已冻结"); + throw new STASException("该用户已冻结"); } } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/social/SocialGrantAuthenticationProvider.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/social/SocialGrantAuthenticationProvider.java index 49a62b9..953aa7a 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/social/SocialGrantAuthenticationProvider.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/social/SocialGrantAuthenticationProvider.java @@ -6,13 +6,12 @@ import com.auth0.jwt.interfaces.DecodedJWT; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.CommonAPI; import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.SysDepartModel; import org.jeecg.common.util.RedisUtil; import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.JeecgBaseConfig; -import org.jeecg.config.security.password.PasswordGrantAuthenticationToken; import org.jeecg.modules.base.service.BaseCommonService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; @@ -256,19 +255,19 @@ public class SocialGrantAuthenticationProvider implements AuthenticationProvider //情况1:根据用户信息查询,该用户不存在 if (Objects.isNull(loginUser)) { baseCommonService.addLog("用户登录失败,用户不存在!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户不存在,请注册"); + throw new STASException("该用户不存在,请注册"); } //情况2:根据用户信息查询,该用户已注销 //update-begin---author:王帅 Date:20200601 for:if条件永远为falsebug------------ if (CommonConstant.DEL_FLAG_1.equals(loginUser.getDelFlag())) { //update-end---author:王帅 Date:20200601 for:if条件永远为falsebug------------ baseCommonService.addLog("用户登录失败,用户名:" + loginUser.getUsername() + "已注销!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户已注销"); + throw new STASException("该用户已注销"); } //情况3:根据用户信息查询,该用户已冻结 if (CommonConstant.USER_FREEZE.equals(loginUser.getStatus())) { baseCommonService.addLog("用户登录失败,用户名:" + loginUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null); - throw new JeecgBootException("该用户已冻结"); + throw new STASException("该用户已冻结"); } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/sign/util/SignUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/sign/util/SignUtil.java index a85a466..6be51c4 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/sign/util/SignUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/sign/util/SignUtil.java @@ -3,7 +3,7 @@ package org.jeecg.config.sign.util; import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.constant.SymbolConstant; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.util.SpringContextUtils; import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.JeecgBaseConfig; @@ -53,7 +53,7 @@ public class SignUtil { String signatureSecret = jeecgBaseConfig.getSignatureSecret(); String curlyBracket = SymbolConstant.DOLLAR + SymbolConstant.LEFT_CURLY_BRACKET; if(oConvertUtils.isEmpty(signatureSecret) || signatureSecret.contains(curlyBracket)){ - throw new JeecgBootException("签名密钥 ${jeecg.signatureSecret} 缺少配置 !!"); + throw new STASException("签名密钥 ${jeecg.signatureSecret} 缺少配置 !!"); } try { //【issues/I484RW】2.4.6部署后,下拉搜索框提示“sign签名检验失败” diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/config/firewall/SqlInjection/impl/DictTableWhiteListHandlerImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/config/firewall/SqlInjection/impl/DictTableWhiteListHandlerImpl.java index f4cf29c..1185102 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/config/firewall/SqlInjection/impl/DictTableWhiteListHandlerImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/config/firewall/SqlInjection/impl/DictTableWhiteListHandlerImpl.java @@ -2,7 +2,7 @@ package org.jeecg.config.firewall.SqlInjection.impl; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.constant.SymbolConstant; -import org.jeecg.common.exception.JeecgSqlInjectionException; +import org.jeecg.common.exception.STASSqlInjectionException; import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.JeecgBaseConfig; import org.jeecg.config.firewall.SqlInjection.IDictTableWhiteListHandler; @@ -259,16 +259,16 @@ public class DictTableWhiteListHandlerImpl implements IDictTableWhiteListHandler return tableName.replaceAll(reg, ""); } - private void throwException() throws JeecgSqlInjectionException { + private void throwException() throws STASSqlInjectionException { this.throwException(this.getErrorMsg()); } - private void throwException(String message) throws JeecgSqlInjectionException { + private void throwException(String message) throws STASSqlInjectionException { if (oConvertUtils.isEmpty(message)) { message = this.getErrorMsg(); } log.error(message); - throw new JeecgSqlInjectionException(message); + throw new STASSqlInjectionException(message); } @Override diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/message/handle/impl/SystemSendMsgHandle.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/message/handle/impl/SystemSendMsgHandle.java index 087ed9b..e99d68b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/message/handle/impl/SystemSendMsgHandle.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/message/handle/impl/SystemSendMsgHandle.java @@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject; import org.jeecg.common.api.dto.message.MessageDTO; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.WebsocketConst; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.api.ISysBaseAPI; import org.jeecg.common.util.SpringContextUtils; import org.jeecg.common.util.oConvertUtils; @@ -54,7 +54,7 @@ public class SystemSendMsgHandle implements ISendMsgHandle { @Override public void sendMsg(String esReceiver, String esTitle, String esContent) { if(oConvertUtils.isEmpty(esReceiver)){ - throw new JeecgBootException("被发送人不能为空"); + throw new STASException("被发送人不能为空"); } ISysBaseAPI sysBaseApi = SpringContextUtils.getBean(ISysBaseAPI.class); MessageDTO messageDTO = new MessageDTO(FROM_USER,esReceiver,esTitle,esContent); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/openapi/filter/ApiAuthFilter.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/openapi/filter/ApiAuthFilter.java index a301d13..a97bab5 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/openapi/filter/ApiAuthFilter.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/openapi/filter/ApiAuthFilter.java @@ -3,7 +3,7 @@ package org.jeecg.modules.openapi.filter; import jakarta.servlet.*; import jakarta.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.modules.openapi.entity.OpenApi; import org.jeecg.modules.openapi.entity.OpenApiAuth; import org.jeecg.modules.openapi.entity.OpenApiLog; @@ -92,7 +92,7 @@ public class ApiAuthFilter implements Filter { List blackList = Arrays.asList(openApi.getBlackList().split(",")); if (blackList.contains(ip)) { - throw new JeecgBootException("目标接口限制IP[" + ip + "]进行访问,IP已记录,请停止访问"); + throw new STASException("目标接口限制IP[" + ip + "]进行访问,IP已记录,请停止访问"); } } @@ -105,19 +105,19 @@ public class ApiAuthFilter implements Filter { */ protected void checkSignValid(String appkey, String signature, String timestamp) { if (!StringUtils.hasText(appkey)) { - throw new JeecgBootException("appkey为空"); + throw new STASException("appkey为空"); } if (!StringUtils.hasText(signature)) { - throw new JeecgBootException("signature为空"); + throw new STASException("signature为空"); } if (!StringUtils.hasText(timestamp)) { - throw new JeecgBootException("timastamp时间戳为空"); + throw new STASException("timastamp时间戳为空"); } if (!timestamp.matches("[0-9]*")) { - throw new JeecgBootException("timastamp时间戳不合法"); + throw new STASException("timastamp时间戳不合法"); } if (System.currentTimeMillis() - Long.parseLong(timestamp) > 5 * 60 * 1000) { - throw new JeecgBootException("signature签名已过期(超过五分钟)"); + throw new STASException("signature签名已过期(超过五分钟)"); } } @@ -132,15 +132,15 @@ public class ApiAuthFilter implements Filter { */ protected void checkSignature(String appKey, String signature, String timestamp, OpenApiAuth openApiAuth) { if(openApiAuth==null){ - throw new JeecgBootException("不存在认证信息"); + throw new STASException("不存在认证信息"); } if(!appKey.equals(openApiAuth.getAk())){ - throw new JeecgBootException("appkey错误"); + throw new STASException("appkey错误"); } if (!signature.equals(md5(appKey + openApiAuth.getSk() + timestamp))) { - throw new JeecgBootException("signature签名错误"); + throw new STASException("signature签名错误"); } } @@ -156,7 +156,7 @@ public class ApiAuthFilter implements Filter { } if (!hasPermission) { - throw new JeecgBootException("该appKey未授权当前接口"); + throw new STASException("该appKey未授权当前接口"); } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/oss/service/impl/OssFileServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/oss/service/impl/OssFileServiceImpl.java index e69f3c6..b1604cd 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/oss/service/impl/OssFileServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/oss/service/impl/OssFileServiceImpl.java @@ -1,7 +1,7 @@ package org.jeecg.modules.oss.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.util.CommonUtils; import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oss.OssBootUtil; @@ -11,8 +11,6 @@ import org.jeecg.modules.oss.service.IOssFileService; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; - /** * @Description: OSS云存储实现类 * @author: jeecg-boot @@ -28,7 +26,7 @@ public class OssFileServiceImpl extends ServiceImpl impl ossFile.setFileName(fileName); String url = OssBootUtil.upload(multipartFile,"upload/test"); if(oConvertUtils.isEmpty(url)){ - throw new JeecgBootException("上传文件失败! "); + throw new STASException("上传文件失败! "); } //update-begin--Author:scott Date:20201227 for:JT-361【文件预览】阿里云原生域名可以文件预览,自己映射域名kkfileview提示文件下载失败------------------- // 返回阿里云原生域名前缀URL diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/QuartzJobServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/QuartzJobServiceImpl.java index 67e8b52..3a2ae8a 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/QuartzJobServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/QuartzJobServiceImpl.java @@ -3,7 +3,7 @@ package org.jeecg.modules.quartz.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.util.DateUtils; import org.jeecg.modules.quartz.entity.QuartzJob; import org.jeecg.modules.quartz.mapper.QuartzJobMapper; @@ -44,7 +44,7 @@ public class QuartzJobServiceImpl extends ServiceImpl { * 根据父级编码加载分类字典的数据 * @param pcode * @return - * @throws JeecgBootException + * @throws STASException */ - public List queryListByCode(String pcode) throws JeecgBootException; + public List queryListByCode(String pcode) throws STASException; /** * 根据pid查询子节点集合 diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysPermissionService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysPermissionService.java index ae8650a..3d0d076 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysPermissionService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysPermissionService.java @@ -2,8 +2,7 @@ package org.jeecg.modules.system.service; import java.util.List; -import org.apache.ibatis.annotations.Param; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.modules.system.entity.SysPermission; import org.jeecg.modules.system.model.TreeModel; @@ -33,29 +32,29 @@ public interface ISysPermissionService extends IService { /** * 真实删除 * @param id 菜单id - * @throws JeecgBootException + * @throws STASException */ - public void deletePermission(String id) throws JeecgBootException; + public void deletePermission(String id) throws STASException; /** * 逻辑删除 * @param id 菜单id - * @throws JeecgBootException + * @throws STASException */ - public void deletePermissionLogical(String id) throws JeecgBootException; + public void deletePermissionLogical(String id) throws STASException; /** * 添加菜单 * @param sysPermission SysPermission对象 - * @throws JeecgBootException + * @throws STASException */ - public void addPermission(SysPermission sysPermission) throws JeecgBootException; + public void addPermission(SysPermission sysPermission) throws STASException; /** * 编辑菜单 * @param sysPermission SysPermission对象 - * @throws JeecgBootException + * @throws STASException */ - public void editPermission(SysPermission sysPermission) throws JeecgBootException; + public void editPermission(SysPermission sysPermission) throws STASException; /** * 获取登录用户拥有的权限 diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/AuthUserServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/AuthUserServiceImpl.java index 9ab98bb..c2e84fb 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/AuthUserServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/AuthUserServiceImpl.java @@ -25,7 +25,7 @@ import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.constant.enums.DySmsEnum; import org.jeecg.common.constant.enums.RoleIndexConfigEnum; import org.jeecg.common.desensitization.annotation.SensitiveEncode; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.SysUserCacheInfo; import org.jeecg.common.util.*; @@ -39,7 +39,6 @@ import org.jeecg.modules.system.model.SysUserSysDepartModel; import org.jeecg.modules.system.service.IAuthUserService; import org.jeecg.modules.system.service.ISysRoleIndexService; import org.jeecg.modules.system.vo.SysUserDepVo; -import org.jeecg.modules.system.vo.SysUserPositionVo; import org.jeecg.modules.system.vo.UserAvatar; import org.jeecg.modules.system.vo.lowapp.AppExportUserVo; import org.jeecg.modules.system.vo.lowapp.DepartAndUserInfo; @@ -1525,7 +1524,7 @@ public class AuthUserServiceImpl extends ServiceImpl im Long adminRoleCount = this.authUserMapper.selectCount(query); //大于0说明存在管理员用户,不允许删除 if(adminRoleCount>0){ - throw new JeecgBootException("admin用户,不允许删除!"); + throw new STASException("admin用户,不允许删除!"); } } @@ -1535,15 +1534,15 @@ public class AuthUserServiceImpl extends ServiceImpl im String phone = json.getString("phone"); String type = json.getString("type"); if(oConvertUtils.isEmpty(phone)){ - throw new JeecgBootException("请填写原手机号!"); + throw new STASException("请填写原手机号!"); } if(oConvertUtils.isEmpty(smscode)){ - throw new JeecgBootException("请填写验证码!"); + throw new STASException("请填写验证码!"); } //step1 验证原手机号是否和当前用户匹配 SysUser sysUser = authUserMapper.getUserByNameAndPhone(phone,username); if (null == sysUser){ - throw new JeecgBootException("原手机号不匹配,无法修改密码!"); + throw new STASException("原手机号不匹配,无法修改密码!"); } //step2 根据类型判断是验证原手机号的验证码还是新手机号的验证码 //验证原手机号 @@ -1554,7 +1553,7 @@ public class AuthUserServiceImpl extends ServiceImpl im String newPhone = json.getString("newPhone"); //需要验证新手机号和原手机号是否一致,一致不让修改 if(newPhone.equals(phone)){ - throw new JeecgBootException("新手机号与原手机号一致,无法修改!"); + throw new STASException("新手机号与原手机号一致,无法修改!"); } this.verifyPhone(newPhone, smscode); //step3 新手机号验证码验证成功之后即可修改手机号 @@ -1574,10 +1573,10 @@ public class AuthUserServiceImpl extends ServiceImpl im String phoneKey = CommonConstant.CHANGE_PHONE_REDIS_KEY_PRE + phone; Object phoneCode = redisUtil.get(phoneKey); if(null == phoneCode){ - throw new JeecgBootException("验证码失效,请重新发送验证码!"); + throw new STASException("验证码失效,请重新发送验证码!"); } if(!smsCode.equals(phoneCode.toString())) { - throw new JeecgBootException("短信验证码不匹配!"); + throw new STASException("短信验证码不匹配!"); } //验证完成之后清空手机验证码 redisUtil.removeAll(phoneKey); @@ -1588,20 +1587,20 @@ public class AuthUserServiceImpl extends ServiceImpl im String type = jsonObject.getString("type"); String phone = jsonObject.getString("phone"); if(oConvertUtils.isEmpty(phone)){ - throw new JeecgBootException("请填写手机号!"); + throw new STASException("请填写手机号!"); } //step1 根据类型判断是发送旧手机号验证码还是新的手机号验证码 if(CommonConstant.VERIFY_ORIGINAL_PHONE.equals(type)){ //step2 旧手机号验证码需要验证手机号是否匹配 SysUser sysUser = authUserMapper.getUserByNameAndPhone(phone, username); if(null == sysUser){ - throw new JeecgBootException("旧手机号不匹配,无法修改手机号!"); + throw new STASException("旧手机号不匹配,无法修改手机号!"); } }else if(CommonConstant.UPDATE_PHONE.equals(type)){ //step3 新手机号需要验证手机号码是否已注册过 SysUser userByPhone = authUserMapper.getUserByPhone(phone); if(null != userByPhone){ - throw new JeecgBootException("手机号已被注册,请尝试其他手机号!"); + throw new STASException("手机号已被注册,请尝试其他手机号!"); } } //step4 发送短信验证码 @@ -1615,7 +1614,7 @@ public class AuthUserServiceImpl extends ServiceImpl im //通过用户名查询数据库中的手机号 SysUser userByNameAndPhone = authUserMapper.getUserByNameAndPhone(phone, username); if (null == userByNameAndPhone) { - throw new JeecgBootException("当前用户手机号不匹配,无法修改!"); + throw new STASException("当前用户手机号不匹配,无法修改!"); } String code = CommonConstant.LOG_OFF_PHONE_REDIS_KEY_PRE + phone; this.sendPhoneSms(phone, ipAddress, code); @@ -1629,15 +1628,15 @@ public class AuthUserServiceImpl extends ServiceImpl im //通过用户名查询数据库中的手机号 SysUser userByNameAndPhone = authUserMapper.getUserByNameAndPhone(phone, username); if (null == userByNameAndPhone) { - throw new JeecgBootException("当前用户手机号不匹配,无法注销!"); + throw new STASException("当前用户手机号不匹配,无法注销!"); } String code = CommonConstant.LOG_OFF_PHONE_REDIS_KEY_PRE + phone; Object redisSmdCode = redisUtil.get(code); if (null == redisSmdCode) { - throw new JeecgBootException("验证码失效,无法注销!"); + throw new STASException("验证码失效,无法注销!"); } if (!redisSmdCode.toString().equals(smsCode)) { - throw new JeecgBootException("验证码不匹配,无法注销!"); + throw new STASException("验证码不匹配,无法注销!"); } this.deleteUser(userByNameAndPhone.getId()); redisUtil.removeAll(code); @@ -1793,13 +1792,13 @@ public class AuthUserServiceImpl extends ServiceImpl im Object object = redisUtil.get(redisKey); if (object != null) { - throw new JeecgBootException("验证码10分钟内,仍然有效!"); + throw new STASException("验证码10分钟内,仍然有效!"); } //增加 check防止恶意刷短信接口 if(!DySmsLimit.canSendSms(clientIp)){ log.warn("--------[警告] IP地址:{}, 短信接口请求太多-------", clientIp); - throw new JeecgBootException("短信接口请求太多,请稍后再试!", CommonConstant.PHONE_SMS_FAIL_CODE); + throw new STASException("短信接口请求太多,请稍后再试!", CommonConstant.PHONE_SMS_FAIL_CODE); } //随机数 @@ -1809,13 +1808,13 @@ public class AuthUserServiceImpl extends ServiceImpl im try { boolean sendSmsSuccess = DySmsHelper.sendSms(phone, obj, DySmsEnum.LOGIN_TEMPLATE_CODE); if(!sendSmsSuccess){ - throw new JeecgBootException("短信验证码发送失败,请稍后重试!"); + throw new STASException("短信验证码发送失败,请稍后重试!"); } //验证码10分钟内有效 redisUtil.set(redisKey, captcha, 600); } catch (ClientException e) { log.error(e.getMessage(),e); - throw new JeecgBootException("短信接口未配置,请联系管理员!"); + throw new STASException("短信接口未配置,请联系管理员!"); } } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java index 4bc5328..9a604a3 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java @@ -20,14 +20,13 @@ import org.apache.commons.lang3.ObjectUtils; import org.jeecg.common.api.dto.DataLogDTO; import org.jeecg.common.api.dto.OnlineAuthDTO; import org.jeecg.common.api.dto.message.*; -import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.UrlMatchEnum; import org.jeecg.common.constant.*; import org.jeecg.common.constant.enums.EmailTemplateEnum; import org.jeecg.common.constant.enums.MessageTypeEnum; import org.jeecg.common.constant.enums.SysAnnmentTypeEnum; import org.jeecg.common.desensitization.util.SensitiveInfoUtil; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.api.ISysBaseAPI; import org.jeecg.common.system.query.QueryCondition; import org.jeecg.common.system.query.QueryGenerator; @@ -53,7 +52,6 @@ import org.jeecg.modules.system.vo.lowapp.SysDictVo; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; import org.springframework.util.AntPathMatcher; @@ -449,7 +447,7 @@ public class SysBaseApiImpl implements ISysBaseAPI { List sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode); if(sysSmsTemplates==null||sysSmsTemplates.size()==0){ - throw new JeecgBootException("消息模板不存在,模板编码:"+templateCode); + throw new STASException("消息模板不存在,模板编码:"+templateCode); } SysMessageTemplate sysSmsTemplate = sysSmsTemplates.get(0); //模板标题 @@ -518,7 +516,7 @@ public class SysBaseApiImpl implements ISysBaseAPI { List sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode); if(sysSmsTemplates==null||sysSmsTemplates.size()==0){ - throw new JeecgBootException("消息模板不存在,模板编码:"+templateCode); + throw new STASException("消息模板不存在,模板编码:"+templateCode); } SysMessageTemplate sysSmsTemplate = sysSmsTemplates.get(0); //模板标题 @@ -589,7 +587,7 @@ public class SysBaseApiImpl implements ISysBaseAPI { Map map = templateDTO.getTemplateParam(); List sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode); if(sysSmsTemplates==null||sysSmsTemplates.size()==0){ - throw new JeecgBootException("消息模板不存在,模板编码:"+templateCode); + throw new STASException("消息模板不存在,模板编码:"+templateCode); } SysMessageTemplate sysSmsTemplate = sysSmsTemplates.get(0); //模板内容 @@ -1566,7 +1564,7 @@ public class SysBaseApiImpl implements ISysBaseAPI { } if(oConvertUtils.isEmpty(message.getContent())){ log.error("发送消息失败,消息内容为空!"); - throw new JeecgBootException("发送消息失败,消息内容为空!"); + throw new STASException("发送消息失败,消息内容为空!"); } //update-end-author:taoyan date:2022-7-9 for: 将模板解析代码移至消息发送, 而不是调用的地方 diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java index c007d8a..a88b05d 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java @@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.common.constant.FillRuleConstant; import org.jeecg.common.constant.SymbolConstant; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.util.FillRuleUtil; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.system.entity.SysCategory; @@ -73,15 +73,15 @@ public class SysCategoryServiceImpl extends ServiceImpl queryListByCode(String pcode) throws JeecgBootException{ + public List queryListByCode(String pcode) throws STASException { String pid = ROOT_PID_VALUE; if(oConvertUtils.isNotEmpty(pcode)) { List list = baseMapper.selectList(new LambdaQueryWrapper().eq(SysCategory::getCode, pcode)); if(list==null || list.size() ==0) { - throw new JeecgBootException("该编码【"+pcode+"】不存在,请核实!"); + throw new STASException("该编码【"+pcode+"】不存在,请核实!"); } if(list.size()>1) { - throw new JeecgBootException("该编码【"+pcode+"】存在多个,请核实!"); + throw new STASException("该编码【"+pcode+"】存在多个,请核实!"); } pid = list.get(0).getId(); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCommentServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCommentServiceImpl.java index cee144b..68e1e37 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCommentServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCommentServiceImpl.java @@ -10,7 +10,7 @@ import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.constant.enums.FileTypeEnum; import org.jeecg.common.constant.enums.MessageTypeEnum; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.system.api.ISysBaseAPI; import org.jeecg.common.system.vo.SysFilesModel; import org.jeecg.common.util.CommonUtils; @@ -26,7 +26,6 @@ import org.jeecg.modules.system.vo.SysCommentVO; import org.jeecg.modules.system.vo.UserAvatar; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.FileCopyUtils; @@ -128,7 +127,7 @@ public class SysCommentServiceImpl extends ServiceImpl impl }catch(MyBatisSystemException e){ log.error(e.getMessage(), e); String errorCause = "查询异常,请检查唯一校验的配置!"; - throw new JeecgBootException(errorCause); + throw new STASException(errorCause); } // 4.返回结果 @@ -830,11 +829,11 @@ public class SysDictServiceImpl extends ServiceImpl impl String id = sysDictVo.getId(); SysDict dict = baseMapper.selectById(id); if(null == dict){ - throw new JeecgBootException("字典数据不存在"); + throw new STASException("字典数据不存在"); } //判断应用id和数据库中的是否一致,不一致不让修改 if(!dict.getLowAppId().equals(sysDictVo.getLowAppId())){ - throw new JeecgBootException("字典数据不存在"); + throw new STASException("字典数据不存在"); } SysDict sysDict = new SysDict(); sysDict.setDictName(sysDictVo.getDictName()); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysPermissionServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysPermissionServiceImpl.java index 477fd9e..70efe67 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysPermissionServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysPermissionServiceImpl.java @@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.common.constant.CacheConstant; import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.mybatis.MybatisPlusSaasConfig; import org.jeecg.modules.system.entity.SysPermission; @@ -78,10 +78,10 @@ public class SysPermissionServiceImpl extends ServiceImpl().lambda().eq(SysPermission::getParentId, pid)); @@ -170,7 +170,7 @@ public class SysPermissionServiceImpl extends ServiceImpl impl query.eq(SysRole::getRoleCode,"admin"); Long adminRoleCount = sysRoleMapper.selectCount(query); if(adminRoleCount>0){ - throw new JeecgBootException("admin角色,不允许删除!"); + throw new STASException("admin角色,不允许删除!"); } } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTableWhiteListServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTableWhiteListServiceImpl.java index 1bab18b..cc6239b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTableWhiteListServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTableWhiteListServiceImpl.java @@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.firewall.SqlInjection.IDictTableWhiteListHandler; import org.jeecg.modules.system.entity.SysTableWhiteList; @@ -59,13 +59,13 @@ public class SysTableWhiteListServiceImpl extends ServiceImpl getById(@NotNull(message = "ID不能为空") String id){ + return Result.OK(weatherTaskService.getById(id)); + } + @AutoLog(value = "修改天气预测任务") @Operation(summary = "修改天气预测任务") @PutMapping("update") diff --git a/jeecg-module-weather/src/main/java/org/jeecg/service/WeatherTaskService.java b/jeecg-module-weather/src/main/java/org/jeecg/service/WeatherTaskService.java index 139e815..cf7aa72 100644 --- a/jeecg-module-weather/src/main/java/org/jeecg/service/WeatherTaskService.java +++ b/jeecg-module-weather/src/main/java/org/jeecg/service/WeatherTaskService.java @@ -31,6 +31,13 @@ public interface WeatherTaskService extends IService { */ void cteate(WeatherTask weatherTask); + /** + * 获取单条任务数据 + * @param id + * @return + */ + WeatherTask getById(String id); + /** * 修改天气预报预测任务 * @param weatherTask diff --git a/jeecg-module-weather/src/main/java/org/jeecg/service/impl/WeatherDataServiceImpl.java b/jeecg-module-weather/src/main/java/org/jeecg/service/impl/WeatherDataServiceImpl.java index d4cc0f6..12a715f 100644 --- a/jeecg-module-weather/src/main/java/org/jeecg/service/impl/WeatherDataServiceImpl.java +++ b/jeecg-module-weather/src/main/java/org/jeecg/service/impl/WeatherDataServiceImpl.java @@ -9,10 +9,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import lombok.val; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.constant.enums.WeatherDataSourceEnum; import org.jeecg.common.constant.enums.WeatherTypeEnum; -import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.exception.STASException; +import org.jeecg.common.exception.STASFileUploadException; import org.jeecg.common.properties.SystemStorageProperties; import org.jeecg.common.system.query.PageRequest; import org.jeecg.common.util.NcUtil; @@ -24,7 +26,10 @@ import org.jeecg.vo.FileUploadResultVo; import org.jeecg.vo.FileVo; import org.jeecg.vo.WeatherResultVO; import org.springframework.beans.BeanUtils; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Service; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import ucar.nc2.NetcdfFile; @@ -48,6 +53,8 @@ import java.util.Objects; public class WeatherDataServiceImpl extends ServiceImpl implements WeatherDataService { private final SystemStorageProperties systemStorageProperties; + private final DataSourceTransactionManager transactionManager; + private final TransactionDefinition transactionDefinition; /** * 根据类型和小时数获取天气数据 @@ -80,7 +87,7 @@ public class WeatherDataServiceImpl extends ServiceImpl0){ - //获取文件数据开始日期 - String reftime = NcUtil.getReftime(dataFile.getAbsolutePath()); - if(StringUtils.isNotBlank(reftime)) { + } + + if(flag) { + final TransactionStatus updateTransactionStatus = this.transactionManager.getTransaction(transactionDefinition); + try{ + //处理气象文件数据开始时间和计算文件大小 + WeatherData queryResult = this.baseMapper.selectById(id); + File dataFile = new File(storagePath); + if(dataFile.exists() && dataFile.length()>0){ + //获取文件数据开始日期 + String reftime = NcUtil.getReftime(dataFile.getAbsolutePath()); + if(StringUtils.isBlank(reftime)) { + throw new STASFileUploadException("解析气象文件起始时间数据异常,此文件可能损坏"); + } Instant instant = Instant.parse(reftime); LocalDateTime utcDateTime = LocalDateTime.ofInstant(instant, ZoneId.of("UTC")); queryResult.setDataStartTime(utcDateTime); + //计算文件大小M + BigDecimal divideVal = new BigDecimal("1024"); + BigDecimal bg = new BigDecimal(dataFile.length()); + BigDecimal fileSize = bg.divide(divideVal).divide(divideVal).setScale(2, RoundingMode.HALF_UP); + queryResult.setFileSize(fileSize.doubleValue()); + //把文件移入新路径 + int year = utcDateTime.getYear(); + int month = utcDateTime.getMonth().getValue(); + int day = utcDateTime.getDayOfMonth(); + String newFileDirPath = dataFile.getParentFile().getParent()+File.separator+year+File.separator+month+File.separator+day; + String newFilePath = newFileDirPath+File.separator+dataFile.getName(); + FileUtil.mkdir(newFileDirPath); + File parentDir = dataFile.getParentFile(); + File[] files = parentDir.listFiles(); + if(ArrayUtils.isNotEmpty(files)) { + for(File file : files) { + File targetFile = new File(newFileDirPath + File.separator + file.getName()); + FileUtil.move(file,targetFile,true); + } + } + //删除临时目录 + parentDir.delete(); + //给原路径变量重新赋值 + storagePath = newFileDirPath; + //修改文件新路径存到数据库 + queryResult.setFilePath(newFilePath); + this.baseMapper.updateById(queryResult); + this.transactionManager.commit(updateTransactionStatus); } - //计算文件大小M - BigDecimal divideVal = new BigDecimal("1024"); - BigDecimal bg = new BigDecimal(dataFile.length()); - BigDecimal fileSize = bg.divide(divideVal).divide(divideVal).setScale(2, RoundingMode.HALF_UP); - queryResult.setFileSize(fileSize.doubleValue()); - - this.baseMapper.updateById(queryResult); + }catch (Exception e){ + flag = false; } - - FileUploadResultVo result = new FileUploadResultVo(); - result.setCompleted(flag); - result.setId(id); - - return result; - }catch (Exception e){ - throw new RuntimeException(e); } + //如果单文件上传失败或者分片上传失败则删除数据 + if((!flag && !fileVo.isFileShare()) || + (!flag && fileVo.isFileShare() && fileVo.getShareIndex() == (fileVo.getShareTotal()-1))) { + String delDirPath = null; + File file = new File(storagePath); + if(file.exists() && file.isFile()){ + delDirPath = file.getParent(); + }else if(file.isDirectory()){ + delDirPath = file.getAbsolutePath(); + } + FileUtil.del(delDirPath); + final TransactionStatus delTransactionStatus = this.transactionManager.getTransaction(transactionDefinition); + this.baseMapper.deleteById(id); + this.transactionManager.commit(delTransactionStatus); + log.error("{}文件上传失败",fileVo.getFileName()); + throw new RuntimeException(fileVo.getFileName()+"文件上传失败"); + } + + FileUploadResultVo result = new FileUploadResultVo(); + result.setCompleted(flag); + result.setId(id); + return result; } /** @@ -273,7 +330,20 @@ public class WeatherDataServiceImpl extends ServiceImpl ids) { - this.baseMapper.deleteBatchIds(ids); + List weatherDatas = this.baseMapper.selectByIds(ids); + for(WeatherData weatherData : weatherDatas) { + //删除气象文件和生成的.gbx9、.ncx2文件 + File dataFile = new File(weatherData.getFilePath()); + if(dataFile.exists()) { + File[] files = dataFile.getParentFile().listFiles(); + for(File file : files) { + if(file.getName().startsWith(dataFile.getName()) || file.getName().equals(dataFile.getName())) { + file.delete(); + } + } + } + this.baseMapper.deleteById(weatherData.getId()); + } } /** @@ -281,12 +351,14 @@ public class WeatherDataServiceImpl extends ServiceImpl