From 549732d7cf82fab6ceffa56e3f775c584090eae3 Mon Sep 17 00:00:00 2001 From: 3juhwan <13selfesteem91@naver.com> Date: Mon, 19 Aug 2024 16:00:30 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=98=95=ED=83=9C=EC=9D=98=20=EC=9A=94=EC=B2=AD=20=EB=B0=94?= =?UTF-8?q?=EB=94=94=EC=97=90=20null=EC=9D=84=20=EB=84=A3=EC=9C=BC?= =?UTF-8?q?=EB=A9=B4=20500=EC=9D=B4=20=EB=9C=A8=EB=8A=94=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../haengdong/presentation/BillActionController.java | 2 +- .../request/BillActionDetailsUpdateRequest.java | 7 ++++--- .../presentation/request/BillActionsSaveRequest.java | 3 ++- .../presentation/request/MemberActionsSaveRequest.java | 3 +++ .../presentation/request/MemberNamesUpdateRequest.java | 7 ++++--- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/server/haengdong/presentation/BillActionController.java b/server/src/main/java/server/haengdong/presentation/BillActionController.java index 94cd1666b..56e99337d 100644 --- a/server/src/main/java/server/haengdong/presentation/BillActionController.java +++ b/server/src/main/java/server/haengdong/presentation/BillActionController.java @@ -22,7 +22,7 @@ public class BillActionController { @PostMapping("/api/events/{eventId}/bill-actions") public ResponseEntity saveAllBillAction( @PathVariable("eventId") String token, - @RequestBody @Valid BillActionsSaveRequest request + @Valid @RequestBody BillActionsSaveRequest request ) { billActionService.saveAllBillAction(token, request.toAppRequests()); diff --git a/server/src/main/java/server/haengdong/presentation/request/BillActionDetailsUpdateRequest.java b/server/src/main/java/server/haengdong/presentation/request/BillActionDetailsUpdateRequest.java index 2cd79b61d..fafbb8fd7 100644 --- a/server/src/main/java/server/haengdong/presentation/request/BillActionDetailsUpdateRequest.java +++ b/server/src/main/java/server/haengdong/presentation/request/BillActionDetailsUpdateRequest.java @@ -1,15 +1,16 @@ package server.haengdong.presentation.request; import jakarta.validation.Valid; +import jakarta.validation.constraints.NotEmpty; import java.util.List; import server.haengdong.application.request.BillActionDetailsUpdateAppRequest; public record BillActionDetailsUpdateRequest( - @Valid List members + @Valid @NotEmpty List members ) { public BillActionDetailsUpdateAppRequest toAppRequest() { return new BillActionDetailsUpdateAppRequest(members.stream() - .map(BillActionDetailUpdateRequest::toAppRequest) - .toList()); + .map(BillActionDetailUpdateRequest::toAppRequest) + .toList()); } } diff --git a/server/src/main/java/server/haengdong/presentation/request/BillActionsSaveRequest.java b/server/src/main/java/server/haengdong/presentation/request/BillActionsSaveRequest.java index 42bf86149..6727d4cf1 100644 --- a/server/src/main/java/server/haengdong/presentation/request/BillActionsSaveRequest.java +++ b/server/src/main/java/server/haengdong/presentation/request/BillActionsSaveRequest.java @@ -1,12 +1,13 @@ package server.haengdong.presentation.request; import jakarta.validation.Valid; +import jakarta.validation.constraints.NotEmpty; import java.util.List; import server.haengdong.application.request.BillActionAppRequest; public record BillActionsSaveRequest( - @Valid List actions + @Valid @NotEmpty List actions ) { public List toAppRequests() { diff --git a/server/src/main/java/server/haengdong/presentation/request/MemberActionsSaveRequest.java b/server/src/main/java/server/haengdong/presentation/request/MemberActionsSaveRequest.java index 828fc7b4c..41e95cc3c 100644 --- a/server/src/main/java/server/haengdong/presentation/request/MemberActionsSaveRequest.java +++ b/server/src/main/java/server/haengdong/presentation/request/MemberActionsSaveRequest.java @@ -1,11 +1,14 @@ package server.haengdong.presentation.request; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; import java.util.List; import server.haengdong.application.request.MemberActionSaveAppRequest; import server.haengdong.application.request.MemberActionsSaveAppRequest; public record MemberActionsSaveRequest( + + @NotEmpty List members, @NotBlank(message = "멤버 액션은 공백일 수 없습니다.") diff --git a/server/src/main/java/server/haengdong/presentation/request/MemberNamesUpdateRequest.java b/server/src/main/java/server/haengdong/presentation/request/MemberNamesUpdateRequest.java index c67e1b699..872aa55de 100644 --- a/server/src/main/java/server/haengdong/presentation/request/MemberNamesUpdateRequest.java +++ b/server/src/main/java/server/haengdong/presentation/request/MemberNamesUpdateRequest.java @@ -1,16 +1,17 @@ package server.haengdong.presentation.request; import jakarta.validation.Valid; +import jakarta.validation.constraints.NotEmpty; import java.util.List; import server.haengdong.application.request.MemberNamesUpdateAppRequest; public record MemberNamesUpdateRequest( - @Valid List members + @Valid @NotEmpty List members ) { public MemberNamesUpdateAppRequest toAppRequest() { return new MemberNamesUpdateAppRequest(members.stream() - .map(MemberNameUpdateRequest::toAppRequest) - .toList()); + .map(MemberNameUpdateRequest::toAppRequest) + .toList()); } } From 9a6015dd66ea77f382004ad9e7c67de86578e82e Mon Sep 17 00:00:00 2001 From: 3juhwan <13selfesteem91@naver.com> Date: Mon, 19 Aug 2024 16:14:56 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EB=A5=BC=20json?= =?UTF-8?q?=20=ED=98=95=ED=83=9C=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../haengdong/exception/GlobalExceptionHandler.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/server/haengdong/exception/GlobalExceptionHandler.java b/server/src/main/java/server/haengdong/exception/GlobalExceptionHandler.java index 4d7dff45f..ec8e4cba0 100644 --- a/server/src/main/java/server/haengdong/exception/GlobalExceptionHandler.java +++ b/server/src/main/java/server/haengdong/exception/GlobalExceptionHandler.java @@ -19,10 +19,11 @@ public class GlobalExceptionHandler { private static final String LOG_FORMAT = """ - - [Request URI] {} {} - [Request Body] {} - [Error Message] {} + { + "RequestURI": "{} {}", + "RequestBody": "{}", + "ErrorMessage": "{}" + } """; @ExceptionHandler(AuthenticationException.class) From 37b9500aa8d762db8df3f8b38dbf7555cb2c01a1 Mon Sep 17 00:00:00 2001 From: 3juhwan <13selfesteem91@naver.com> Date: Mon, 19 Aug 2024 16:44:21 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EB=A5=BC=20json?= =?UTF-8?q?=20=EC=9D=B8=EB=8D=B4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../haengdong/exception/GlobalExceptionHandler.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/server/haengdong/exception/GlobalExceptionHandler.java b/server/src/main/java/server/haengdong/exception/GlobalExceptionHandler.java index ec8e4cba0..50ba3a9a5 100644 --- a/server/src/main/java/server/haengdong/exception/GlobalExceptionHandler.java +++ b/server/src/main/java/server/haengdong/exception/GlobalExceptionHandler.java @@ -19,11 +19,11 @@ public class GlobalExceptionHandler { private static final String LOG_FORMAT = """ - { + \n\t{ "RequestURI": "{} {}", - "RequestBody": "{}", + "RequestBody": {}, "ErrorMessage": "{}" - } + \t} """; @ExceptionHandler(AuthenticationException.class) @@ -79,9 +79,9 @@ public ResponseEntity handleException(HttpServletRequest req, Exc .body(ErrorResponse.of(HaengdongErrorCode.INTERNAL_SERVER_ERROR)); } - private String getRequestBody(HttpServletRequest req) { - try (BufferedReader reader = req.getReader()) { - return reader.lines().collect(Collectors.joining(System.lineSeparator())); + private String getRequestBody(HttpServletRequest request) { + try (BufferedReader reader = request.getReader()) { + return reader.lines().collect(Collectors.joining(System.lineSeparator() + "\t")); } catch (IOException e) { log.error("Failed to read request body", e); return "";