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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionThis method returns a list of all Recommendation Requests intended for current user who is a professor.This method returns a list of all Recommendation Requests requested by current student.Any admin can delete a RecommendationRequestThe user who posted a RecommendationRequest can delete their RecommendationRequestThis method returns a single recommendation request where the current user is either the requester or the professor.This method returns a list of recommendation requests with specified status for a professor.postRecommendationRequests
(Long professorId, String recommendationType, String details, LocalDateTime dueDate) This method creates a new Recommendation Request.updateRecommendationRequestAsAdmin
(Long id, @Valid RecommendationRequest incoming) Prof can update a Recommendation Request's statusupdateRecommendationRequestAsUser
(Long id, @Valid RecommendationRequest incoming) The user who posted a RecommendationRequest can update their RecommendationRequestMethods inherited from class edu.ucsb.cs156.rec.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException, handleIllegalArgumentException
-
Constructor Details
-
RecommendationRequestController
public RecommendationRequestController()
-
-
Method Details
-
deleteRecommendationRequestAsAdmin
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("/admin") public Object deleteRecommendationRequestAsAdmin(@RequestParam Long id) Any admin can delete a RecommendationRequest- Parameters:
id
- the id of the RecommendationRequest to delete- Returns:
- a message indicating that the RecommendationRequest was deleted
-
deleteRecommendationRequestAsUser
@PreAuthorize("hasRole(\'ROLE_USER\')") @DeleteMapping("") public Object deleteRecommendationRequestAsUser(@RequestParam Long id) The user who posted a RecommendationRequest can delete their RecommendationRequest- Parameters:
id
- the id of the RecommendationRequest to delete- Returns:
- a message indicating that the RecommendationRequest was deleted
-
updateRecommendationRequestAsUser
@PreAuthorize("hasRole(\'ROLE_USER\')") @PutMapping("") public RecommendationRequest updateRecommendationRequestAsUser(@RequestParam Long id, @RequestBody @Valid @Valid RecommendationRequest incoming) The user who posted a RecommendationRequest can update their RecommendationRequest- Parameters:
id
- the id of the Recommendation Request to updateincoming
- the updated Recommendation Request- Returns:
- the updated Recommendation Request object
-
updateRecommendationRequestAsAdmin
@PreAuthorize("hasRole(\'ROLE_PROFESSOR\')") @PutMapping("/professor") public RecommendationRequest updateRecommendationRequestAsAdmin(@RequestParam Long id, @RequestBody @Valid @Valid RecommendationRequest incoming) Prof can update a Recommendation Request's status- Parameters:
id
- the id of the Recommendation Request to updateincoming
- the updated Recommendation Request- Returns:
- the updated Recommendation Request object
-
allRequesterRecommendationRequests
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/requester/all") public Iterable<RecommendationRequest> allRequesterRecommendationRequests()This method returns a list of all Recommendation Requests requested by current student.- Returns:
- a list of all Recommendation Requests requested by the current user
-
allProfessorRecommendationRequests
@PreAuthorize("hasRole(\'ROLE_PROFESSOR\')") @GetMapping("/professor/all") public Iterable<RecommendationRequest> allProfessorRecommendationRequests()This method returns a list of all Recommendation Requests intended for current user who is a professor.- Returns:
- a list of all Recommendation Requests intended for the current user who is a professor
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public RecommendationRequest getById(@RequestParam Long id) This method returns a single recommendation request where the current user is either the requester or the professor.- Parameters:
id
- id of the Recommendation Requests to get- Returns:
- a single recommendation request where the current user is either the requester or the professor
-
postRecommendationRequests
@PreAuthorize("hasRole(\'ROLE_USER\')") @PostMapping("/post") public RecommendationRequest postRecommendationRequests(@RequestParam Long professorId, @RequestParam String recommendationType, @RequestParam String details, @RequestParam @DateTimeFormat(iso=DATE_TIME) LocalDateTime dueDate) This method creates a new Recommendation Request. Accessible only to users with the role "ROLE_USER" so professors and students can both create.- Parameters:
professorId
- id from a dropdown of professors from the form in create pagerecommendationType
- recommendation types of requestdetails
- details of requestdueDate
- submission date of request- Returns:
- the save recommendationrequests (with it's id field set by the database)
-
getRecommendationRequestByStatusForProfessor
@GetMapping("/professor/filtered") @PreAuthorize("hasRole(\'ROLE_PROFESSOR\')") public Iterable<RecommendationRequest> getRecommendationRequestByStatusForProfessor(@RequestParam String status) This method returns a list of recommendation requests with specified status for a professor.- Returns:
- a list of recommendation requests with specified status for a professor.
-