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
  • 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("dateReviewed") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateReviewed, @RequestParam String comments)
    • getById

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public MenuItemReview getById(@RequestParam Long id)
      Get a single record from the table; use the value passed in as a @RequestParam to do a lookup by id. If a matching row is found, return the row as a JSON object, otherwise throw an EntityNotFoundException.
      Parameters:
      id - the id of the review
      Returns:
      a MenuItemReview
    • updateMenuItemReview

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public MenuItemReview updateMenuItemReview(@RequestParam Long id, @RequestBody @Valid @Valid MenuItemReview incoming)
      Get a single record from the table; use the value passed in as a @RequestParam to do a lookup by id. If a matching row is found, update that row with the values passed in as a JSON object. If a matching row is not found, throw an EntityNotFoundException.
      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 review * @param id the id of the review to delete
      Returns:
      a message indicating the review was deleted