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 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) LocalDateTime requestTime) throws com.fasterxml.jackson.core.JsonProcessingException
      Create a new helprequest
      Parameters:
      requesterEmail - the requester's email
      teamId - the ID of the team of the requester
      tableOrBreakoutRoom - the table or breakout room of the requester
      explanation - the explanation for the problem
      solved - the boolean paramter indicating if the problem is sloved
      requestTime - the timestamp on the help request, with time zome information
      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 date to update
      incoming - the new hleprequest
      Returns:
      the updated date 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 helprequest was deleted