Skip to content

Commit e66821f

Browse files
committed
refactor(review): 봉사 지원 수정 및 삭제 리팩토링
- ReviewQueryUseCase 의존하도록 변경
1 parent 7c0429e commit e66821f

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/main/java/com/somemore/domains/review/service/DeleteReviewService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.somemore.domains.review.repository.ReviewRepository;
55
import com.somemore.domains.review.service.validator.ReviewValidator;
66
import com.somemore.domains.review.usecase.DeleteReviewUseCase;
7+
import com.somemore.domains.review.usecase.ReviewQueryUseCase;
78
import com.somemore.global.exception.ExceptionMessage;
89
import com.somemore.global.exception.NoSuchElementException;
910
import lombok.RequiredArgsConstructor;
@@ -17,13 +18,12 @@
1718
@Service
1819
public class DeleteReviewService implements DeleteReviewUseCase {
1920

20-
private final ReviewRepository reviewRepository;
21+
private final ReviewQueryUseCase reviewQueryUseCase;
2122
private final ReviewValidator reviewValidator;
2223

2324
@Override
2425
public void deleteReview(UUID volunteerId, Long id) {
25-
Review review = reviewRepository.findById(id).orElseThrow(
26-
() -> new NoSuchElementException(ExceptionMessage.NOT_EXISTS_REVIEW));
26+
Review review = reviewQueryUseCase.getById(id);
2727

2828
reviewValidator.validateAuthor(review, volunteerId);
2929
review.markAsDeleted();

src/main/java/com/somemore/domains/review/service/UpdateReviewService.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.somemore.domains.review.dto.request.ReviewUpdateRequestDto;
55
import com.somemore.domains.review.repository.ReviewRepository;
66
import com.somemore.domains.review.service.validator.ReviewValidator;
7+
import com.somemore.domains.review.usecase.ReviewQueryUseCase;
78
import com.somemore.domains.review.usecase.UpdateReviewUseCase;
89
import com.somemore.global.exception.ExceptionMessage;
910
import com.somemore.global.exception.NoSuchElementException;
@@ -18,25 +19,21 @@
1819
@Service
1920
public class UpdateReviewService implements UpdateReviewUseCase {
2021

21-
private final ReviewRepository reviewRepository;
22+
private final ReviewQueryUseCase reviewQueryUseCase;
2223
private final ReviewValidator reviewValidator;
2324

2425
@Override
2526
public void updateReview(Long id, UUID volunteerId, ReviewUpdateRequestDto requestDto) {
26-
Review review = getReview(id);
27+
Review review = reviewQueryUseCase.getById(id);
2728
reviewValidator.validateAuthor(review, volunteerId);
2829
review.updateWith(requestDto);
2930
}
3031

3132
@Override
3233
public void updateReviewImageUrl(Long id, UUID volunteerId, String imgUrl) {
33-
Review review = getReview(id);
34+
Review review = reviewQueryUseCase.getById(id);
3435
reviewValidator.validateAuthor(review, volunteerId);
3536
review.updateWith(imgUrl);
3637
}
3738

38-
private Review getReview(Long id) {
39-
return reviewRepository.findById(id).orElseThrow(
40-
() -> new NoSuchElementException(ExceptionMessage.NOT_EXISTS_REVIEW));
41-
}
4239
}

0 commit comments

Comments
 (0)