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 MenuItemReviews
  • Constructor Details

    • MenuItemReviewController

      public MenuItemReviewController()
  • Method Details

    • allMenuItemReviews

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<MenuItemReview> allMenuItemReviews()
    • 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 id of the menu item being reviewed
      reviewerEmail - the email of the reviewer
      stars - the star rating (0-5)
      comments - the reviewer's comments
      dateReviewed - the date the review was written
      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 date by id
      Parameters:
      id - the id of the date
      Returns:
      a UCSBDate
    • updateMenuItemReview

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public MenuItemReview updateMenuItemReview(@RequestParam Long id, @RequestBody @Valid @Valid MenuItemReview incoming)
      Update a single date
      Parameters:
      id - id of the review to update
      incoming - the new review
      Returns:
      the updated review object
    • deletemenuItemReview

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deletemenuItemReview(@RequestParam Long id)
      Delete a MenuItemReview
      Parameters:
      id - the id of the review to delete
      Returns:
      a message indicating the review was deleted
    • handleIllegalArgumentException

      @ExceptionHandler(java.lang.IllegalArgumentException.class) @ResponseStatus(BAD_REQUEST) public Map<String,String> handleIllegalArgumentException(IllegalArgumentException ex)