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 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 update
      incoming - 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 update
      incoming - 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 page
      recommendationType - recommendation types of request
      details - details of request
      dueDate - 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.