Class HelpRequestController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.HelpRequestController
@RequestMapping("/api/helprequests")
@RestController
public class HelpRequestController
extends ApiController
This is a REST controller for HelpRequests
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList all UCSB datesDelete a HelpRequestGet a single date by idpostHelpRequest
(String requesterEmail, String teamId, String tableOrBreakoutRoom, String explanation, boolean solved, LocalDateTime requestTime) Create a 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
-
HelpRequestController
public HelpRequestController()
-
-
Method Details
-
allHelpRequests
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<HelpRequest> allHelpRequests()List all UCSB dates- Returns:
- an iterable of HelpRequest
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public HelpRequest getById(@RequestParam Long id) Get a single date by id- Parameters:
id
- the id of the date- Returns:
- a UCSBDate
-
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 help request- Parameters:
requesterEmail
- the email of the requesterteamId
- the id of the teamtableOrBreakoutRoom
- whether its at a table or breakout roomexplanation
- the details of requestsolved
- whether request has been solved or notrequestTime
- the date and time of request in the format YYYY-mm-ddTHH:MM:SS- Returns:
- the saved helprequest
- 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 request to delete- Returns:
- a message indicating the request was deleted
-
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 date to updateincoming
- the new request- Returns:
- the updated request object
-