From 0f46a245049c4023ec714421821d49ab44e673a6 Mon Sep 17 00:00:00 2001 From: XiaoHH <1431984546@qq.com> Date: Thu, 6 Jul 2023 14:33:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=85=B1=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api-passenger/pom.xml | 6 +++ common/common-annotation/pom.xml | 2 +- .../pom.xml | 2 +- .../com/greateme/contant/PackageContent.java | 0 .../business/VerificationCodeConstant.java | 0 .../com/greateme/contant/http/HttpStatus.java | 0 .../contant/http/ServiceNameConstant.java | 0 common/common-entity/pom.xml | 2 +- common/common-web/pom.xml | 38 ++++++++++++++++++ .../web/advice/CommonControllerAdvice.java | 40 +++++++++++++++++++ ...ot.autoconfigure.AutoConfiguration.imports | 1 + common/pom.xml | 3 +- pom.xml | 9 ++++- service/service-passenger-user/pom.xml | 6 +++ service/service-verification-code/pom.xml | 6 +++ 15 files changed, 110 insertions(+), 5 deletions(-) rename common/{common-contant => common-constant}/pom.xml (90%) rename common/{common-contant => common-constant}/src/main/java/com/greateme/contant/PackageContent.java (100%) rename common/{common-contant => common-constant}/src/main/java/com/greateme/contant/business/VerificationCodeConstant.java (100%) rename common/{common-contant => common-constant}/src/main/java/com/greateme/contant/http/HttpStatus.java (100%) rename common/{common-contant => common-constant}/src/main/java/com/greateme/contant/http/ServiceNameConstant.java (100%) create mode 100644 common/common-web/pom.xml create mode 100644 common/common-web/src/main/java/com/greateme/web/advice/CommonControllerAdvice.java create mode 100644 common/common-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/api/api-passenger/pom.xml b/api/api-passenger/pom.xml index e0db710..714db95 100644 --- a/api/api-passenger/pom.xml +++ b/api/api-passenger/pom.xml @@ -66,6 +66,12 @@ com.greateme verification-code-client + + + + com.greateme + common-web + diff --git a/common/common-annotation/pom.xml b/common/common-annotation/pom.xml index 3cc2566..5d66f8c 100644 --- a/common/common-annotation/pom.xml +++ b/common/common-annotation/pom.xml @@ -23,7 +23,7 @@ com.greateme - common-contant + common-constant diff --git a/common/common-contant/pom.xml b/common/common-constant/pom.xml similarity index 90% rename from common/common-contant/pom.xml rename to common/common-constant/pom.xml index a256979..78d90e2 100644 --- a/common/common-contant/pom.xml +++ b/common/common-constant/pom.xml @@ -10,6 +10,6 @@ 公共常量类模块 - common-contant + common-constant \ No newline at end of file diff --git a/common/common-contant/src/main/java/com/greateme/contant/PackageContent.java b/common/common-constant/src/main/java/com/greateme/contant/PackageContent.java similarity index 100% rename from common/common-contant/src/main/java/com/greateme/contant/PackageContent.java rename to common/common-constant/src/main/java/com/greateme/contant/PackageContent.java diff --git a/common/common-contant/src/main/java/com/greateme/contant/business/VerificationCodeConstant.java b/common/common-constant/src/main/java/com/greateme/contant/business/VerificationCodeConstant.java similarity index 100% rename from common/common-contant/src/main/java/com/greateme/contant/business/VerificationCodeConstant.java rename to common/common-constant/src/main/java/com/greateme/contant/business/VerificationCodeConstant.java diff --git a/common/common-contant/src/main/java/com/greateme/contant/http/HttpStatus.java b/common/common-constant/src/main/java/com/greateme/contant/http/HttpStatus.java similarity index 100% rename from common/common-contant/src/main/java/com/greateme/contant/http/HttpStatus.java rename to common/common-constant/src/main/java/com/greateme/contant/http/HttpStatus.java diff --git a/common/common-contant/src/main/java/com/greateme/contant/http/ServiceNameConstant.java b/common/common-constant/src/main/java/com/greateme/contant/http/ServiceNameConstant.java similarity index 100% rename from common/common-contant/src/main/java/com/greateme/contant/http/ServiceNameConstant.java rename to common/common-constant/src/main/java/com/greateme/contant/http/ServiceNameConstant.java diff --git a/common/common-entity/pom.xml b/common/common-entity/pom.xml index 224cfb1..22fab1a 100644 --- a/common/common-entity/pom.xml +++ b/common/common-entity/pom.xml @@ -16,7 +16,7 @@ com.greateme - common-contant + common-constant diff --git a/common/common-web/pom.xml b/common/common-web/pom.xml new file mode 100644 index 0000000..bb6accd --- /dev/null +++ b/common/common-web/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + + com.greateme + common + 1.0-SNAPSHOT + + jar + 公共的web模块 + + common-web + + + 11 + 11 + UTF-8 + + + + + + org.springframework.boot + spring-boot-starter-web + provided + + + + + com.greateme + common-entity + provided + + + + \ No newline at end of file diff --git a/common/common-web/src/main/java/com/greateme/web/advice/CommonControllerAdvice.java b/common/common-web/src/main/java/com/greateme/web/advice/CommonControllerAdvice.java new file mode 100644 index 0000000..7a28d40 --- /dev/null +++ b/common/common-web/src/main/java/com/greateme/web/advice/CommonControllerAdvice.java @@ -0,0 +1,40 @@ +package com.greateme.web.advice; + +import com.greateme.entity.respose.ResponseEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + *

+ * 公共的异常处理类 + *

+ * + * @author XiaoHH + * @version 1.0.0 + * @date 2023-07-06 星期四 14:15:14 + * @file CommonControllerAdvice.java + */ +@Component +@RestControllerAdvice +public class CommonControllerAdvice { + + /** + * 日志记录对象 + */ + private static final Logger log = LoggerFactory.getLogger(CommonControllerAdvice.class); + + /** + * 所有异常的公共捕获类,兜底的方法 + * + * @param e 异常对象 + * @return 返回给前端的内容 + */ + @ExceptionHandler(Throwable.class) + public ResponseEntity handleThrowable(Throwable e) { + log.error("接收用户请求了发生错误", e); + return ResponseEntity.error(e.getMessage()); + } +} diff --git a/common/common-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/common/common-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..9fa1695 --- /dev/null +++ b/common/common-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.greateme.web.advice.CommonControllerAdvice \ No newline at end of file diff --git a/common/pom.xml b/common/pom.xml index e18a9a9..3a26b7f 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -14,8 +14,9 @@ common-entity common-util - common-contant + common-constant common-annotation + common-web common diff --git a/pom.xml b/pom.xml index 2c8a4d4..b5f2ebc 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ com.greateme - common-contant + common-constant ${online-taxi-public.version} @@ -98,6 +98,13 @@ common-annotation ${online-taxi-public.version} + + + + com.greateme + common-web + ${online-taxi-public.version} + \ No newline at end of file diff --git a/service/service-passenger-user/pom.xml b/service/service-passenger-user/pom.xml index dbe2cc9..a65de6f 100644 --- a/service/service-passenger-user/pom.xml +++ b/service/service-passenger-user/pom.xml @@ -72,6 +72,12 @@ com.greateme common-annotation + + + + com.greateme + common-web + diff --git a/service/service-verification-code/pom.xml b/service/service-verification-code/pom.xml index eaa3d8d..b592bfc 100644 --- a/service/service-verification-code/pom.xml +++ b/service/service-verification-code/pom.xml @@ -66,6 +66,12 @@ com.greateme common-annotation + + + + com.greateme + common-web +