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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all help requestsDelete a HelpRequestGet a single help 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 help requestMethods inherited from class 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 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("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 email of the student requesting helpteamId- the id of the requester's teamtableOrBreakoutRoom- the table or breakout room the requester is atrequestTime- the time the help was requestedexplanation- an explanation of what the requester needs help withsolved- whether the request has been solved- Returns:
- the saved help request
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
deleteHelpRequest
-
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
-