Class ReviewsController

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

@RequestMapping("/api/reviews") @RestController public class ReviewsController extends ApiController
This is a REST controller for Reviews
  • Constructor Details

    • ReviewsController

      public ReviewsController()
  • Method Details

    • allReviews

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/all") public Iterable<Reviews> allReviews()
      THis method returns a list of all reviews.
      Returns:
      a list of all reviews
    • postReview

      @PreAuthorize("hasRole(\'ROLE_USER\')") @PostMapping("/post") public Reviews postReview(@RequestParam int item_id, @RequestParam int rating, @RequestParam String comments, @RequestParam("date_served") @DateTimeFormat(iso=DATE_TIME) LocalDateTime date_served) throws com.fasterxml.jackson.core.JsonProcessingException
      This method creates a new review. Accessible only to users with the role "ROLE_ADMIN".
      Parameters:
      item_id - itemID of the review
      date_served - date served
      Returns:
      the save review
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getByCurrUserId

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public Iterable<Reviews> getByCurrUserId()
      This method returns all reviews from current user.
      Returns:
      all reviews from current user.