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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionTHis method returns a list of all reviews.This method returns all reviews from current user.postReview
(int item_id, int rating, String comments, LocalDateTime date_served) This method creates a new review.Methods inherited from class edu.ucsb.cs156.dining.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
ReviewsController
public ReviewsController()
-
-
Method Details
-
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 reviewdate_served
- date served- Returns:
- the save review
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getByCurrUserId
This method returns all reviews from current user.- Returns:
- all reviews from current user.
-