diff --git a/boot/platform/src/main/java/com/platform/boot/commons/annotation/GlobalExceptionHandler.java b/boot/platform/src/main/java/com/platform/boot/commons/ExceptionHandler.java similarity index 87% rename from boot/platform/src/main/java/com/platform/boot/commons/annotation/GlobalExceptionHandler.java rename to boot/platform/src/main/java/com/platform/boot/commons/ExceptionHandler.java index 08ec2128..bf4b6482 100644 --- a/boot/platform/src/main/java/com/platform/boot/commons/annotation/GlobalExceptionHandler.java +++ b/boot/platform/src/main/java/com/platform/boot/commons/ExceptionHandler.java @@ -1,9 +1,8 @@ -package com.platform.boot.commons.annotation; +package com.platform.boot.commons; import com.google.common.collect.Lists; -import com.platform.boot.commons.ErrorResponse; -import com.platform.boot.commons.annotation.exception.ClientException; -import com.platform.boot.commons.annotation.exception.RestServerException; +import com.platform.boot.commons.exception.ClientException; +import com.platform.boot.commons.exception.RestServerException; import io.r2dbc.spi.R2dbcException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -14,7 +13,6 @@ import org.springframework.r2dbc.BadSqlGrammarException; import org.springframework.validation.ObjectError; import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.support.WebExchangeBindException; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebInputException; @@ -25,11 +23,11 @@ * @author Alex bob */ @ControllerAdvice -public class GlobalExceptionHandler { +public class ExceptionHandler { - private static final Log log = LogFactory.getLog(GlobalExceptionHandler.class); + private static final Log log = LogFactory.getLog(ExceptionHandler.class); - @ExceptionHandler(ServerWebInputException.class) + @org.springframework.web.bind.annotation.ExceptionHandler(ServerWebInputException.class) public ResponseEntity handleBindException(ServerWebExchange exchange, ServerWebInputException ex) { List errors = Lists.newArrayList(ex.getLocalizedMessage()); if (ex instanceof WebExchangeBindException bindException) { @@ -52,7 +50,7 @@ public ResponseEntity handleBindException(ServerWebExchange excha 4170, "请求参数验证失败!", errors)); } - @ExceptionHandler({DataAccessException.class, R2dbcException.class}) + @org.springframework.web.bind.annotation.ExceptionHandler({DataAccessException.class, R2dbcException.class}) public ResponseEntity handleFailureException(ServerWebExchange exchange, RuntimeException ex) { List errors = Lists.newArrayList(ex.getLocalizedMessage()); if (ex instanceof R2dbcException r2dbcException) { @@ -74,7 +72,7 @@ public ResponseEntity handleFailureException(ServerWebExchange ex 5070, "数据库操作错误!", errors)); } - @ExceptionHandler(ClientException.class) + @org.springframework.web.bind.annotation.ExceptionHandler(ClientException.class) public ResponseEntity handleClientException(ServerWebExchange exchange, ClientException ex) { log.error("%s内部服务访问错误! 信息: %s".formatted(exchange.getLogPrefix(), ex.getMessage())); if (log.isDebugEnabled()) { @@ -85,7 +83,7 @@ public ResponseEntity handleClientException(ServerWebExchange exc ex.getCode(), ex.getServiceId() + "内部服务访问错误!", ex.getMsg())); } - @ExceptionHandler(RestServerException.class) + @org.springframework.web.bind.annotation.ExceptionHandler(RestServerException.class) public ResponseEntity handleRestServerException(ServerWebExchange exchange, RestServerException ex) { log.error("%s服务器自定义错误! 信息: %s".formatted(exchange.getLogPrefix(), ex.getMessage())); if (log.isDebugEnabled()) { @@ -96,7 +94,7 @@ public ResponseEntity handleRestServerException(ServerWebExchange ex.getCode(), "服务自定义错误!", ex.getMsg())); } - @ExceptionHandler(Exception.class) + @org.springframework.web.bind.annotation.ExceptionHandler(Exception.class) public ResponseEntity handleException(ServerWebExchange exchange, Exception ex) { log.error("%s服务器未知错误! 信息: %s".formatted(exchange.getLogPrefix(), ex.getMessage())); if (log.isDebugEnabled()) { diff --git a/boot/platform/src/main/java/com/platform/boot/commons/Snowflake.java b/boot/platform/src/main/java/com/platform/boot/commons/Snowflake.java index ea3bc91f..b42a927f 100644 --- a/boot/platform/src/main/java/com/platform/boot/commons/Snowflake.java +++ b/boot/platform/src/main/java/com/platform/boot/commons/Snowflake.java @@ -1,6 +1,6 @@ package com.platform.boot.commons; -import com.platform.boot.commons.annotation.exception.RestServerException; +import com.platform.boot.commons.exception.RestServerException; import java.io.Serializable; diff --git a/boot/platform/src/main/java/com/platform/boot/commons/base/BaseEntity.java b/boot/platform/src/main/java/com/platform/boot/commons/base/BaseEntity.java index 8e39610d..ad9941fd 100644 --- a/boot/platform/src/main/java/com/platform/boot/commons/base/BaseEntity.java +++ b/boot/platform/src/main/java/com/platform/boot/commons/base/BaseEntity.java @@ -1,6 +1,7 @@ package com.platform.boot.commons.base; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.platform.boot.commons.utils.ContextUtils; import com.platform.boot.commons.utils.CriteriaUtils; import org.springframework.data.domain.Persistable; import org.springframework.data.relational.core.query.Criteria; @@ -42,7 +43,7 @@ default void setCode(String code) { default boolean isNew() { boolean isNew = ObjectUtils.isEmpty(getId()); if (isNew) { - setCode(String.valueOf(getId())); + setCode(ContextUtils.nextId()); } return isNew; } diff --git a/boot/platform/src/main/java/com/platform/boot/commons/annotation/exception/ClientException.java b/boot/platform/src/main/java/com/platform/boot/commons/exception/ClientException.java similarity index 90% rename from boot/platform/src/main/java/com/platform/boot/commons/annotation/exception/ClientException.java rename to boot/platform/src/main/java/com/platform/boot/commons/exception/ClientException.java index 54ae5e11..be404b7d 100644 --- a/boot/platform/src/main/java/com/platform/boot/commons/annotation/exception/ClientException.java +++ b/boot/platform/src/main/java/com/platform/boot/commons/exception/ClientException.java @@ -1,4 +1,4 @@ -package com.platform.boot.commons.annotation.exception; +package com.platform.boot.commons.exception; import lombok.Getter; diff --git a/boot/platform/src/main/java/com/platform/boot/commons/annotation/exception/JsonException.java b/boot/platform/src/main/java/com/platform/boot/commons/exception/JsonException.java similarity index 90% rename from boot/platform/src/main/java/com/platform/boot/commons/annotation/exception/JsonException.java rename to boot/platform/src/main/java/com/platform/boot/commons/exception/JsonException.java index 67be0ccd..9ddfbc9b 100644 --- a/boot/platform/src/main/java/com/platform/boot/commons/annotation/exception/JsonException.java +++ b/boot/platform/src/main/java/com/platform/boot/commons/exception/JsonException.java @@ -1,4 +1,4 @@ -package com.platform.boot.commons.annotation.exception; +package com.platform.boot.commons.exception; import java.io.IOException; diff --git a/boot/platform/src/main/java/com/platform/boot/commons/annotation/exception/RestServerException.java b/boot/platform/src/main/java/com/platform/boot/commons/exception/RestServerException.java similarity index 93% rename from boot/platform/src/main/java/com/platform/boot/commons/annotation/exception/RestServerException.java rename to boot/platform/src/main/java/com/platform/boot/commons/exception/RestServerException.java index f5a578b0..6e43beb3 100644 --- a/boot/platform/src/main/java/com/platform/boot/commons/annotation/exception/RestServerException.java +++ b/boot/platform/src/main/java/com/platform/boot/commons/exception/RestServerException.java @@ -1,5 +1,5 @@ // Define the package name -package com.platform.boot.commons.annotation.exception; +package com.platform.boot.commons.exception; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/boot/platform/src/main/java/com/platform/boot/commons/utils/BeanUtils.java b/boot/platform/src/main/java/com/platform/boot/commons/utils/BeanUtils.java index 47e21df9..2655e3ac 100644 --- a/boot/platform/src/main/java/com/platform/boot/commons/utils/BeanUtils.java +++ b/boot/platform/src/main/java/com/platform/boot/commons/utils/BeanUtils.java @@ -5,8 +5,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.google.common.collect.Maps; -import com.platform.boot.commons.annotation.exception.JsonException; -import com.platform.boot.commons.annotation.exception.RestServerException; +import com.platform.boot.commons.exception.JsonException; +import com.platform.boot.commons.exception.RestServerException; import org.springframework.util.ObjectUtils; import org.springframework.util.unit.DataSize; diff --git a/boot/platform/src/main/java/com/platform/boot/commons/utils/ContextUtils.java b/boot/platform/src/main/java/com/platform/boot/commons/utils/ContextUtils.java index 7ac4aff6..25fb3aef 100644 --- a/boot/platform/src/main/java/com/platform/boot/commons/utils/ContextUtils.java +++ b/boot/platform/src/main/java/com/platform/boot/commons/utils/ContextUtils.java @@ -3,8 +3,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.platform.boot.commons.Snowflake; -import com.platform.boot.commons.annotation.exception.JsonException; -import com.platform.boot.commons.annotation.exception.RestServerException; +import com.platform.boot.commons.exception.JsonException; +import com.platform.boot.commons.exception.RestServerException; import com.platform.boot.security.SecurityDetails; import com.platform.boot.security.core.UserAuditor; import com.platform.boot.security.core.user.UsersService; diff --git a/boot/platform/src/main/java/com/platform/boot/config/SessionConfiguration.java b/boot/platform/src/main/java/com/platform/boot/config/SessionConfiguration.java index 9ec67087..89c131fb 100644 --- a/boot/platform/src/main/java/com/platform/boot/config/SessionConfiguration.java +++ b/boot/platform/src/main/java/com/platform/boot/config/SessionConfiguration.java @@ -1,6 +1,6 @@ package com.platform.boot.config; -import com.platform.boot.commons.annotation.exception.RestServerException; +import com.platform.boot.commons.exception.RestServerException; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; diff --git a/boot/platform/src/main/java/com/platform/boot/converters/CollectionConverter.java b/boot/platform/src/main/java/com/platform/boot/converters/CollectionConverter.java index 4e608f99..e47f2518 100644 --- a/boot/platform/src/main/java/com/platform/boot/converters/CollectionConverter.java +++ b/boot/platform/src/main/java/com/platform/boot/converters/CollectionConverter.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; -import com.platform.boot.commons.annotation.exception.JsonException; +import com.platform.boot.commons.exception.JsonException; import com.platform.boot.commons.utils.ContextUtils; import io.r2dbc.postgresql.codec.Json; import lombok.NonNull; diff --git a/boot/platform/src/main/java/com/platform/boot/converters/JsonNodeConverters.java b/boot/platform/src/main/java/com/platform/boot/converters/JsonNodeConverters.java index a383a623..290570b2 100644 --- a/boot/platform/src/main/java/com/platform/boot/converters/JsonNodeConverters.java +++ b/boot/platform/src/main/java/com/platform/boot/converters/JsonNodeConverters.java @@ -1,7 +1,7 @@ package com.platform.boot.converters; import com.fasterxml.jackson.databind.JsonNode; -import com.platform.boot.commons.annotation.exception.JsonException; +import com.platform.boot.commons.exception.JsonException; import com.platform.boot.commons.utils.ContextUtils; import io.r2dbc.postgresql.codec.Json; import lombok.NonNull; diff --git a/boot/platform/src/main/java/com/platform/boot/relational/LoggerFilter.java b/boot/platform/src/main/java/com/platform/boot/relational/LoggerFilter.java index 5593a360..ad8e7ecf 100644 --- a/boot/platform/src/main/java/com/platform/boot/relational/LoggerFilter.java +++ b/boot/platform/src/main/java/com/platform/boot/relational/LoggerFilter.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.platform.boot.commons.annotation.exception.JsonException; +import com.platform.boot.commons.exception.JsonException; import com.platform.boot.commons.utils.ContextUtils; import com.platform.boot.relational.logger.LoggerRequest; import com.platform.boot.relational.logger.LoggersService; diff --git a/boot/platform/src/main/java/com/platform/boot/relational/menus/MenusService.java b/boot/platform/src/main/java/com/platform/boot/relational/menus/MenusService.java index d3f7020b..7b662524 100644 --- a/boot/platform/src/main/java/com/platform/boot/relational/menus/MenusService.java +++ b/boot/platform/src/main/java/com/platform/boot/relational/menus/MenusService.java @@ -1,8 +1,8 @@ package com.platform.boot.relational.menus; -import com.platform.boot.commons.annotation.exception.RestServerException; import com.platform.boot.commons.base.AbstractDatabase; +import com.platform.boot.commons.exception.RestServerException; import com.platform.boot.commons.utils.ContextUtils; import com.platform.boot.security.core.group.authority.GroupAuthoritiesRepository; import com.platform.boot.security.core.user.authority.UserAuthoritiesRepository; diff --git a/boot/platform/src/main/java/com/platform/boot/security/SecurityController.java b/boot/platform/src/main/java/com/platform/boot/security/SecurityController.java index 2925d16a..369ff1b6 100644 --- a/boot/platform/src/main/java/com/platform/boot/security/SecurityController.java +++ b/boot/platform/src/main/java/com/platform/boot/security/SecurityController.java @@ -1,6 +1,6 @@ package com.platform.boot.security; -import com.platform.boot.commons.annotation.exception.RestServerException; +import com.platform.boot.commons.exception.RestServerException; import com.platform.boot.commons.utils.ContextUtils; import com.platform.boot.security.core.AuthenticationToken; import jakarta.validation.Valid; diff --git a/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersService.java b/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersService.java index 2936540a..554f42d5 100644 --- a/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersService.java +++ b/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersService.java @@ -1,7 +1,7 @@ package com.platform.boot.security.core.user; -import com.platform.boot.commons.annotation.exception.RestServerException; import com.platform.boot.commons.base.AbstractDatabase; +import com.platform.boot.commons.exception.RestServerException; import com.platform.boot.commons.query.ParamSql; import com.platform.boot.commons.query.QueryJson; import com.platform.boot.commons.utils.BeanUtils;