Class RecommendationRequestController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.RecommendationRequestController
@RequestMapping("/api/RecommendationRequest")
@RestController
public class RecommendationRequestController
extends ApiController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all recommendation requests.Delete a recommendation request by id.Get a recommendation request by id.postRecommendationRequest(String requesterEmail, String professorEmail, String explanation, LocalDateTime dateRequested, LocalDateTime dateNeeded, String done) Create a new recommendation request.updateRecommendationRequest(Long id, @Valid RecommendationRequest incoming) Update a recommendation request by id.Methods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
RecommendationRequestController
public RecommendationRequestController()
-
-
Method Details
-
allRecommendationRequests
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<RecommendationRequest> allRecommendationRequests() throws com.fasterxml.jackson.core.JsonProcessingExceptionList all recommendation requests.- Returns:
- all recommendation requests
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- on serialization error
-
getRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public RecommendationRequest getRecommendationRequest(@RequestParam Long id) Get a recommendation request by id.- Parameters:
id- the id of the recommendation request- Returns:
- the recommendation request
-
updateRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public RecommendationRequest updateRecommendationRequest(@RequestParam Long id, @RequestBody @Valid @Valid RecommendationRequest incoming) Update a recommendation request by id.- Parameters:
id- the id of the recommendation requestincoming- the updated recommendation request fields- Returns:
- the updated recommendation request
-
deleteRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteRecommendationRequest(@RequestParam Long id) Delete a recommendation request by id.- Parameters:
id- the id of the recommendation request- Returns:
- a message indicating the record was deleted
-
postRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public RecommendationRequest postRecommendationRequest(@RequestParam String requesterEmail, @RequestParam String professorEmail, @RequestParam String explanation, @RequestParam("dateRequested") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateRequested, @RequestParam("dateNeeded") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateNeeded, @RequestParam String done) Create a new recommendation request.- Parameters:
requesterEmail- email of the requesterprofessorEmail- email of the professorexplanation- explanation for the requestdateRequested- date the request was madedateNeeded- date the letter is neededdone- whether the request is complete- Returns:
- the created recommendation request
-