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 TypeMethodDescriptionDelete a MenuItemReviewGet a single date by idpostMenuItemReview(Long itemId, String reviewerEmail, int stars, String comments, LocalDateTime dateReviewed) Create a new menu item reviewupdateMenuItemReview(Long id, @Valid MenuItemReview incoming) Update a single dateMethods 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() -
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 reviewedreviewerEmail- the email of the reviewerstars- the star rating (0-5)comments- the reviewer's commentsdateReviewed- the date the review was written- 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 date by id- Parameters:
id- the id of the date- Returns:
- a UCSBDate
-
updateMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public MenuItemReview updateMenuItemReview(@RequestParam Long id, @RequestBody @Valid @Valid MenuItemReview incoming) Update a single date- Parameters:
id- id of the review to updateincoming- the new review- Returns:
- the updated review object
-
handleIllegalArgumentException
@ExceptionHandler(java.lang.IllegalArgumentException.class) @ResponseStatus(BAD_REQUEST) public Map<String,String> handleIllegalArgumentException(IllegalArgumentException ex)
-