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 MenuItemReview reviewsDelete a MenuItemReviewGet a single review by idpostMenuItemReview(long itemId, String reviewerEmail, LocalDateTime dateReviewed, int stars, String comments) Create a new reviewupdateMenuItemReview(Long id, @Valid MenuItemReview incoming) Update a single reviewMethods inherited from class ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
MenuItemReviewController
public MenuItemReviewController()
-
-
Method Details
-
allMenuItemReview
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/all") public Iterable<MenuItemReview> allMenuItemReview()List all MenuItemReview reviews- Returns:
- an iterable of MenuItemReview
-
getById
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("") public MenuItemReview 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 MenuItemReview postMenuItemReview(@RequestParam long itemId, @RequestParam String reviewerEmail, @RequestParam("dateReviewed") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateReviewed, @RequestParam int stars, @RequestParam String comments) throws com.fasterxml.jackson.core.JsonProcessingException Create a new review- Parameters:
itemId- the id of the menu itemreviewerEmail- the email of the person writing the reviewdateReviewed- the date the item was reviewedstars- the number of stars given to the reviewcomments- the comment left by the reviewer- Returns:
- the saved review
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
deleteMenuItemReview
-
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 the review to updateincoming- the new review- Returns:
- the updated review object
-