Class ReviewController
java.lang.Object
com.JesacaLin.GrubGoblin_v13.controllers.ReviewController
@PreAuthorize("isAuthenticated()")
@RestController
@RequestMapping("/review")
public class ReviewController
extends Object
Controller for managing Review entities.
-
Constructor Summary
ConstructorsConstructorDescriptionReviewController
(ReviewDAO reviewDAO) Constructs a new ReviewController with the given ReviewDAO. -
Method Summary
Modifier and TypeMethodDescriptioncreateReview
(Review review, int dealId, Principal principal) Creates a new Review for a given deal.int
deleteReview
(int id) Deletes a Review by its ID.getReviewByDealId
(int dealId) Retrieves all Reviews for a given deal.getReviewById
(int id) Retrieves a Review by its ID.Retrieves all Reviews.updateReview
(int id, Review review, Principal principal) Updates a Review.
-
Constructor Details
-
ReviewController
Constructs a new ReviewController with the given ReviewDAO.- Parameters:
reviewDAO
- the ReviewDAO to use for review management
-
-
Method Details
-
listOfReviews
-
getReviewById
Retrieves a Review by its ID.- Parameters:
id
- the ID of the Review to retrieve- Returns:
- the Review with the given ID
-
createReview
@PreAuthorize("hasAuthority(\'contributor\') or hasAuthority(\'admin\')") @PostMapping("/{dealId}") public Review createReview(@RequestBody Review review, @PathVariable int dealId, Principal principal) Creates a new Review for a given deal.- Parameters:
review
- the Review to createdealId
- the ID of the deal the review is forprincipal
- the authenticated user- Returns:
- the created Review
-
updateReview
@PreAuthorize("hasAuthority(\'contributor\') or hasAuthority(\'admin\')") @PutMapping("/{id}") public Review updateReview(@PathVariable int id, @RequestBody Review review, Principal principal) Updates a Review.- Parameters:
id
- the ID of the Review to updatereview
- the Review data to update- Returns:
- the updated Review if authorized person matches the creator of the review
-
deleteReview
@PreAuthorize("hasAuthority(\'admin\')") @DeleteMapping("/{id}") public int deleteReview(@PathVariable int id) Deletes a Review by its ID.- Parameters:
id
- the ID of the Review to delete- Returns:
- the number of rows affected by the delete
-
getReviewByDealId
-