Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/fernandokkang/todaysbook
Browse files Browse the repository at this point in the history
…into release
  • Loading branch information
dhktjr0204 committed May 15, 2024
2 parents 1ab00e7 + dc49312 commit ba646b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public String addNewReview(@RequestBody ReviewRequestDto requestDto,
}

@DeleteMapping("/delete")
public String deleteReview(@RequestParam(value = "reviewId") long reviewId,
@RequestParam(value = "bookId") long bookId,
public String deleteReview(@RequestBody ReviewRequestDto requestDto,
@AuthenticationPrincipal CustomUserDetails userDetails,
Model model, BindingResult result) {

Expand All @@ -76,15 +75,15 @@ public String deleteReview(@RequestParam(value = "reviewId") long reviewId,

Map<String, Long> map = new HashMap<>();
map.put("userId", userId);
map.put("reviewOwnerId", reviewService.getReviewOwnerId(reviewId));
map.put("reviewOwnerId", reviewService.getReviewOwnerId(requestDto.getReviewId()));

ReviewUpdateDeleteValidator validator = new ReviewUpdateDeleteValidator();
validator.validate(map, result);

reviewService.deleteReview(reviewId);
reviewService.deleteReview(requestDto.getReviewId());

List<Review> reviews =
reviewService.getReviews(bookId, userId, orderBy);
reviewService.getReviews(requestDto.getBookId(), userId, orderBy);
model.addAttribute("reviews", reviews);
model.addAttribute("userId", userId);

Expand All @@ -101,7 +100,7 @@ public String updateReview(@RequestBody ReviewRequestDto requestDto,

Map<String, Long> map = new HashMap<>();
map.put("userId", userId);
map.put("reviewOwnerId", requestDto.getReviewId());
map.put("reviewOwnerId", reviewService.getReviewOwnerId(requestDto.getReviewId()));

ReviewUpdateDeleteValidator validator = new ReviewUpdateDeleteValidator();
validator.validate(map, result);
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/static/js/review/review.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ function deleteReview(button) {
$.ajax({
url: url,
type: method,
data: {
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({
bookId: bookId,
reviewId: reviewId
},
}),
success: function (data) {
alert("리뷰가 삭제 되었습니다.");
$('.review-area').html(data);
Expand Down

0 comments on commit ba646b1

Please sign in to comment.