Package edu.ucsb.cs156.rec.controllers
Class RequestTypesController
java.lang.Object
edu.ucsb.cs156.rec.controllers.ApiController
edu.ucsb.cs156.rec.controllers.RequestTypesController
@RequestMapping("/api/requesttypes")
@RestController
public class RequestTypesController
extends ApiController
This is a REST controller for Request Types
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionThis method returns a list of all request types.This method returns a single request type.postRequestType
(String requestType) This method creates a new request type.Methods inherited from class edu.ucsb.cs156.rec.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException, handleGenericException
-
Constructor Details
-
RequestTypesController
public RequestTypesController()
-
-
Method Details
-
allRequestTypes
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<RequestType> allRequestTypes()This method returns a list of all request types.- Returns:
- a list of all request types
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public RequestType getById(@RequestParam Long id) This method returns a single request type.- Parameters:
id
- id of the request type to get- Returns:
- a single request type
-
postRequestType
@PreAuthorize("hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_INSTRUCTOR\')") @PostMapping("/post") public RequestType postRequestType(@RequestParam String requestType) This method creates a new request type. Accessible only to users with the role "ROLE_ADMIN" or "ROLE_INSTRUCTOR".- Parameters:
requestType
- description of the request type- Returns:
- the save request type (with it's id field set by the database)
-