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

    • MenuItemReviewController

      public MenuItemReviewController()
  • Method Details

    • allMenuItemReviews

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<MenuItemReview> allMenuItemReviews()
      List all UCSB dates
      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 review (not the same as itemId)
      Returns:
      a MenuItemReview
    • 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
    • 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) throws com.fasterxml.jackson.core.JsonProcessingException
      Create a new review
      Parameters:
      itemId - the id of the food item being reviewed
      reviewerEmail - the email of the reviewer
      stars - star rating of the review
      dateReviewed - date of the review
      comments - comments in the review
      Returns:
      the saved menu item review
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • updateMenuItemReview

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