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
This is a REST controller for RecommendationRequests
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all recommendation requestsDelete a RecommendationRequestGet a single recommendation request by idpostRecommendationRequest(String requesterEmail, String professorEmail, String explanation, LocalDateTime dateRequested, LocalDateTime dateNeeded, boolean done) Create a new recommendation requestupdateRecommendationRequest(Long id, @Valid RecommendationRequest incoming) Update a single recommendation requestMethods inherited from class 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 recommendation request by id- Parameters:
id- the id of the recommendation 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) Create a new recommendation request- Parameters:
requesterEmail- the email of the student requesting the recommendationprofessorEmail- the email of the professor being asked for the recommendationexplanation- what the recommendation is for (e.g. the program being applied to)dateRequested- the date the recommendation was requesteddateNeeded- the date by which the recommendation is neededdone- whether the recommendation request has been fulfilled- Returns:
- the saved recommendation request
-
deleteRecommendationRequest
-
updateRecommendationRequest
@PreAuthorize("hasRole('ROLE_ADMIN')") @PutMapping("") public RecommendationRequest updateRecommendationRequest(@RequestParam Long id, @RequestBody @Valid @Valid RecommendationRequest incoming) Update a single recommendation request- Parameters:
id- id of the recommendation request to updateincoming- the new values for the recommendation request- Returns:
- the updated recommendation request
-