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 RequestsdeleteUCSBDate
(Long id) Delete 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
-
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 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 email of the requesterteamId
- the team id of the team the requester is intableOrBreakoutRoom
- where the help request is needed/locatedexplanation
- a description of the help neededsolved
- whether or not the help request has been resolvedrequestTime
- when the help request was sent- Returns:
- the saved help request
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
deleteUCSBDate
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteUCSBDate(@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
-
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
-