Class UCSBMenuItemReviewController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.UCSBMenuItemReviewController
@RequestMapping("/api/ucsbmenuitemreview")
@RestController
public class UCSBMenuItemReviewController
extends ApiController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all UCSB menu item reviewsDelete a UCSBMenuItemReviewGet a single UCSBMenuItemReview by idpostUCSBMenuItemReview
(long itemId, String reviewerEmail, int stars, LocalDateTime dateReviewed, String comments) Create a new UCSB menu item reviewupdateUCSBMenuItemReview
(Long id, @Valid UCSBMenuItemReview incoming) Update a single UCSBMenuItemReviewMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
UCSBMenuItemReviewController
public UCSBMenuItemReviewController()
-
-
Method Details
-
allUCSBMenuItemRevies
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<UCSBMenuItemReview> allUCSBMenuItemRevies()List all UCSB menu item reviews- Returns:
- an iterable of UCSBMenuItemReview
-
postUCSBMenuItemReview
@PreAuthorize("hasRole(\'ROLE_USER\')") @PostMapping("/post") public UCSBMenuItemReview postUCSBMenuItemReview(@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 UCSB menu item review- Parameters:
itemId
- the id of the menu itemreviewerEmail
- the email of the reviewerstars
- the number of stars (0 to 5) // * @param dateReviewed the date the review was madecomments
- the comments of the review- Returns:
- the created UCSBMenuItemReview
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public UCSBMenuItemReview getById(@RequestParam Long id) Get a single UCSBMenuItemReview by id- Parameters:
id
- the id of the review- Returns:
- a UCSBMenuItemReview
-
updateUCSBMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public UCSBMenuItemReview updateUCSBMenuItemReview(@RequestParam Long id, @RequestBody @Valid @Valid UCSBMenuItemReview incoming) Update a single UCSBMenuItemReview- Parameters:
id
- id of the review to updateincoming
- the new review- Returns:
- the updated review object
-
deleteUCSBMenuItemReview
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteUCSBMenuItemReview(@RequestParam Long id) Delete a UCSBMenuItemReview- Parameters:
id
- the id of the review to delete- Returns:
- a message indicating the review was deleted
-