Class MenuItemReviewController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.MenuItemReviewController
@RequestMapping("/api/menuitemreview")
@RestController
public class MenuItemReviewController
extends ApiController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all menu item reviewspostMenuItemReview(long itemId, String reviewerEmail, int stars, LocalDateTime dateReviewed, String comments) Create a new reviewMethods inherited from class ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
MenuItemReviewController
public MenuItemReviewController()
-
-
Method Details
-
allMenuItemReviews
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/all") public Iterable<MenuItemReview> allMenuItemReviews()List all menu item reviews- Returns:
- an iterable of MenuItemReview
-
postMenuItemReview
@PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping("/post") public MenuItemReview postMenuItemReview(@RequestParam long itemId, @RequestParam String reviewerEmail, @RequestParam int stars, @RequestParam("dateReviewed") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateReviewed, @RequestParam String comments) throws com.fasterxml.jackson.core.JsonProcessingException Create a new review- Parameters:
itemId- the id of the menu item reviewedreviewerEmail- email of the reviewerstars- how many stars given (0-5)dateReviewed- date of the reviewcomments- any coments left by reviewer- Returns:
- the saved menu item review
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-