Class RequestTypeController

java.lang.Object
edu.ucsb.cs156.rec.controllers.ApiController
edu.ucsb.cs156.rec.controllers.RequestTypeController

@RequestMapping("/api/request-types") @RestController public class RequestTypeController extends ApiController
This is a REST controller for Request Types.
  • Constructor Details

    • RequestTypeController

      public RequestTypeController()
  • 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\')") @PostMapping("/post") public org.springframework.http.ResponseEntity<Object> postRequestType(@RequestParam String description)
      This method creates a new request type. Accessible only to users with the role "ROLE_ADMIN".
      Parameters:
      description - description of the request type
      Returns:
      the saved request type (with its id field set by the database)
    • deleteRequestType

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteRequestType(@RequestParam Long id)
      Deletes a request type. Accessible only to users with the role "ROLE_ADMIN".
      Parameters:
      id - id of the request type to delete
      Returns:
      a message indicating that the request type was deleted
    • updateRequestType

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public org.springframework.http.ResponseEntity<Object> updateRequestType(@RequestParam Long id, @RequestParam String description)
      Update a single request type. Accessible only to users with the role "ROLE_ADMIN".
      Parameters:
      id - id of the request type to update
      description - the new description for the request type
      Returns:
      the updated request type object