class AccountCodePurposeController {

	@PostMapping("/_search")
	@ResponseBody
	@ResponseStatus(HttpStatus.OK)
	public AccountCodePurposeResponse search(
			@ModelAttribute AccountCodePurposeSearchContract accountCodePurposeSearchContract, @RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId) {

		ModelMapper mapper = new ModelMapper();
		AccountCodePurposeSearch domain = new AccountCodePurposeSearch();
		mapper.map(accountCodePurposeSearchContract, domain);
		AccountCodePurposeContract contract;
		ModelMapper model = new ModelMapper();
		List<AccountCodePurposeContract> accountCodePurposeContracts = new ArrayList<>();
		Pagination<AccountCodePurpose> accountcodepurposes = accountCodePurposeService.search(domain, errors);

		for (AccountCodePurpose accountCodePurpose : accountcodepurposes.getPagedData()) {
			contract = new AccountCodePurposeContract();
			model.map(accountCodePurpose, contract);
			accountCodePurposeContracts.add(contract);
		}

		AccountCodePurposeResponse response = new AccountCodePurposeResponse();
		response.setAccountCodePurposes(accountCodePurposeContracts);
		response.setPage(new PaginationContract(accountcodepurposes));
		response.setResponseInfo(getResponseInfo(requestInfo));

		return response;

	}

}