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
-
Method Summary
Modifier and TypeMethodDescriptionList all Menu Item ReviewsDelete a MenuItemReviewGet a single review by idpostMenuItemReview
(long itemId, String reviewerEmail, int stars, LocalDateTime dateReviewed, String comments) Create a new dateupdateMenuItemReviews
(Long id, @Valid MenuItemReviews incoming) Update 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<MenuItemReviews> allMenuItemReviews()List all Menu Item Reviews- Returns:
- an iterable of MenuItemReviews
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public MenuItemReviews getById(@RequestParam Long id) Get a single review by id- Parameters:
id
- the id of the review- Returns:
- a MenuItemReview
-
postMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public MenuItemReviews postMenuItemReview(@RequestParam long itemId, @RequestParam String reviewerEmail, @RequestParam int stars, @RequestParam("dateReviewed") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateReviewed, @RequestParam String comments) throws com.fasterxml.jackson.core.JsonProcessingException Create a new date- Parameters:
itemId
-reviewerEmail
-stars
-dateReviewed
-comments
-- Returns:
- the created 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
- of the menu item review- Returns:
- the saved menu item review
-
updateMenuItemReviews
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public MenuItemReviews updateMenuItemReviews(@RequestParam Long id, @RequestBody @Valid @Valid MenuItemReviews incoming) Update MenuItemReview- Parameters:
id
- the id of the date to updateincoming
- the menuitemreview to update- Returns:
- the updated menu item review
-