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
ConstructorsConstructorDescriptionBankIdentityServiceImpl(BankIdentityRepository identityRepository, UserProfileRepository userProfileRepository, JwtService jwtService, BankAccountService accountService) Constructs a new instance ofBankIdentityServiceImpl. -
Method Summary
Modifier and TypeMethodDescriptionaddBank(jakarta.servlet.http.HttpServletRequest request) Adds a new bank identity for the user identified by the request.voiddeleteBank(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:
getBanksin 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:
getBankByNamein 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) throws Exception Adds a new bank identity for the user identified by the request.- Specified by:
addBankin interfaceBankIdentityService- Parameters:
request- the HTTP request containing user information- Returns:
- the created bank identity
- Throws:
Exception- if an error occurs during bank identity creationApplicationException- if the user is blocked or if a bank with the same name already exists
-
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:
deleteBankin 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
-