Class UserController

java.lang.Object
com.alpaca.controller.UserController

@RestController @RequestMapping("/api/users") public class UserController extends Object
REST controller for managing User entities.

Provides endpoints for CRUD operations and pagination of users. Utilizes IUserService for business logic and IUserMapper for DTO conversions.

See Also:
  • Field Details

  • Constructor Details

    • UserController

      public UserController()
  • Method Details

    • findById

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

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

      @PutMapping("/{id}") public org.springframework.http.ResponseEntity<UserResponseDTO> updateById(@Valid @RequestBody @Valid UserRequestDTO request, @PathVariable UUID id)
      Updates an existing user identified by its unique identifier.
      Parameters:
      request - the UserRequestDTO containing the updated user's details; must not be null
      id - the unique identifier of the user to update; must not be null
      Returns:
      ResponseEntity containing the updated UserResponseDTO with status HttpStatus.OK
      Throws:
      NotFoundException - if no user 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 user identified by its unique identifier.
      Parameters:
      id - the unique identifier of the user to delete; must not be null
      Returns:
      ResponseEntity with status HttpStatus.NO_CONTENT
      Throws:
      NotFoundException - if no user is found with the given id
    • findAll

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

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