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
ConstructorDescriptionAccountEventHandlerService
(AccountRepository accountRepository, OperationRepository operationRepository, CustomerRepository customerRepository) Constructs anAccountEventHandlerService
with the specified repositories. -
Method Summary
Modifier and TypeMethodDescriptionvoid
on
(@NotNull AccountActivatedEvent event) Handles theAccountActivatedEvent
by updating the status of an existing account to activate.void
on
(@NotNull AccountCreatedEvent event) Handles theAccountCreatedEvent
by creating a new account and associating it with a customer.void
on
(@NotNull AccountCreditedEvent event) Handles theAccountCreditedEvent
by updating the balance of an existing account and recording a credit operation.void
on
(@NotNull AccountDebitedEvent event) Handles theAccountDebitedEvent
by updating the balance of an existing account, recording a debit operation, and checking for sufficient balance.void
on
(@NotNull AccountSuspendedEvent event) Handles theAccountSuspendedEvent
by updating the status of an existing account to suspended.
-
Constructor Details
-
AccountEventHandlerService
public AccountEventHandlerService(AccountRepository accountRepository, OperationRepository operationRepository, CustomerRepository customerRepository) Constructs anAccountEventHandlerService
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
Handles theAccountCreatedEvent
by creating a new account and associating it with a customer.- Parameters:
event
- TheAccountCreatedEvent
to handle.
-
on
Handles theAccountActivatedEvent
by updating the status of an existing account to activate.- Parameters:
event
- TheAccountActivatedEvent
to handle.
-
on
Handles theAccountSuspendedEvent
by updating the status of an existing account to suspended.- Parameters:
event
- TheAccountSuspendedEvent
to handle.
-
on
Handles theAccountCreditedEvent
by updating the balance of an existing account and recording a credit operation.- Parameters:
event
- TheAccountCreditedEvent
to handle.
-
on
Handles theAccountDebitedEvent
by updating the balance of an existing account, recording a debit operation, and checking for sufficient balance.- Parameters:
event
- TheAccountDebitedEvent
to handle.
-