diff --git a/src/main/java/com/cvsgo/controller/ReviewController.java b/src/main/java/com/cvsgo/controller/ReviewController.java index a255eda2..855917a9 100644 --- a/src/main/java/com/cvsgo/controller/ReviewController.java +++ b/src/main/java/com/cvsgo/controller/ReviewController.java @@ -62,6 +62,12 @@ public SuccessResponse updateReview(@LoginUser User user, @PathVariable Lo return SuccessResponse.create(); } + @DeleteMapping("/reviews/{reviewId}") + public SuccessResponse deleteReview(@LoginUser User user, @PathVariable Long reviewId) { + reviewService.deleteReview(user, reviewId); + return SuccessResponse.create(); + } + @PostMapping("/reviews/{reviewId}/likes") @ResponseStatus(HttpStatus.CREATED) public SuccessResponse createReviewLike(@LoginUser User user, diff --git a/src/main/java/com/cvsgo/service/ReviewService.java b/src/main/java/com/cvsgo/service/ReviewService.java index 65302096..3207da42 100644 --- a/src/main/java/com/cvsgo/service/ReviewService.java +++ b/src/main/java/com/cvsgo/service/ReviewService.java @@ -119,6 +119,21 @@ public void updateReview(User user, Long reviewId, UpdateReviewRequestDto reques review.updateRating(request.getRating()); } + /** + * 리뷰를 삭제합니다. + * + * @param user 현재 로그인한 사용자 + * @param reviewId 삭제하려는 리뷰 ID + */ + @Transactional + public void deleteReview(User user, Long reviewId) { + Review review = reviewRepository.findById(reviewId).orElseThrow(() -> NOT_FOUND_REVIEW); + if (!review.getUser().equals(user)) { + throw FORBIDDEN_REVIEW; + } + reviewRepository.delete(review); + } + /** * 필터를 적용하여 리뷰를 조회합니다. *