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
This is a REST controller for menuitemreview
  • 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 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 menu item id
      reviewerEmail - the email of the reviewer
      stars - the number of stars (0-5) for the review
      comments - any additional comments for the review
      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 MenuItemReview by id
      Parameters:
      id - the id of the MenuItemReview
      Returns:
      a MenuItemReview
    • updateMenuItemReview

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

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteMenuItemReview(@RequestParam Long id)
      Delete a Menu item review
      Parameters:
      id - the id of the menu item review to delete
      Returns:
      a message indicating the menu item review was deleted