Class RoleController

java.lang.Object
com.alpaca.controller.RoleController

@RestController @RequestMapping("/api/roles") public class RoleController extends Object
REST controller for managing Role entities.

Provides endpoints for CRUD operations and pagination of roles. Utilizes IRoleService for business logic and IRoleMapper for DTO conversions.

See Also:
  • Field Details

  • Constructor Details

    • RoleController

      public RoleController()
  • Method Details

    • findById

      @GetMapping("/{id}") public org.springframework.http.ResponseEntity<RoleResponseDTO> findById(@PathVariable UUID id)
      Retrieves a RoleResponseDTO by its unique identifier.
      Parameters:
      id - the unique identifier of the role; must not be null
      Returns:
      ResponseEntity containing the RoleResponseDTO with status HttpStatus.OK
      Throws:
      NotFoundException - if no role is found with the given id
    • save

      @PostMapping public org.springframework.http.ResponseEntity<RoleResponseDTO> save(@Valid @RequestBody @Valid RoleRequestDTO request)
      Creates a new Role.
      Parameters:
      request - the RoleRequestDTO containing the role's details; must not be null
      Returns:
      ResponseEntity containing the created RoleResponseDTO with status HttpStatus.CREATED
      Throws:
      BadRequestException - if the request is null or contains invalid data
    • updateById

      @PutMapping("/{id}") public org.springframework.http.ResponseEntity<RoleResponseDTO> updateById(@Valid @RequestBody @Valid RoleRequestDTO request, @PathVariable UUID id)
      Updates an existing Role identified by its unique identifier.
      Parameters:
      request - the RoleRequestDTO containing the updated role's details; must not be null
      id - the unique identifier of the role to update; must not be null
      Returns:
      ResponseEntity containing the updated RoleResponseDTO with status HttpStatus.OK
      Throws:
      NotFoundException - if no role is found with the given id
      BadRequestException - if the request is null or contains invalid data
    • delete

      @DeleteMapping("/{id}") public org.springframework.http.ResponseEntity<Void> delete(@PathVariable UUID id)
      Deletes a Role identified by its unique identifier.
      Parameters:
      id - the unique identifier of the role to delete; must not be null
      Returns:
      ResponseEntity with status HttpStatus.NO_CONTENT
      Throws:
      NotFoundException - if no role is found with the given id
    • findAll

      @GetMapping public org.springframework.http.ResponseEntity<List<RoleResponseDTO>> findAll()
      Retrieves all RoleResponseDTOs.
      Returns:
      ResponseEntity containing a list of RoleResponseDTOs with status HttpStatus.OK
    • findAllPage

      @GetMapping("/page") public org.springframework.http.ResponseEntity<org.springframework.data.web.PagedModel<RoleResponseDTO>> findAllPage(org.springframework.data.domain.Pageable pageable)
      Retrieves a paginated list of RoleResponseDTOs.
      Parameters:
      pageable - the pagination information; must not be null
      Returns:
      ResponseEntity containing a PagedModel of RoleResponseDTOs with status HttpStatus.OK