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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all Menu Item reviewsDelete a Menu item reviewGet 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 single 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 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 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 menu item idreviewerEmail- the email of the reviewerstars- the number of stars (0-5) for the reviewcomments- any additional comments for the reviewdateReviewed- the date of the review- 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 MenuItemReview by id- Parameters:
id- the id of the MenuItemReview- Returns:
- a MenuItemReview
-
updateMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public MenuItemReview updateMenuItemReview(@RequestParam Long id, @RequestBody @Valid @Valid MenuItemReview incoming) Update a single Menu Item Review- Parameters:
id- id of the menu item review to updateincoming- the new menu item review- Returns:
- the updated menu item 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 menu item review to delete- Returns:
- a message indicating the menu item review was deleted
-