Class AddressesRepositoryImpl

java.lang.Object
com.fiap.tech_challenge.parte1.ms_users.repositories.AddressesRepositoryImpl
All Implemented Interfaces:
AddressesRepository

@Repository public class AddressesRepositoryImpl extends Object implements 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 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

      public List<Address> findAllByUserId(UUID userId)
      Retrieves all addresses associated with the specified user ID.
      Specified by:
      findAllByUserId in interface AddressesRepository
      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:
      save in interface AddressesRepository
      Parameters:
      addresses - a non-empty list of AddressRequestDTOs to be saved
      generatedUserId - the UUID of the user to associate with these addresses
    • findAllByUserIds

      public List<Address> findAllByUserIds(Set<UUID> userIdSet)
      Retrieves all addresses for a given set of user IDs. If the provided set is null or empty, returns an empty list.
      Specified by:
      findAllByUserIds in interface AddressesRepository
      Parameters:
      userIdSet - a set of UUIDs representing user IDs
      Returns:
      a list of Address entities related to the provided user IDs
    • deleteByUserId

      @Transactional(propagation=MANDATORY) public void deleteByUserId(UUID userId)
      Deletes all addresses associated with the specified user ID. This operation requires an existing transaction.
      Specified by:
      deleteByUserId in interface AddressesRepository
      Parameters:
      userId - the UUID of the user whose addresses will be deleted