From 12887cc1695bd79bd14a94af7d98bc06315fe6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E7=8B=BC=E8=93=9D=E5=A4=A9?= Date: Mon, 23 Sep 2024 21:26:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E5=92=8C=E9=94=99=E8=AF=AF=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/GlobalExceptionHandler.java | 11 +++-- .../harmony/controller/命名规范.md | 4 ++ .../harmony/domain/{about.txt => about.md} | 3 ++ src/main/resources/logback-spring.xml | 44 +++++++++++++++---- 4 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/guaiguailang/harmony/controller/命名规范.md rename src/main/java/com/guaiguailang/harmony/domain/{about.txt => about.md} (98%) diff --git a/src/main/java/com/guaiguailang/harmony/config/GlobalExceptionHandler.java b/src/main/java/com/guaiguailang/harmony/config/GlobalExceptionHandler.java index b7af2ad..2b2e310 100644 --- a/src/main/java/com/guaiguailang/harmony/config/GlobalExceptionHandler.java +++ b/src/main/java/com/guaiguailang/harmony/config/GlobalExceptionHandler.java @@ -4,6 +4,8 @@ import cn.dev33.satoken.util.SaResult; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.fusesource.jansi.Ansi; +import java.util.Arrays; @RestControllerAdvice @Slf4j @@ -11,8 +13,11 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; public class GlobalExceptionHandler { // 全局异常拦截 @ExceptionHandler - public SaResult handlerException(Exception e) { - log.error(e.getMessage()); - return SaResult.error(e.getMessage()); + public void handlerException(Exception e) { + System.err.println(Ansi.ansi().fgRed().a("==========ERROR==========START==========").reset()); + System.err.println(Ansi.ansi().fgRed().a("错误消息:").a(e.getMessage()).reset()); + System.err.println(Ansi.ansi().fgRed().a("错误类型:").a(e.getLocalizedMessage()).reset()); + System.err.println(Ansi.ansi().fgRed().a(e.getCause() == null ? "" : e.getCause().toString()).reset()); + System.err.println(Ansi.ansi().fgRed().a("==========ERROR========== END ==========").reset()); } } diff --git a/src/main/java/com/guaiguailang/harmony/controller/命名规范.md b/src/main/java/com/guaiguailang/harmony/controller/命名规范.md new file mode 100644 index 0000000..db1c9bf --- /dev/null +++ b/src/main/java/com/guaiguailang/harmony/controller/命名规范.md @@ -0,0 +1,4 @@ + + +比如xxxController,里面的@RequestMapping就写@RequestMapping("/xxx") + diff --git a/src/main/java/com/guaiguailang/harmony/domain/about.txt b/src/main/java/com/guaiguailang/harmony/domain/about.md similarity index 98% rename from src/main/java/com/guaiguailang/harmony/domain/about.txt rename to src/main/java/com/guaiguailang/harmony/domain/about.md index 31df0f2..e561c8f 100644 --- a/src/main/java/com/guaiguailang/harmony/domain/about.txt +++ b/src/main/java/com/guaiguailang/harmony/domain/about.md @@ -1,4 +1,7 @@ domain 文件夹包含了 + entity(持久化对象), 映射数据库数据表的字段 + dto(Data Transfer Object)(数据传输对象), 接收前端参数的对象 + vo(Value Object)(值对象) 响应值对象 \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 1683813..b91d791 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,27 +1,53 @@ - - + + + + + - %d{HH:mm:ss.SSS} [%thread] %-5level 【 %logger{36} 】 %msg%n + %d{HH:mm:ss} %-5level %logger{36} - %msg%n + UTF-8 + + + ERROR + DENY + NEUTRAL + + + ERROR + ACCEPT + DENY + + - logs/app.log + logs/application.log %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + ERROR + DENY + NEUTRAL + + + ERROR + ACCEPT + DENY + + - - - - - + + + \ No newline at end of file