Package com.alpaca.controller
Class UserController
java.lang.Object
com.alpaca.controller.UserController
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<Void> Deletes a user identified by its unique identifier.org.springframework.http.ResponseEntity
<List<UserResponseDTO>> findAll()
Retrieves all users.org.springframework.http.ResponseEntity
<org.springframework.data.web.PagedModel<UserResponseDTO>> findAllPage
(org.springframework.data.domain.Pageable pageable) Retrieves a paginated list of users.org.springframework.http.ResponseEntity
<UserResponseDTO> Retrieves a user by its unique identifier.org.springframework.http.ResponseEntity
<UserResponseDTO> save
(@Valid UserRequestDTO request) Creates a new user.org.springframework.http.ResponseEntity
<UserResponseDTO> updateById
(@Valid UserRequestDTO request, UUID id) Updates an existing user identified by its unique identifier.
-
Field Details
-
service
-
mapper
-
-
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 benull
- Returns:
ResponseEntity
containing theUserResponseDTO
with statusHttpStatus.OK
- Throws:
NotFoundException
- if no user is found with the givenid
-
save
@PostMapping public org.springframework.http.ResponseEntity<UserResponseDTO> save(@Valid @RequestBody @Valid UserRequestDTO request) Creates a new user.- Parameters:
request
- theUserRequestDTO
containing the user's details; must not benull
- Returns:
ResponseEntity
containing the createdUserResponseDTO
with statusHttpStatus.CREATED
- Throws:
BadRequestException
- if therequest
isnull
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
- theUserRequestDTO
containing the updated user's details; must not benull
id
- the unique identifier of the user to update; must not benull
- Returns:
ResponseEntity
containing the updatedUserResponseDTO
with statusHttpStatus.OK
- Throws:
NotFoundException
- if no user is found with the givenid
BadRequestException
- if therequest
isnull
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 benull
- Returns:
ResponseEntity
with statusHttpStatus.NO_CONTENT
- Throws:
NotFoundException
- if no user is found with the givenid
-
findAll
Retrieves all users.- Returns:
ResponseEntity
containing a list ofUserResponseDTO
with statusHttpStatus.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 benull
- Returns:
ResponseEntity
containing aPagedModel
ofUserResponseDTO
with statusHttpStatus.OK
-