class BankAccountController {

	@PostMapping("/_create")
	@ResponseStatus(HttpStatus.CREATED)
	public BankAccountResponse create(@RequestBody BankAccountRequest bankAccountRequest, BindingResult errors,@RequestParam String tenantId) {
		if (errors.hasErrors()) {
			throw new CustomBindException(errors);
		}

		ModelMapper model = new ModelMapper();
		BankAccountResponse bankAccountResponse = new BankAccountResponse();
		bankAccountResponse.setResponseInfo(getResponseInfo(bankAccountRequest.getRequestInfo()));
		List<BankAccount> bankaccounts = new ArrayList<>();
		BankAccount bankAccount;
		List<BankAccountContract> bankAccountContracts = new ArrayList<>();
		BankAccountContract contract;

		bankAccountRequest.getRequestInfo().setAction(Constants.ACTION_CREATE);

		for (BankAccountContract bankAccountContract : bankAccountRequest.getBankAccounts()) {
			bankAccount = new BankAccount();
			model.map(bankAccountContract, bankAccount);
			bankAccount.setCreatedDate(new Date());
			bankAccount.setCreatedBy(bankAccountRequest.getRequestInfo().getUserInfo());
			bankAccount.setLastModifiedBy(bankAccountRequest.getRequestInfo().getUserInfo());
			bankaccounts.add(bankAccount);
		}

		bankaccounts = bankAccountService.create(bankaccounts, errors, bankAccountRequest.getRequestInfo());

		for (BankAccount f : bankaccounts) {
			contract = new BankAccountContract();
			contract.setCreatedDate(new Date());
			model.map(f, contract);
			bankAccountContracts.add(contract);
		}

		bankAccountResponse.setBankAccounts(bankAccountContracts);

		return bankAccountResponse;
	}

}