Skip to content

Commit

Permalink
added endpoint to delete review
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerstock committed Jun 25, 2019
1 parent 352b11f commit f0d6ddf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,22 @@ public ResponseEntity<?> postReview(@RequestBody Review review) {
return new ResponseEntity<>(HttpStatus.OK);
}

@ApiOperation(value = "deletes a review by review id", response = Book.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "review successfully deleted", response = Review.class),
@ApiResponse(code = 500, message = "failed to delete review", response = ErrorDetail.class)
})
@DeleteMapping(value = "/delete/{reviewid}}")
public ResponseEntity<?> deleteReview(@PathVariable long reviewid) {


reviewService.delete(reviewid);

logger.info("/reviews/delete/{reviewid} DELETE endpoint accessed");

return new ResponseEntity<>(HttpStatus.OK);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public interface ReviewService {
List<Review> findReviewsByBook(Pageable pageable, Long id);

Review updateReview(Review review, long reviewid);

void delete(long reviewid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public Review updateReview(Review review, long reviewid) {
repo.save(currentReview);
return currentReview;
}

@Override
public void delete(long reviewid) {
repo.deleteById(reviewid);
}
}

0 comments on commit f0d6ddf

Please sign in to comment.