Class HelpRequestsController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.HelpRequestsController
@RequestMapping("/api/helprequests")
@RestController
public class HelpRequestsController
extends ApiController
This is a REST controller for HelpRequests
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList all help requestsDelete a HelpRequestGet a single request by idpostHelpRequest
(String requesterEmail, String teamId, String tableOrBreakoutRoom, LocalDateTime requestTime, String explanation, boolean solved) Create a new help requestupdateHelpRequest
(Long id, @Valid HelpRequest incoming) Update a single 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("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
- the requester's emailteamId
- the requester's team as a stringtableOrBreakoutRoom
- the table and/or breakout room of the requesterrequestTime
- the date and time of when the request was madeexplanation
- the explanation of why help is being requestedsolved
- the status 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 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 request- Parameters:
id
- id of the request to updateincoming
- the new request- Returns:
- the updated request object
-
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
-