Class AddressesRepositoryImpl
java.lang.Object
com.fiap.tech_challenge.parte1.ms_users.repositories.AddressesRepositoryImpl
- All Implemented Interfaces:
AddressesRepository
Implementation of the AddressesRepository interface using JdbcClient to perform database operations.
This repository handles CRUD operations related to Address entities tied to users.
-
Constructor Summary
ConstructorsConstructorDescriptionAddressesRepositoryImpl(org.springframework.jdbc.core.simple.JdbcClient jdbcClient) Constructs an AddressesRepositoryImpl with the given JdbcClient. -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteByUserId(UUID userId) Deletes all addresses associated with the specified user ID.findAllByUserId(UUID userId) Retrieves all addresses associated with the specified user ID.findAllByUserIds(Set<UUID> userIdSet) Retrieves all addresses for a given set of user IDs.voidsave(@NotEmpty List<AddressRequestDTO> addresses, UUID generatedUserId) Saves a list of address DTOs for a given user ID.
-
Constructor Details
-
AddressesRepositoryImpl
public AddressesRepositoryImpl(org.springframework.jdbc.core.simple.JdbcClient jdbcClient) Constructs an AddressesRepositoryImpl with the given JdbcClient.- Parameters:
jdbcClient- the JdbcClient used to execute SQL queries
-
-
Method Details
-
findAllByUserId
Retrieves all addresses associated with the specified user ID.- Specified by:
findAllByUserIdin interfaceAddressesRepository- Parameters:
userId- the UUID of the user whose addresses will be retrieved- Returns:
- a list of Address entities related to the given userId
-
save
@Transactional(propagation=MANDATORY) public void save(@NotEmpty @NotEmpty List<AddressRequestDTO> addresses, UUID generatedUserId) Saves a list of address DTOs for a given user ID. This operation requires an existing transaction.- Specified by:
savein interfaceAddressesRepository- Parameters:
addresses- a non-empty list of AddressRequestDTOs to be savedgeneratedUserId- the UUID of the user to associate with these addresses
-
findAllByUserIds
Retrieves all addresses for a given set of user IDs. If the provided set is null or empty, returns an empty list.- Specified by:
findAllByUserIdsin interfaceAddressesRepository- Parameters:
userIdSet- a set of UUIDs representing user IDs- Returns:
- a list of Address entities related to the provided user IDs
-
deleteByUserId
Deletes all addresses associated with the specified user ID. This operation requires an existing transaction.- Specified by:
deleteByUserIdin interfaceAddressesRepository- Parameters:
userId- the UUID of the user whose addresses will be deleted
-