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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList all Menu Item ReviewsDelete a UCSBDateGet a single review by idpostMenuItemReview
(Long itemId, String reviewerEmail, int stars, LocalDateTime localDateTime, String comments) Create a new reviewupdateMenuItemReview
(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()List all Menu Item Reviews- Returns:
- an iterable of MenuItemRevire
-
postMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public MenuItemReview postMenuItemReview(@RequestParam Long itemId, @RequestParam String reviewerEmail, @RequestParam int stars, @RequestParam("localDateTime") @DateTimeFormat(iso=DATE_TIME) LocalDateTime localDateTime, @RequestParam String comments) throws com.fasterxml.jackson.core.JsonProcessingException Create a new review- Parameters:
itemId
-reviewerEmail
-stars
-localDateTime
-comments
-- Returns:
- the saved review
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
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
-
deleteMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteMenuItemReview(@RequestParam Long id) Delete a UCSBDate- Parameters:
id
- the id of the date to delete- Returns:
- a message indicating the date was deleted
-
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
-