From ee9790c34e1a83a5e2e4c5f3a8ffa1cbd2f97756 Mon Sep 17 00:00:00 2001 From: lym Date: Thu, 18 Apr 2024 20:24:15 +0800 Subject: [PATCH] dev --- shoulder-backstage/pom.xml | 5 ++-- .../platform/gateway/ShoulderApiGateway.java | 2 +- .../gateway/config/JsonExceptionHandler.java | 28 ++++++++++++------- shoulder-generator/pom.xml | 11 +++++--- .../service/impl/SysGeneratorServiceImpl.java | 6 ++-- shoulder-system-center/system-modules/pom.xml | 3 +- .../uaa-infrastructure/uaa-storage/pom.xml | 1 - shoulder-user-center/uaa-modules/pom.xml | 7 ----- 8 files changed, 35 insertions(+), 28 deletions(-) diff --git a/shoulder-backstage/pom.xml b/shoulder-backstage/pom.xml index 4ee7bcb..6c9110c 100644 --- a/shoulder-backstage/pom.xml +++ b/shoulder-backstage/pom.xml @@ -16,8 +16,9 @@ org.apache.maven.plugins maven-compiler-plugin - ${java.version} - ${java.version} + + 17 + 17 diff --git a/shoulder-gateway/shoulder-api-gateway/src/main/java/cn/itlym/shoulder/platform/gateway/ShoulderApiGateway.java b/shoulder-gateway/shoulder-api-gateway/src/main/java/cn/itlym/shoulder/platform/gateway/ShoulderApiGateway.java index 7749bbd..eb60abc 100644 --- a/shoulder-gateway/shoulder-api-gateway/src/main/java/cn/itlym/shoulder/platform/gateway/ShoulderApiGateway.java +++ b/shoulder-gateway/shoulder-api-gateway/src/main/java/cn/itlym/shoulder/platform/gateway/ShoulderApiGateway.java @@ -22,6 +22,6 @@ public class ShoulderApiGateway { @RequestMapping("/fallback") public Mono fallback() { - return Mono.just(BaseResult.error(CommonErrorCodeEnum.REQUEST_TIMEOUT)); + return Mono.just(BaseResult.error(CommonErrorCodeEnum.SERVICE_RESPONSE_TIMEOUT)); } } diff --git a/shoulder-gateway/shoulder-api-gateway/src/main/java/cn/itlym/shoulder/platform/gateway/config/JsonExceptionHandler.java b/shoulder-gateway/shoulder-api-gateway/src/main/java/cn/itlym/shoulder/platform/gateway/config/JsonExceptionHandler.java index 96b3c1d..6bf2542 100644 --- a/shoulder-gateway/shoulder-api-gateway/src/main/java/cn/itlym/shoulder/platform/gateway/config/JsonExceptionHandler.java +++ b/shoulder-gateway/shoulder-api-gateway/src/main/java/cn/itlym/shoulder/platform/gateway/config/JsonExceptionHandler.java @@ -1,14 +1,16 @@ package cn.itlym.shoulder.platform.gateway.config; import cn.itlym.shoulder.platform.gateway.ex.ShoulderGatewayException; -import lombok.extern.shoulder.SLog; import org.shoulder.core.dto.response.BaseResult; import org.shoulder.core.exception.ErrorCode; +import org.shoulder.core.log.AppLoggers; +import org.shoulder.core.log.Logger; import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.web.ResourceProperties; import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.boot.autoconfigure.web.WebProperties; import org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler; import org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration; +import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.reactive.error.ErrorAttributes; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Configuration; @@ -18,8 +20,13 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.codec.ServerCodecConfigurer; import org.springframework.lang.NonNull; +import org.springframework.web.ErrorResponseException; import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.*; +import org.springframework.web.reactive.function.server.RequestPredicates; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; import org.springframework.web.reactive.result.view.ViewResolver; import org.springframework.web.server.ResponseStatusException; import reactor.core.publisher.Mono; @@ -33,13 +40,14 @@ import java.util.stream.Collectors; * * @author lym */ -@SLog @Configuration( proxyBeanMethods = false ) @Order(Ordered.HIGHEST_PRECEDENCE) public class JsonExceptionHandler extends DefaultErrorWebExceptionHandler { + private static final Logger log = AppLoggers.APP_ERROR; + private static final String ATTRIBUTE_NAME_HTTP_STATUS = "httpStatus"; private static final String ATTRIBUTE_NAME_RESPONSE = "shoulderResponseBody"; @@ -52,7 +60,7 @@ public class JsonExceptionHandler extends DefaultErrorWebExceptionHandler { /** * @see ErrorWebFluxAutoConfiguration#errorWebExceptionHandler */ - public JsonExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties, + public JsonExceptionHandler(ErrorAttributes errorAttributes, WebProperties.Resources resourceProperties, ServerProperties serverProperties, ApplicationContext applicationContext, ObjectProvider viewResolvers, ServerCodecConfigurer serverCodecConfigurer) { @@ -82,12 +90,12 @@ public class JsonExceptionHandler extends DefaultErrorWebExceptionHandler { * 为了安全,不打印堆栈信息,即使使用者手动开启 */ @Override - protected Map getErrorAttributes(ServerRequest request, boolean includeStackTrace) { + protected Map getErrorAttributes(ServerRequest request, ErrorAttributeOptions options) { int httpStatus = DEFAULT_SERVER_ERROR_HTTP_STATUS; Throwable error = super.getError(request); - if (error instanceof ResponseStatusException) { + if (error instanceof ErrorResponseException) { // spring 定义的 http 异常 - httpStatus = ((ResponseStatusException) error).getStatus().value(); + httpStatus = ((ResponseStatusException) error).getStatusCode().value(); } else if (error instanceof ErrorCode) { // shoulder 定义的异常 ErrorCode errorCode = (ErrorCode) error; @@ -116,8 +124,8 @@ public class JsonExceptionHandler extends DefaultErrorWebExceptionHandler { @NonNull @Override protected Mono renderErrorResponse(ServerRequest request) { - boolean includeStackTrace = isIncludeStackTrace(request, MediaType.ALL); - Map error = getErrorAttributes(request, includeStackTrace); + ErrorAttributeOptions errorAttributeOptions = getErrorAttributeOptions(request, MediaType.ALL); + Map error = getErrorAttributes(request, errorAttributeOptions); return ServerResponse.status(getHttpStatus(error)).contentType(MediaType.APPLICATION_JSON) .body(BodyInserters.fromValue(error)); } diff --git a/shoulder-generator/pom.xml b/shoulder-generator/pom.xml index 74100db..7343a28 100644 --- a/shoulder-generator/pom.xml +++ b/shoulder-generator/pom.xml @@ -10,7 +10,7 @@ 4.0.0 shoulder-generator - 代码生成器 + shoulder-generator:代码生成器 代码生成器 @@ -47,9 +47,12 @@ spring-boot-starter-jdbc - org.mybatis.spring.boot - mybatis-spring-boot-starter - 2.1.3 + com.baomidou + mybatis-plus-spring-boot3-starter + + + com.baomidou + mybatis-plus-generator com.github.pagehelper diff --git a/shoulder-generator/src/main/java/cn/itlym/shoulder/generator/service/impl/SysGeneratorServiceImpl.java b/shoulder-generator/src/main/java/cn/itlym/shoulder/generator/service/impl/SysGeneratorServiceImpl.java index bac96e7..c380ebb 100644 --- a/shoulder-generator/src/main/java/cn/itlym/shoulder/generator/service/impl/SysGeneratorServiceImpl.java +++ b/shoulder-generator/src/main/java/cn/itlym/shoulder/generator/service/impl/SysGeneratorServiceImpl.java @@ -5,11 +5,12 @@ import cn.itlym.shoulder.generator.service.SysGeneratorService; import cn.itlym.shoulder.generator.utils.GenUtils; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; -import lombok.extern.shoulder.SLog; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.io.IOUtils; import org.shoulder.core.dto.response.PageResult; +import org.shoulder.core.log.AppLoggers; +import org.shoulder.core.log.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -22,10 +23,11 @@ import java.util.zip.ZipOutputStream; /** * @author lym */ -@SLog @Service public class SysGeneratorServiceImpl implements SysGeneratorService { + private final Logger log = AppLoggers.APP_SERVICE; + @Autowired private SysGeneratorMapper sysGeneratorMapper; diff --git a/shoulder-system-center/system-modules/pom.xml b/shoulder-system-center/system-modules/pom.xml index 8a3672c..0d1b234 100644 --- a/shoulder-system-center/system-modules/pom.xml +++ b/shoulder-system-center/system-modules/pom.xml @@ -13,7 +13,8 @@ pom - + + system-config system-dictionary system-error-code diff --git a/shoulder-user-center/uaa-infrastructure/uaa-storage/pom.xml b/shoulder-user-center/uaa-infrastructure/uaa-storage/pom.xml index b4ddcbc..fc1089d 100644 --- a/shoulder-user-center/uaa-infrastructure/uaa-storage/pom.xml +++ b/shoulder-user-center/uaa-infrastructure/uaa-storage/pom.xml @@ -22,7 +22,6 @@ com.baomidou mybatis-plus-annotation - ${mybatis-plus.version} diff --git a/shoulder-user-center/uaa-modules/pom.xml b/shoulder-user-center/uaa-modules/pom.xml index d28437b..56ab30c 100644 --- a/shoulder-user-center/uaa-modules/pom.xml +++ b/shoulder-user-center/uaa-modules/pom.xml @@ -2,13 +2,9 @@ - cn.itlym.platform - shoulder-user-center - 1.0-SNAPSHOT - 4.0.0 @@ -24,11 +20,8 @@ - cn.itlym.platform - uaa-core -