Class RecommendationRequestController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.RecommendationRequestController
@RequestMapping("/api/recommendationrequests")
@RestController
public class RecommendationRequestController
extends ApiController
This is a REST controller for RecommendationRequests
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList all Recommendation requestsDelete a RecommendationRequestGet a single request by idpostRecommendationRequest
(String requesterEmail, String professorEmail, String explanation, LocalDateTime dateRequested, LocalDateTime dateNeeded, boolean done) Create a new requestupdateRecommendationRequest
(Long id, @Valid RecommendationRequest incoming) Update a single dateMethods 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()List all Recommendation requests- Returns:
- an iterable of RecommendationRequest
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public RecommendationRequest getById(@RequestParam Long id) Get a single request by id- Parameters:
id
- the id of the request- Returns:
- a RecommendationRequest
-
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 boolean done) throws com.fasterxml.jackson.core.JsonProcessingException Create a new request- Parameters:
requesterEmail
- email of requesterprofessorEmail
- email of professorexplanation
- reason for recommendationdateRequested
- date of requestdateNeeded
- date request must be processed bydone
- status of request- Returns:
- the saved recommendationrequest
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
deleteRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteRecommendationRequest(@RequestParam Long id) Delete a RecommendationRequest- Parameters:
id
- the id of the date to delete- Returns:
- a message indicating the date was deleted
-
updateRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public RecommendationRequest updateRecommendationRequest(@RequestParam Long id, @RequestBody @Valid @Valid RecommendationRequest incoming) Update a single date- Parameters:
id
- id of the date to updateincoming
- the new date- Returns:
- the updated date object
-