Package api.mpba.rastvdmy.service.impl
Class BankIdentityServiceImpl
java.lang.Object
api.mpba.rastvdmy.service.generator.FinancialDataGenerator
api.mpba.rastvdmy.service.impl.BankIdentityServiceImpl
- All Implemented Interfaces:
BankIdentityService
@Service
public class BankIdentityServiceImpl
extends FinancialDataGenerator
implements BankIdentityService
Service implementation for managing bank identities, including retrieval,
addition, and deletion of bank identities connected to a user's profile.
-
Constructor Summary
ConstructorDescriptionBankIdentityServiceImpl
(BankIdentityRepository identityRepository, UserProfileRepository userProfileRepository, JwtService jwtService, BankAccountService accountService) Constructs a new instance ofBankIdentityServiceImpl
. -
Method Summary
Modifier and TypeMethodDescriptionaddBank
(jakarta.servlet.http.HttpServletRequest request, BankIdentityRequest identityRequest) Adds a new bank identity for the user.void
deleteBank
(jakarta.servlet.http.HttpServletRequest request, String bankName) Deletes a bank identity associated with the user.getBankByName
(jakarta.servlet.http.HttpServletRequest request, String name) Retrieves a specific bank identity by name for the user identified by the request.getBanks
(jakarta.servlet.http.HttpServletRequest request) Retrieves a list of bank identities associated with the user identified by the request.Methods inherited from class api.mpba.rastvdmy.service.generator.FinancialDataGenerator
generateAccountNumber, generateBankNumber, generateCardNumber, generateCvv, generateIban, generatePin, generateSwift, getRandomExpirationDate, getRandomStartDate
-
Constructor Details
-
BankIdentityServiceImpl
@Autowired public BankIdentityServiceImpl(BankIdentityRepository identityRepository, UserProfileRepository userProfileRepository, JwtService jwtService, BankAccountService accountService) Constructs a new instance ofBankIdentityServiceImpl
.- Parameters:
identityRepository
- the repository for bank identity operationsuserProfileRepository
- the repository for user profile operationsjwtService
- the service for handling JWT operationsaccountService
- the service for managing bank accounts
-
-
Method Details
-
getBanks
@Cacheable("bankIdentity") public List<BankIdentity> getBanks(jakarta.servlet.http.HttpServletRequest request) Retrieves a list of bank identities associated with the user identified by the request.- Specified by:
getBanks
in interfaceBankIdentityService
- Parameters:
request
- the HTTP request containing user information- Returns:
- a list of bank identities
- Throws:
ApplicationException
- if the user is blocked or if no bank identities are found
-
getBankByName
@Cacheable(value="bankIdentity", key="#request.userPrincipal.name + \'-\' + #name") public BankIdentity getBankByName(jakarta.servlet.http.HttpServletRequest request, String name) Retrieves a specific bank identity by name for the user identified by the request.- Specified by:
getBankByName
in interfaceBankIdentityService
- Parameters:
request
- the HTTP request containing user informationname
- the name of the bank- Returns:
- the bank identity
- Throws:
ApplicationException
- if the user is blocked or if the bank identity is not found
-
addBank
@Transactional public BankIdentity addBank(jakarta.servlet.http.HttpServletRequest request, BankIdentityRequest identityRequest) throws Exception Adds a new bank identity for the user.- Specified by:
addBank
in interfaceBankIdentityService
- Parameters:
request
- the HTTP request containing user informationidentityRequest
- the bank identity request containing necessary information- Returns:
- the created bank identity
- Throws:
Exception
- if the user is blocked, if the bank name is empty, or if an error occurs during account connection
-
deleteBank
@CacheEvict(value="bankIdentity", key="#request.userPrincipal.name + \'-\' + #bankName") public void deleteBank(jakarta.servlet.http.HttpServletRequest request, String bankName) Deletes a bank identity associated with the user.- Specified by:
deleteBank
in interfaceBankIdentityService
- Parameters:
request
- the HTTP request containing user informationbankName
- the name of the bank to delete- Throws:
ApplicationException
- if the user is blocked, if the bank identity is not found, or if there are connected bank accounts
-