From 9540d8713773bc883f3dd86899e8346b3cd00252 Mon Sep 17 00:00:00 2001 From: onpyeong Date: Wed, 19 Jul 2023 20:10:52 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=8B=9C=EA=B0=84=20=ED=8F=AC?= =?UTF-8?q?=EB=A7=B7=20=EC=98=88=EC=99=B8=EC=99=80=20=EC=9E=98=EB=AA=BB?= =?UTF-8?q?=EB=90=9C=20=EC=A7=80=EC=97=AD=20=EC=98=88=EC=99=B8=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sophy/common/advice/ControllerExceptionAdvice.java | 6 ++++++ src/main/java/org/sophy/sophy/exception/ErrorStatus.java | 3 ++- .../java/org/sophy/sophy/service/BooktalkService.java | 9 ++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/sophy/sophy/common/advice/ControllerExceptionAdvice.java b/src/main/java/org/sophy/sophy/common/advice/ControllerExceptionAdvice.java index ecc9398..a29c8f3 100644 --- a/src/main/java/org/sophy/sophy/common/advice/ControllerExceptionAdvice.java +++ b/src/main/java/org/sophy/sophy/common/advice/ControllerExceptionAdvice.java @@ -39,6 +39,12 @@ protected ApiResponseDto handleExpiredRefreshTokenException(final ExpiredJwtExce @ResponseStatus(HttpStatus.NOT_FOUND) @ExceptionHandler(InvalidFormatException.class) protected ApiResponseDto handleInvalidFormatException(final InvalidFormatException e) { + return ApiResponseDto.error(ErrorStatus.INVALID_FORMAT_EXCEPTION); + } + + @ResponseStatus(HttpStatus.NOT_FOUND) + @ExceptionHandler(IllegalArgumentException.class) + protected ApiResponseDto handleIllegalArgumentException(final IllegalArgumentException e) { return ApiResponseDto.error(ErrorStatus.NOT_FOUND_CITY_EXCEPTION); } diff --git a/src/main/java/org/sophy/sophy/exception/ErrorStatus.java b/src/main/java/org/sophy/sophy/exception/ErrorStatus.java index fff33b8..b1970d0 100644 --- a/src/main/java/org/sophy/sophy/exception/ErrorStatus.java +++ b/src/main/java/org/sophy/sophy/exception/ErrorStatus.java @@ -14,8 +14,9 @@ public enum ErrorStatus { VALIDATION_EXCEPTION(HttpStatus.BAD_REQUEST, "잘못된 요청입니다."), VALIDATION_REQUEST_MISSING_EXCEPTION(HttpStatus.BAD_REQUEST, "올바른 요청값이 입력되지 않았습니다."), INVALID_PASSWORD_EXCEPTION(HttpStatus.BAD_REQUEST, "잘못된 비밀번호가 입력됐습니다."), - INVALID_MULTIPART_EXTENSION_EXCEPTION(HttpStatus.BAD_REQUEST, "허용되지 않은 타입의 파일입니다"), + INVALID_MULTIPART_EXTENSION_EXCEPTION(HttpStatus.BAD_REQUEST, "허용되지 않은 타입의 파일입니다."), INVALID_TOKEN_INFO_EXCEPTION(HttpStatus.BAD_REQUEST, "토큰 혹은 만료시간 설정이 잘못되었습니다."), + INVALID_FORMAT_EXCEPTION(HttpStatus.BAD_REQUEST, "잘못된 형식입니다."), /** * 401 UNAUTHORIZED diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java index e1c048d..66f1096 100644 --- a/src/main/java/org/sophy/sophy/service/BooktalkService.java +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -27,6 +27,7 @@ public class BooktalkService { private final MemberBooktalkRepository memberBooktalkRepository; private final CompletedBooktalkRepository completedBooktalkRepository; + // 북토크 생성 @Transactional public BooktalkCreateResponseDto createBooktalk(BooktalkRequestDto booktalkRequestDto) { Place place = placeRepository.getPlaceById(booktalkRequestDto.getPlaceId()); @@ -38,6 +39,7 @@ public BooktalkCreateResponseDto createBooktalk(BooktalkRequestDto booktalkReque return BooktalkCreateResponseDto.of(booktalkRepository.save(booktalk)); } + // 북토크 수정 @Transactional public BooktalkUpdateDto updateBooktalk(Long booktalkId, BooktalkUpdateDto booktalkUpdateDto) { Booktalk booktalk = booktalkRepository.getBooktalkById(booktalkId); @@ -45,6 +47,7 @@ public BooktalkUpdateDto updateBooktalk(Long booktalkId, BooktalkUpdateDto bookt return booktalkUpdateDto; } + // 북토크 삭제 @Transactional public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) { // 수정필요 -> 테이블 외래키 고려하여 관련된 엔티티 전부 삭제해야 함 Booktalk booktalk = booktalkRepository.getBooktalkById(booktalkId); @@ -56,11 +59,13 @@ public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) { // 수정필 return BooktalkDeleteResponseDto.of(booktalkId); } + // 북토크 상세 조회 public BooktalkDetailResponseDto getBooktalkDetail(Long booktalkId) { Booktalk booktalk = booktalkRepository.getBooktalkById(booktalkId); return BooktalkDetailResponseDto.of(booktalk); } + // 북토크 참여 신청 @Transactional public void postBooktalkParticipation(BooktalkParticipationRequestDto booktalkParticipationRequestDto) { Member member = memberRepository.getMemberById(booktalkParticipationRequestDto.getMemberId()); @@ -70,6 +75,7 @@ public void postBooktalkParticipation(BooktalkParticipationRequestDto booktalkPa memberBooktalkRepository.save(memberBooktalk); } + // 마감임박 북토크 조회 public List getBooktalkDeadlineUpcoming() { List placeList = placeRepository.findAll(); @@ -91,8 +97,9 @@ public List getBooktalkDeadlineUpcoming() { } + //지역으로 북토크 조회 @Transactional - public List getBooktalksByCity(City city) { //지역으로 북토크 조회 + public List getBooktalksByCity(City city) { List booktalks;