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 menuitemreviewGet a single menu item review by idpostMenuItemReview
(long itemId, String reviewerEmail, int stars, LocalDateTime dateReviewed, String comments) Create a new menuItemReviewupdateMenuItemReview
(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 MenuItemReview
-
postMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public MenuItemReview 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 menuItemReview- Parameters:
itemId
- the id of the reviewed itemreviewerEmail
- The email of the reviewerstars
- The amount of starsdateReviewed
- The date of the reviewcomments
- The review comments- Returns:
- the saved menuitemreview
- 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
-
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 date object
-
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
-