Class HelpRequestsController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.HelpRequestsController
@RequestMapping("/api/help_requests")
@RestController
public class HelpRequestsController
extends ApiController
This is a REST controller for HelpRequest
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all help requestsDelete a HelpRequestGet a single help_request by idpostHelpRequest(String requesterEmail, String teamId, String tableOrBreakoutRoom, String explanation, boolean solved, LocalDateTime requestTime) Create a new help requestupdateHelpRequest(Long id, @Valid HelpRequest incoming) Update a single help_requestMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
HelpRequestsController
public HelpRequestsController()
-
-
Method Details
-
allHelpRequests
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<HelpRequest> allHelpRequests()List all help requests- Returns:
- an iterable of 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 help request- Parameters:
requesterEmail- the requester's emailteamId- the team idtableOrBreakoutRoom- the number of table or breakout roomexplanation- the explanationsolved- the boolean indicating if the request is solvedrequestTime- the request time- 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 date to delete- Returns:
- a message indicating the help request was deleted
-
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
-
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 updateincoming- the new help_request- Returns:
- the updated help_request object
-