|
4 | 4 | import com.somemore.domains.review.dto.request.ReviewUpdateRequestDto; |
5 | 5 | import com.somemore.domains.review.repository.ReviewRepository; |
6 | 6 | import com.somemore.domains.review.service.validator.ReviewValidator; |
| 7 | +import com.somemore.domains.review.usecase.ReviewQueryUseCase; |
7 | 8 | import com.somemore.domains.review.usecase.UpdateReviewUseCase; |
8 | 9 | import com.somemore.global.exception.ExceptionMessage; |
9 | 10 | import com.somemore.global.exception.NoSuchElementException; |
|
18 | 19 | @Service |
19 | 20 | public class UpdateReviewService implements UpdateReviewUseCase { |
20 | 21 |
|
21 | | - private final ReviewRepository reviewRepository; |
| 22 | + private final ReviewQueryUseCase reviewQueryUseCase; |
22 | 23 | private final ReviewValidator reviewValidator; |
23 | 24 |
|
24 | 25 | @Override |
25 | 26 | public void updateReview(Long id, UUID volunteerId, ReviewUpdateRequestDto requestDto) { |
26 | | - Review review = getReview(id); |
| 27 | + Review review = reviewQueryUseCase.getById(id); |
27 | 28 | reviewValidator.validateAuthor(review, volunteerId); |
28 | 29 | review.updateWith(requestDto); |
29 | 30 | } |
30 | 31 |
|
31 | 32 | @Override |
32 | 33 | public void updateReviewImageUrl(Long id, UUID volunteerId, String imgUrl) { |
33 | | - Review review = getReview(id); |
| 34 | + Review review = reviewQueryUseCase.getById(id); |
34 | 35 | reviewValidator.validateAuthor(review, volunteerId); |
35 | 36 | review.updateWith(imgUrl); |
36 | 37 | } |
37 | 38 |
|
38 | | - private Review getReview(Long id) { |
39 | | - return reviewRepository.findById(id).orElseThrow( |
40 | | - () -> new NoSuchElementException(ExceptionMessage.NOT_EXISTS_REVIEW)); |
41 | | - } |
42 | 39 | } |
0 commit comments