From b77fc103e6e36f65f6d825a0fe96918374d0f778 Mon Sep 17 00:00:00 2001 From: ariimo Date: Fri, 15 Nov 2024 09:34:59 +0900 Subject: [PATCH] =?UTF-8?q?[Weekly/11/Refactor/All]=20Transactional=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95,=20=EC=A0=91=EA=B7=BC=EC=A0=9C=EC=96=B4?= =?UTF-8?q?=EC=9E=90=20=EC=84=A4=EC=A0=95=20(#142)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: Review Transactional 설정 * refactor: RequestDto 접근제어자 private으로 변경 --- .../advertisement/api/dto/AdvertisementRequest.java | 2 +- .../cokaen/wouldyouin/event/api/dto/EventCreateRequest.java | 4 ++-- .../cokaen/wouldyouin/event/api/dto/EventEditRequest.java | 4 ++-- .../cokaen/wouldyouin/review/application/ReviewService.java | 5 ++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/api/dto/AdvertisementRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/api/dto/AdvertisementRequest.java index 566ada93..27f58443 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/api/dto/AdvertisementRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/api/dto/AdvertisementRequest.java @@ -30,7 +30,7 @@ public class AdvertisementRequest { private LocalDateTime endTime; @AssertTrue(message = "종료 시간은 시작 시간 이후여야 합니다.") - public boolean isEndTimeAfterStartTime() { + private boolean isEndTimeAfterStartTime() { return endTime.isAfter(startTime); } diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventCreateRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventCreateRequest.java index 3d877b03..d236ed3d 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventCreateRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventCreateRequest.java @@ -66,7 +66,7 @@ public class EventCreateRequest { private List imageIds; @AssertTrue(message = "종료 시간은 시작 시간 이후여야 합니다.") - public boolean isEndTimeAfterStartTime() { + private boolean isEndTimeAfterStartTime() { if (startTime == null || endTime == null) { return true; } @@ -74,7 +74,7 @@ public boolean isEndTimeAfterStartTime() { } @AssertTrue(message = "이미지는 최대 5개까지 등록할 수 있습니다.") - public boolean isImageSizeValid() { + private boolean isImageSizeValid() { return imageIds.size() <= 5; } diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventEditRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventEditRequest.java index afec07f6..f06e9eab 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventEditRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventEditRequest.java @@ -62,7 +62,7 @@ public class EventEditRequest { private List imageIds; @AssertTrue(message = "종료 시간은 시작 시간 이후여야 합니다.") - public boolean isEndTimeAfterStartTime() { + private boolean isEndTimeAfterStartTime() { if (startTime == null || endTime == null) { return true; } @@ -70,7 +70,7 @@ public boolean isEndTimeAfterStartTime() { } @AssertTrue(message = "이미지는 최대 5개까지 등록할 수 있습니다.") - public boolean isImageSizeValid() { + private boolean isImageSizeValid() { return imageIds.size() <= 5; } } \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/ReviewService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/ReviewService.java index c2178751..f542eced 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/ReviewService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/ReviewService.java @@ -59,7 +59,7 @@ private Long getLastId(Slice reviews, Long oldLastId) { return oldLastId; } - @Transactional + @Transactional(readOnly = true) public ReviewEventSliceResponse getUnreviewedEventsByMemberId(Long memberId, Pageable pageable, Long beforeLastId) { Slice unreviewedEvents = reviewRepository.findUnreviewedEventsByMemberId(memberId, @@ -95,8 +95,7 @@ public void delete(Long memberId, Long reviewId) { reviewRepository.deleteById(reviewId); } - @Transactional - public Review getByIdOrThrow(Long id) { + private Review getByIdOrThrow(Long id) { return reviewRepository.findById(id) .orElseThrow(() -> new EntityNotFoundException("해당하는 리뷰를 찾을 수 없습니다.")); }