class AccountEntityController {

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

        ModelMapper model = new ModelMapper();
        AccountEntityResponse accountEntityResponse = new AccountEntityResponse();
        accountEntityResponse.setResponseInfo(getResponseInfo(accountEntityRequest.getRequestInfo()));
        List<AccountEntity> accountentities = new ArrayList<>();
        AccountEntity accountEntity;
        List<AccountEntityContract> accountEntityContracts = new ArrayList<>();
        AccountEntityContract contract;

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

        for (AccountEntityContract accountEntityContract : accountEntityRequest.getAccountEntities()) {
            accountEntity = new AccountEntity();
            model.map(accountEntityContract, accountEntity);
            accountEntity.setCreatedDate(new Date());
            accountEntity.setCreatedBy(accountEntityRequest.getRequestInfo().getUserInfo());
            accountEntity.setLastModifiedBy(accountEntityRequest.getRequestInfo().getUserInfo());
            accountentities.add(accountEntity);
        }

        accountentities = accountEntityService.create(accountentities, errors, accountEntityRequest.getRequestInfo());

        for (AccountEntity f : accountentities) {
            contract = new AccountEntityContract();
            contract.setCreatedDate(new Date());
            model.map(f, contract);
            accountEntityContracts.add(contract);
        }

        accountEntityResponse.setAccountEntities(accountEntityContracts);

        return accountEntityResponse;
    }

}