Package edu.ucsb.cs156.rec.controllers
Class RecommendationRequestController
java.lang.Object
edu.ucsb.cs156.rec.controllers.ApiController
edu.ucsb.cs156.rec.controllers.RecommendationRequestController
@RequestMapping("/api/recommendationrequest")
@RestController
public class RecommendationRequestController
extends ApiController
This is a REST controller for RecommendationRequest
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList all recommendation requestsDelete a recommendation requestgetAllRecommendationRequestsByProfessor
(long userId) Get all recommendation requests by Professor idgetAllRecommendationRequestsByRequester
(long userId) Get all recommendation requests by Requester idGet a single recommendation request by idpostRecommendationRequest
(String professorEmail, String recommendationType, String details) Create a new recommendation requestupdateRecommendationRequest
(Long id, @Valid RecommendationRequest incoming) Update a single recommendation requestMethods inherited from class edu.ucsb.cs156.rec.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
RecommendationRequestController
public RecommendationRequestController()
-
-
Method Details
-
allRecommendationRequests
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/all") public Iterable<RecommendationRequest> allRecommendationRequests()List all recommendation requests- Returns:
- an iterable of RecommendationRequest
-
getById
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("") public RecommendationRequest getById(@RequestParam Long id) Get a single recommendation request by id- Parameters:
id
- the id of the recommendation request- Returns:
- a recommendation request
- Throws:
EntityNotFoundException
- if the recommendation request is not found
-
postRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_STUDENT\')") @PostMapping("/post") public RecommendationRequest postRecommendationRequest(@RequestParam String professorEmail, @RequestParam String recommendationType, @RequestParam String details) throws com.fasterxml.jackson.core.JsonProcessingException Create a new recommendation request- Parameters:
professorEmail
- the email of the professorrecommendationType
- the type of recommendationsdetails
- the other details of the request- Returns:
- the created RecommendationRequest
- Throws:
EntityNotFoundException
- if the professor is not found or is hte user does not have the professor rolecom.fasterxml.jackson.core.JsonProcessingException
-
deleteRecommendationRequest
@PreAuthorize("hasRole(\'ROLE_USER\')") @DeleteMapping("") public Object deleteRecommendationRequest(@RequestParam Long id) Delete a recommendation request- Parameters:
id
- the id of the recommendation request to delete- Returns:
- a message indicating the recommedation request was deleted
- Throws:
EntityNotFoundException
- if the recommendation request is not found
-
updateRecommendationRequest
@PreAuthorize("hasAnyRole(\'ROLE_ADMIN\', \'ROLE_PROFESSOR\')") @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 recommendation request- Returns:
- the updated recommendation request object
- Throws:
EntityNotFoundException
- if the recommendation request is not found
-
getAllRecommendationRequestsByProfessor
@PreAuthorize("hasAnyRole(\'ROLE_ADMIN\', \'ROLE_PROFESSOR\')") @GetMapping("/professor/{userId}") public List<RecommendationRequest> getAllRecommendationRequestsByProfessor(@PathVariable("userId") long userId) Get all recommendation requests by Professor id- Parameters:
userId
- the user Id of the professor- Returns:
- a list of all rec reqs directed towards the professor with the given userId
- Throws:
EntityNotFoundException
- if the professor is not found
-
getAllRecommendationRequestsByRequester
@PreAuthorize("hasAnyRole(\'ROLE_ADMIN\', \'ROLE_STUDENT\')") @GetMapping("/requester/{userId}") public List<RecommendationRequest> getAllRecommendationRequestsByRequester(@PathVariable("userId") long userId) Get all recommendation requests by Requester id- Parameters:
userId
- the user Id of the requester- Returns:
- a list of all rec reqs made by the requester with the given userId
- Throws:
EntityNotFoundException
- if the requester is not found
-