Class RecommendationRequestsController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.RecommendationRequestsController
@RequestMapping("/api/recommendationrequests")
@RestController
public class RecommendationRequestsController
extends ApiController
This is a REST controller for req requests
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList all recommendation requestsDelete a Recommendation RequestGet a single request by idpostRecommendationRequest
(String requesterEmail, String professorEmail, String explanation, LocalDateTime dateRequested, LocalDateTime dateNeeded, boolean done) Create a new rec requpdateRecommendationRequest
(Long id, @Valid RecommendationRequest incoming) Update a single rec reqMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
RecommendationRequestsController
public RecommendationRequestsController()
-
-
Method Details
-
allRecommendationRequests
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<RecommendationRequest> allRecommendationRequests()List all recommendation requests- Returns:
- an iterable of rec req
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public RecommendationRequest getById(@RequestParam Long id) Get a single request by id- Parameters:
id
- the id of the rec req- Returns:
- a recommendation request
-
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 rec req- Parameters:
requesterEmail
- the email of the requesterprofessorEmail
- the professor to requestexplanation
- the explanationdateRequested
- the date requesteddateNeeded
- the date it is neededdone
- is it done- Returns:
- the saved recommendation req
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
updateRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public RecommendationRequest updateRecommendationRequest(@RequestParam Long id, @RequestBody @Valid @Valid RecommendationRequest incoming) Update a single rec req- Parameters:
id
- the id of the rec request to updateincoming
- an object to copy from- Returns:
- the saved recommendation req
-
deleteRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteRecommendationRequest(@RequestParam Long id) Delete a Recommendation Request- Parameters:
id
- the id of the rec request to delete- Returns:
- a message indicating the req request was deleted
-