Class MenuItemReviewsController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.MenuItemReviewsController
@RequestMapping("/api/menuitemreviews")
@RestController
public class MenuItemReviewsController
extends ApiController
This is a REST controller for MenuItemReviewsController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all MenuItemReviewsDelete a MenuItemReviewGet a single MenuItemReview by idpostMenuItemReview(long itemId, String reviewerEmail, int stars, String comments, LocalDateTime dateReviewed) updateMenuItemReview(Long id, @Valid MenuItemReview incoming) Update a single reviewMethods inherited from class ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
MenuItemReviewsController
public MenuItemReviewsController()
-
-
Method Details
-
allMenuItemReviews
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/all") public Iterable<MenuItemReview> allMenuItemReviews()List all MenuItemReviews- 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 String comments, @RequestParam LocalDateTime dateReviewed) throws com.fasterxml.jackson.core.JsonProcessingException - Parameters:
itemId- id of the itemreviewerEmail- email of the reviewerstars- the rating in starscomments- any commments left by the reviewerdateReviewed- the date of the review- 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 MenuItemReview by id- Parameters:
id- the id of the MenuItemReview- Returns:
- a MenuItemReview
-
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 menuitemreview object
-
deleteMenuItemReview
-