Class AccountEventHandlerService

java.lang.Object
com.brodygaudel.bank.query.service.account.AccountEventHandlerService

@Service @Transactional public class AccountEventHandlerService extends Object
Service class for handling events related to accounts, such as creation, activation, suspension, crediting, and debiting.
  • Constructor Details

    • AccountEventHandlerService

      public AccountEventHandlerService(AccountRepository accountRepository, OperationRepository operationRepository, CustomerRepository customerRepository)
      Constructs an AccountEventHandlerService with the specified repositories.
      Parameters:
      accountRepository - The repository for managing account data.
      operationRepository - The repository for managing operation data.
      customerRepository - The repository for managing customer data.
  • Method Details

    • on

      @EventHandler public void on(@NotNull @NotNull AccountCreatedEvent event)
      Handles the AccountCreatedEvent by creating a new account and associating it with a customer.
      Parameters:
      event - The AccountCreatedEvent to handle.
    • on

      @EventHandler public void on(@NotNull @NotNull AccountActivatedEvent event)
      Handles the AccountActivatedEvent by updating the status of an existing account to activate.
      Parameters:
      event - The AccountActivatedEvent to handle.
    • on

      @EventHandler public void on(@NotNull @NotNull AccountSuspendedEvent event)
      Handles the AccountSuspendedEvent by updating the status of an existing account to suspended.
      Parameters:
      event - The AccountSuspendedEvent to handle.
    • on

      @EventHandler public void on(@NotNull @NotNull AccountCreditedEvent event)
      Handles the AccountCreditedEvent by updating the balance of an existing account and recording a credit operation.
      Parameters:
      event - The AccountCreditedEvent to handle.
    • on

      @EventHandler public void on(@NotNull @NotNull AccountDebitedEvent event)
      Handles the AccountDebitedEvent by updating the balance of an existing account, recording a debit operation, and checking for sufficient balance.
      Parameters:
      event - The AccountDebitedEvent to handle.