Class HelpRequestController

java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.HelpRequestController

@RequestMapping("/api/helprequests") @RestController public class HelpRequestController extends ApiController
This is a REST controller for HelpRequest
  • Constructor Details

    • HelpRequestController

      public HelpRequestController()
  • Method Details

    • allHelpRequests

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<HelpRequest> allHelpRequests()
      List all help requests
      Returns:
      an iterable of help requests
    • getById

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public HelpRequest getById(@RequestParam Long id)
      Get a single request by id
      Parameters:
      id - the id of the help request
      Returns:
      a HelpRequest
    • posthHelpRequest

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public HelpRequest posthHelpRequest(@RequestParam String requesterEmail, @RequestParam String teamId, @RequestParam String tableOrBreakoutRoom, @RequestParam("requestTime") @DateTimeFormat(iso=DATE_TIME) LocalDateTime requestTime, @RequestParam String explanation, @RequestParam boolean solved) throws com.fasterxml.jackson.core.JsonProcessingException
      Create a help request
      Parameters:
      requesterEmail - the requester's email ID
      teamId - the team id of the requester
      tableOrBreakoutRoom - where the help request is coming from
      requestTime - the time help request was submitted
      explanation - an explanation of the help request
      solved - bool that indicates if the issue has been solved
      Returns:
      the saved help request
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • deleteHelpRequest

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteHelpRequest(@RequestParam Long id)
      Delete a HelpRequest
      Parameters:
      id - the id of the helprequest to delete
      Returns:
      a message indicating the helprequest was deleted
    • updateHelpRequest

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public HelpRequest updateHelpRequest(@RequestParam Long id, @RequestBody @Valid @Valid HelpRequest incoming)
      Update a single help request
      Parameters:
      id - id of the help request
      incoming - the new help request
      Returns:
      the updated helpreuqest object