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 HelpRequests
  • Constructor Details

    • HelpRequestController

      public HelpRequestController()
  • Method Details

    • allHelpRequests

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<HelpRequest> allHelpRequests()
      List all HelpRequests
      Returns:
      an iterable of HelpRequests
    • 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) ZonedDateTime requestTime) throws com.fasterxml.jackson.core.JsonProcessingException
      Create a new HelpRequest
      Parameters:
      requesterEmail - the email of the person submitting helprequest
      teamId - the ID of the team
      tableOrBreakoutRoom - the name of the table that needs help
      explanation - explanation of what need help with
      solved - tells us whether the helprequest is solved or not
      requestTime - the time of the request
      Returns:
      the saved helprequest
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getById

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

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public HelpRequest updateHelpRequest(@RequestParam Long id, @RequestBody @Valid @Valid HelpRequest incoming)
      Update a single helprequest
      Parameters:
      id - id of the helprequest to update
      incoming - the new helprequest
      Returns:
      the updated helprequest object
    • 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 date was deleted