Class ReviewController
java.lang.Object
edu.ucsb.cs156.dining.controllers.ApiController
edu.ucsb.cs156.dining.controllers.ReviewController
This is a REST controller for Reviews
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionThis method returns a list of all Reviews.This method allows a user to get a list of reviews that they have previously made.postReview
(long itemId, String reviewerComments, Long itemsStars, LocalDateTime dateItemServed) This method allows a user to submit a reviewMethods inherited from class edu.ucsb.cs156.dining.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
ReviewController
public ReviewController()
-
-
Method Details
-
handleValidationExceptions
@ExceptionHandler(java.lang.IllegalArgumentException.class) public org.springframework.http.ResponseEntity<Map<String,String>> handleValidationExceptions(IllegalArgumentException ex) -
allReviews
This method returns a list of all Reviews.- Returns:
- a list of all Reviews
-
postReview
@PreAuthorize("hasRole(\'ROLE_USER\')") @PostMapping("/post") public Review postReview(@RequestParam long itemId, @RequestParam(required=false) String reviewerComments, @RequestParam Long itemsStars, @RequestParam("dateItemServed") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateItemServed) throws com.fasterxml.jackson.core.JsonProcessingException This method allows a user to submit a review- Parameters:
itemId
- id of the itemdateItemServed
- localDataTime All others params must not be parameters and instead derived from data sources that are dynamic (Date), or set to be null or some other signifier- Returns:
- message that says an review was added to the database
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
get_all_review_by_user_id
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/userReviews") public Iterable<Review> get_all_review_by_user_id()This method allows a user to get a list of reviews that they have previously made. Only user can only get a list of their own reviews, and you cant request another persons reviews- Returns:
- a list of reviews sent by a given user
-