Class AccountEventHandlerService
java.lang.Object
com.brodygaudel.bank.query.service.account.AccountEventHandlerService
Service class for handling events related to accounts, such as creation, activation, suspension,
crediting, and debiting.
-
Constructor Summary
ConstructorsConstructorDescriptionAccountEventHandlerService(AccountRepository accountRepository, OperationRepository operationRepository, CustomerRepository customerRepository) Constructs anAccountEventHandlerServicewith the specified repositories. -
Method Summary
Modifier and TypeMethodDescriptionvoidon(@NotNull AccountActivatedEvent event) Handles theAccountActivatedEventby updating the status of an existing account to activate.voidon(@NotNull AccountCreatedEvent event) Handles theAccountCreatedEventby creating a new account and associating it with a customer.voidon(@NotNull AccountCreditedEvent event) Handles theAccountCreditedEventby updating the balance of an existing account and recording a credit operation.voidon(@NotNull AccountDebitedEvent event) Handles theAccountDebitedEventby updating the balance of an existing account, recording a debit operation, and checking for sufficient balance.voidon(@NotNull AccountSuspendedEvent event) Handles theAccountSuspendedEventby updating the status of an existing account to suspended.
-
Constructor Details
-
AccountEventHandlerService
public AccountEventHandlerService(AccountRepository accountRepository, OperationRepository operationRepository, CustomerRepository customerRepository) Constructs anAccountEventHandlerServicewith 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
Handles theAccountCreatedEventby creating a new account and associating it with a customer.- Parameters:
event- TheAccountCreatedEventto handle.
-
on
Handles theAccountActivatedEventby updating the status of an existing account to activate.- Parameters:
event- TheAccountActivatedEventto handle.
-
on
Handles theAccountSuspendedEventby updating the status of an existing account to suspended.- Parameters:
event- TheAccountSuspendedEventto handle.
-
on
Handles theAccountCreditedEventby updating the balance of an existing account and recording a credit operation.- Parameters:
event- TheAccountCreditedEventto handle.
-
on
Handles theAccountDebitedEventby updating the balance of an existing account, recording a debit operation, and checking for sufficient balance.- Parameters:
event- TheAccountDebitedEventto handle.
-