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 MenuItemReview
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList all MenuItemReviewsDelete a menuitemreviewGet a single menuitemreview 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 menu item 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 MenuItemReviews- Returns:
- an iterable of MenuItemReviews
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public MenuItemReview getById(@RequestParam Long id) Get a single menuitemreview by id- Parameters:
id
- the id of the menuitemreview- Returns:
- a menuitemreview
-
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
- id of the menu itemreviewerEmail
- email of the reviewerstars
- the number of stars the item receivedcomments
- comments of the reviewdateReviewed
- the date the review was made- Returns:
- the saved menu item review
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
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 menu item review- Parameters:
id
- id of the menuitemreview to updateincoming
- the new menuitemreview- Returns:
- the updated menuitemreview object
-