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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionList all menu item reviewsDelete a MenuItemReviewGet a single menu item review by idpostMenuItemReview
(long itemId, String reviewerEmail, int stars, String comments, LocalDateTime dateReviewed) Create a new menu itemupdateMenuItemReview
(Long id, @Valid MenuItemReview incoming) Update a single MenuItemReviewMethods 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 MenuItemReviews
-
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- Parameters:
itemId
- the ID of the reviewed item itselfreviewerEmail
- the email address of the reviewer of the menu itemstars
- the rating given to the menu item by the reviewercomments
- the comments left by the reviewer about the menu itemdateReviewed
- the date/time when the menu item was reviewed- Returns:
- the saved ucsbdate
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public MenuItemReview getById(@RequestParam Long id) Get a single menu item review by id- Parameters:
id
- the id of the menu item review- Returns:
- a MenuItemReview
-
deleteMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteMenuItemReview(@RequestParam Long id) Delete a MenuItemReview- Parameters:
id
- the id of the MenuItemReview to delete- Returns:
- a message indicating the MenuItemReview was deleted
-
updateMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public MenuItemReview updateMenuItemReview(@RequestParam Long id, @RequestBody @Valid @Valid MenuItemReview incoming) Update a single MenuItemReview- Parameters:
id
- id of the MenuItemReview to updateincoming
- the new MenuItemReview- Returns:
- the updated MenuItemReview object
-