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

    • allMenuItemReview

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/all") public Iterable<MenuItemReview> allMenuItemReview()
      List all menu item reviews
      Returns:
      an iterable of MenuItemReview
    • getById

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("") public MenuItemReview getById(@RequestParam Long id)
      Get a single review by id
      Parameters:
      id - the id of the date
      Returns:
      a 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 id of the menu item being reviewed
      reviewerEmail - the email of the reviewer
      stars - the number of stars the menu item got
      comments - the comments of the review
      dateReviewed - the date revewed
      Returns:
      the saved menuitemreview
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • deleteMenuItemReview

      @PreAuthorize("hasRole('ROLE_ADMIN')") @DeleteMapping("") public Object deleteMenuItemReview(@RequestParam Long id)
      Delete a MenuItemReview
      Parameters:
      id - the id of the menu item review to delete
      Returns:
      a message indicating the menu item review was deleted
    • 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