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 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 reviewed
      reviewerEmail - the email of the reviewer
      stars - the rating of the item
      comments - any comments about the item
      dateReviewed - 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