mirror of
https://gitee.com/ChinaLym/shoulder-platform.git
synced 2025-12-30 02:52:27 +00:00
dev
This commit is contained in:
@@ -16,8 +16,9 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<!-- java.version-->
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
@@ -22,6 +22,6 @@ public class ShoulderApiGateway {
|
||||
|
||||
@RequestMapping("/fallback")
|
||||
public Mono<BaseResult> fallback() {
|
||||
return Mono.just(BaseResult.error(CommonErrorCodeEnum.REQUEST_TIMEOUT));
|
||||
return Mono.just(BaseResult.error(CommonErrorCodeEnum.SERVICE_RESPONSE_TIMEOUT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ViewResolver> viewResolvers,
|
||||
ServerCodecConfigurer serverCodecConfigurer) {
|
||||
@@ -82,12 +90,12 @@ public class JsonExceptionHandler extends DefaultErrorWebExceptionHandler {
|
||||
* 为了安全,不打印堆栈信息,即使使用者手动开启
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> getErrorAttributes(ServerRequest request, boolean includeStackTrace) {
|
||||
protected Map<String, Object> 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<ServerResponse> renderErrorResponse(ServerRequest request) {
|
||||
boolean includeStackTrace = isIncludeStackTrace(request, MediaType.ALL);
|
||||
Map<String, Object> error = getErrorAttributes(request, includeStackTrace);
|
||||
ErrorAttributeOptions errorAttributeOptions = getErrorAttributeOptions(request, MediaType.ALL);
|
||||
Map<String, Object> error = getErrorAttributes(request, errorAttributeOptions);
|
||||
return ServerResponse.status(getHttpStatus(error)).contentType(MediaType.APPLICATION_JSON)
|
||||
.body(BodyInserters.fromValue(error));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>shoulder-generator</artifactId>
|
||||
<name>代码生成器</name>
|
||||
<name>shoulder-generator:代码生成器</name>
|
||||
<description>代码生成器</description>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -47,9 +47,12 @@
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<!--<module>system-config</module>--> <!--系统配置使用 nacos 管理-->
|
||||
<!-- TODO 系统配置后续使用专门的配置中心管理,如 nacos、apollo -->
|
||||
<module>system-config</module>
|
||||
<module>system-dictionary</module>
|
||||
<module>system-error-code</module>
|
||||
</modules>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JPA -->
|
||||
|
||||
@@ -2,13 +2,9 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
|
||||
<groupId>cn.itlym.platform</groupId>
|
||||
|
||||
<artifactId>shoulder-user-center</artifactId>
|
||||
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -24,11 +20,8 @@
|
||||
<!-- 统一依赖 core -->
|
||||
|
||||
<dependency>
|
||||
|
||||
<groupId>cn.itlym.platform</groupId>
|
||||
|
||||
<artifactId>uaa-core</artifactId>
|
||||
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
Reference in New Issue
Block a user