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 TypeMethodDescriptionDelete a reviewGet a single article by idpostMenuItemReview
(long itemId, String reviewerEmail, int stars, String comments, LocalDateTime dateReviewed) Create a new dateupdateMenuItemReview
(Long id, @Valid MenuItemReview incoming) update a single 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() -
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public MenuItemReview getById(@RequestParam Long id) Get a single article by id- Parameters:
id
- the id of the review- Returns:
- an 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 date- Parameters:
itemId
- id of reviewreviewerEmail
- review emailstars
- review starscomments
- review commentsdateReviewed
- date of review- Returns:
- the saved review
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
updateMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public MenuItemReview updateMenuItemReview(@RequestParam Long id, @RequestBody @Valid @Valid MenuItemReview incoming) update a single review- Parameters:
id
- id of reviewincoming
- review to be updated- Returns:
- the saved review
-
deleteMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteMenuItemReview(@RequestParam Long id) Delete a review- Parameters:
id
- id of review- Returns:
- the saved review
-