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 HelpRequests
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList all help requestsDelete a HelpRequestGet a single date by idpostHelpRequest
(String requesterEmail, String teamId, String tableOrBreakoutRoom, LocalDateTime requestTime, String explanation, boolean solved) Create a new dateupdateHelpRequest
(Long id, @Valid HelpRequest incoming) Update a single dateMethods 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 help requests- 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 HelpRequest- Returns:
- a 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 date- Parameters:
requesterEmail
-teamId
-tableOrBreakoutRoom
-requestTime
-explanation
-solved
-- 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 HelpRequest to delete- Returns:
- a message indicating the HelpRequest was deleted
-
updateHelpRequest
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public HelpRequest updateHelpRequest(@RequestParam Long id, @RequestBody @Valid @Valid HelpRequest incoming) Update a single date- Parameters:
id
- id of the date to updateincoming
- the new date- Returns:
- the updated date object
-