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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all HelpRequestsDelete a HelpRequestGet a single helprequest by idpostHelpRequest
(String requesterEmail, String teamId, String tableOrBreakoutRoom, String explanation, boolean solved, LocalDateTime requestTime) Create a new helprequestupdateHelpRequest
(Long id, @Valid HelpRequest incoming) Update a single helprequestMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
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 emailteamId
- the ID of the team of the requestertableOrBreakoutRoom
- the table or breakout room of the requesterexplanation
- the explanation for the problemsolved
- the boolean paramter indicating if the problem is slovedrequestTime
- 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 updateincoming
- 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
-