Class ReviewController

java.lang.Object
edu.ucsb.cs156.dining.controllers.ApiController
edu.ucsb.cs156.dining.controllers.ReviewController

@RequestMapping("/api/reviews") @RestController public class ReviewController extends ApiController
This is a REST controller for Reviews
  • 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

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/all") public Iterable<Review> 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 item
      dateItemServed - 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