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 help request by id
      Parameters:
      id - the id of the help request
      Returns:
      a HelpRequest
    • postHelpRequest

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public HelpRequest postHelpRequest(@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 new help request
      Parameters:
      requesterEmail - email of help requester
      teamId - team that requester belongs to (class-time-team#)
      tableOrBreakoutRoom - table number or breakout room number
      requestTime - time of request
      explanation - brief summary of problem
      solved - flag if problem has been solved or not
      Returns:
      the saved help request
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • 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 to update
      incoming - the new help request
      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 help request to delete
      Returns:
      a message indicating the help request was deleted