From 4d603d5a2bf717144837c7b185b3d374926a0008 Mon Sep 17 00:00:00 2001 From: kyukong <92148749+kyukong@users.noreply.github.com> Date: Wed, 28 Feb 2024 09:51:57 +0900 Subject: [PATCH] =?UTF-8?q?[REFACTOR]=20=EC=BB=A4=EB=AE=A4=EB=8B=88?= =?UTF-8?q?=ED=8B=B0=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EB=93=B1=EB=A1=9D=20?= =?UTF-8?q?=EC=8B=9C=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=EA=B0=92=EC=9C=BC=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20(#27)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [REFACTOR] 필수값 제외 및 주석 추가 * [REFACTOR] 서버 에러 발생 시 응답 메시지 수정 --- .../oya/kr/community/controller/CommunityController.java | 7 ++++++- .../oya/kr/global/exception/GlobalExceptionHandler.java | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/oya/kr/community/controller/CommunityController.java b/src/main/java/com/oya/kr/community/controller/CommunityController.java index 374e877..504fba2 100644 --- a/src/main/java/com/oya/kr/community/controller/CommunityController.java +++ b/src/main/java/com/oya/kr/community/controller/CommunityController.java @@ -23,11 +23,13 @@ import com.oya.kr.global.dto.response.ApplicationResponse; import lombok.RequiredArgsConstructor; +import lombok.extern.java.Log; /** * @author 이상민 * @since 2024.02.17 */ +@Log @RestController @RequiredArgsConstructor @RequestMapping("/api/v1/communities") @@ -47,8 +49,11 @@ public class CommunityController { public ResponseEntity> save( Principal principal, @RequestPart("data") CommunityRequest communityRequest, - @RequestPart("images") List images, + @RequestPart(value = "images", required = false) List images, @RequestParam("type") String communityType) { + log.info(communityRequest.toString()); + log.info(images.toString()); + log.info(communityType); return ResponseEntity.ok(ApplicationResponse.success(communityService.save(communityType, principal.getName(), communityRequest, images))); } diff --git a/src/main/java/com/oya/kr/global/exception/GlobalExceptionHandler.java b/src/main/java/com/oya/kr/global/exception/GlobalExceptionHandler.java index 1e4c2f9..fe8e5af 100644 --- a/src/main/java/com/oya/kr/global/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/oya/kr/global/exception/GlobalExceptionHandler.java @@ -36,8 +36,7 @@ public ResponseEntity> handleValidationException(Metho @ExceptionHandler(Exception.class) public ResponseEntity> handleGlobalException(Exception e) { log.info(e.getMessage()); - ApplicationResponse response = ApplicationResponse.fail(INTERNAL_SERVER_ERROR_CODE, - "서버에 문제가 발생하였습니다. 관리자에게 문의해주세요."); + ApplicationResponse response = ApplicationResponse.fail(INTERNAL_SERVER_ERROR_CODE, e.getMessage()); return ResponseEntity.badRequest().body(response); } }