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 Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionList all menu item reviewsDelete a menu item reviewGet a single review by idpostMenuItemReview(long itemID, String reviewerEmail, int stars, LocalDateTime reviewDate, String comments) Create a new menu item review.updateReview(Long id, @Valid MenuItemReview incoming) Update a single reviewMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException 
- 
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("reviewDate") @DateTimeFormat(iso=DATE_TIME) LocalDateTime reviewDate, @RequestParam String comments) throws com.fasterxml.jackson.core.JsonProcessingException Create a new menu item review.- Parameters:
 itemID- the ID of the menu item being reviewedreviewerEmail- the email of the reviewerstars- the number of stars given in the reviewreviewDate- the date and time of the reviewcomments- the comments included in the review- Returns:
 - the saved 
MenuItemReview - Throws:
 com.fasterxml.jackson.core.JsonProcessingException- if there is an error processing JSON
 - 
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- Returns:
 - a MenuItemReview
 
 - 
updateReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public MenuItemReview updateReview(@RequestParam Long id, @RequestBody @Valid @Valid MenuItemReview incoming) Update a single review- Parameters:
 id- id of the review to updateincoming- the new review- Returns:
 - the updated 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 review to delete- Returns:
 - a message indicating the review was deleted
 
 
 -