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 RequestTypes
  • Constructor Details

    • RequestTypesController

      public RequestTypesController()
  • Method Details

    • allRequestTypes

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<RequestType> allRequestTypes()
      List all Request Types
      Returns:
      an iterable of RequestType
    • getById

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public RequestType getById(@RequestParam Long id)
      Get a single request type by id
      Parameters:
      id - the id of the request type
      Returns:
      a RequestType
    • deleteRequestType

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteRequestType(@RequestParam Long id)
      Delete a RequestType
      Parameters:
      id - the id of the request type to delete
      Returns:
      a message indicating the request type was deleted
    • postRequestType

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public RequestType postRequestType(@RequestParam String requestType)
      Create a new request type
      Parameters:
      reqType - the name of the request type
      Returns:
      the saved requesttype
      Throws:
      DuplicateArgumentException - if the request type already exists.
    • updateRequestType

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public RequestType updateRequestType(@RequestParam Long id, @RequestBody @Valid @Valid RequestType incoming)
      Update a single request type
      Parameters:
      id - the name of the request type
      incoming - the new RequestType
      Returns:
      the saved requesttype
      Throws:
      DuplicateArgumentException - if the request type already exists.
      EntityNotFoundException - if the id does not exist in the table