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

    • allRecommendationRequests

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/alladmin") public Iterable<RecommendationRequest> allRecommendationRequests()
      List all recommendation requests
      Returns:
      an iterable of RecommendationRequest
    • getAllCurrentUser

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<RecommendationRequest> getAllCurrentUser()
      List all recommendation requests created by a user with requesterId
      Returns:
      an iterable of RecommendationRequest
    • postRecommendationRequest

      @PreAuthorize("hasRole(\'ROLE_USER\')") @PostMapping("/post") public RecommendationRequest postRecommendationRequest(@RequestParam Long professorId, @RequestParam String requestType, @RequestParam String details, @RequestParam("neededByDate") @DateTimeFormat(iso=DATE_TIME) LocalDateTime neededByDate) throws com.fasterxml.jackson.core.JsonProcessingException
      Create a new recommendation request
      Parameters:
      professorId - the id of the professor
      requestType - the request type
      details - the details of the recommendation request
      neededByDate - the date the request should be fulfilled by
      Returns:
      a RecommendationRequest
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getById

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public RecommendationRequest getById(@RequestParam Long id)
      Get a single request by id CHECK if recommendation request belongs to user
      Parameters:
      id - the id of the request
      Returns:
      a RecommendationRequest