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 MenuItemReviews
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all menu item reviewsdeleteUCSBDate(Long id) Delete a MenuItemReviewGet a single review by idpostMenuItemReview(long itemid, String reviewerEmail, int stars, LocalDateTime dateReviewed, String comments) Create a new menu item reviewupdateMenuItemReview(Long id, @Valid MenuItemReview incoming) Update a single reviewMethods inherited from class 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 MenuItemReviews
-
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 int stars, @RequestParam("dateReviewed") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateReviewed, @RequestParam String comments) throws com.fasterxml.jackson.core.JsonProcessingException Create a new menu item review- Parameters:
itemid- the id of the item being reviewedreviewerEmail- the email of whomever submitted the reviewstars- the star rating givendateReviewed- the date of the reviewcomments- any comments on the review- Returns:
- the saved menuItemReview
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
deleteUCSBDate
-
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 date object
-