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:
ResponseEntitycontaining theUserResponseDTOwith 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- theUserRequestDTOcontaining the user's details; must not benull- Returns:
ResponseEntitycontaining the createdUserResponseDTOwith statusHttpStatus.CREATED- Throws:
BadRequestException- if therequestisnullor 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- theUserRequestDTOcontaining the updated user's details; must not benullid- the unique identifier of the user to update; must not benull- Returns:
ResponseEntitycontaining the updatedUserResponseDTOwith statusHttpStatus.OK- Throws:
NotFoundException- if no user is found with the givenidBadRequestException- if therequestisnullor 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:
ResponseEntitywith statusHttpStatus.NO_CONTENT- Throws:
NotFoundException- if no user is found with the givenid
-
findAll
Retrieves all users.- Returns:
ResponseEntitycontaining a list ofUserResponseDTOwith 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:
ResponseEntitycontaining aPagedModelofUserResponseDTOwith statusHttpStatus.OK
-