Class MenuItemReviewController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.MenuItemReviewController
@RequestMapping("/api/menuitemreviews")
@RestController
public class MenuItemReviewController
extends ApiController
This is a REST controller for Menu Item Reviews
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all Menu Item ReviewsGet a single Meny Item Review by idpostMenuItemReview(Long itemId, String reviewerEmail, int stars, String comments, LocalDateTime dateReviewed) Create a new menu item 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 Menu Item Reviews
-
postMenuItemReview
@PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping("/post") public MenuItemReview postMenuItemReview(@RequestParam Long itemId, @RequestParam String reviewerEmail, @RequestParam int stars, @RequestParam String comments, @RequestParam("dateReviewed") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateReviewed) throws com.fasterxml.jackson.core.JsonProcessingException Create a new menu item review- Parameters:
itemId- the item that is being reviewedreviewerEmail- the email of the reviewerstars- the rating of the itemcomments- any comments about the itemdateReviewed- the date of the review- Returns:
- the saved menu item review
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getById
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("") public MenuItemReview getById(@RequestParam Long id) Get a single Meny Item Review by id- Parameters:
id- the id of the Menu Item Review- Returns:
- a MenuItemReview
-