Class HelpRequestController

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

@RequestMapping("/api/helprequest") @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 HelpRequest
    • getById

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

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public HelpRequest postHelpRequest(@RequestParam String requesterEmail, @RequestParam String teamId, @RequestParam String tableOrBreakoutRoom, @RequestParam String explanation, @RequestParam boolean solved, @RequestParam("requestTime") @DateTimeFormat(iso=DATE_TIME) LocalDateTime requestTime) throws com.fasterxml.jackson.core.JsonProcessingException
      Create a new HelpRequest
      Parameters:
      requesterEmail - ; email of the requester
      teamId - ID of the requester's team
      tableOrBreakoutRoom - table/breakout room of requester
      explanation - the solution to the help request
      solved - flag to indicate status of the request
      requestTime - time of the help request
      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 request to delete
      Returns:
      a message indicating the request was deleted
    • updateHelpRequest

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