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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateRecommendationRequest
(String requesterEmail, String professorEmail, String explanation, LocalDateTime dateRequested, LocalDateTime dateNeeded, boolean doneBool) Delete a recommendation request by its IDgetRequestById
(Long id) Get a specific recommendation request by its IDupdateRecommendationRequest
(Long id, @Valid RecommendationRequest incoming) Update a recommendation request by its IDMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
RecommendationRequestsController
public RecommendationRequestsController()
-
-
Method Details
-
getAllRequests
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<RecommendationRequest> getAllRequests() -
createRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public RecommendationRequest createRecommendationRequest(@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 doneBool) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getRequestById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public RecommendationRequest getRequestById(@RequestParam Long id) Get a specific recommendation request by its ID- Parameters:
id
- the ID of the recommendation request- Returns:
- the corresponding RecommendationRequest
-
deleteRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteRecommendationRequest(@RequestParam Long id) Delete a recommendation request by its ID- Parameters:
id
- the ID of the recommendation request to be deleted- Returns:
- a message confirming the deletion
-
updateRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public RecommendationRequest updateRecommendationRequest(@RequestParam Long id, @RequestBody @Valid @Valid RecommendationRequest incoming) Update a recommendation request by its ID- Parameters:
id
- the ID of the recommendation request to be updatedincoming
- the new request data- Returns:
- the updated RecommendationRequest
-