class FunctionController {

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

		ModelMapper mapper = new ModelMapper();
		FunctionSearch domain = new FunctionSearch();
		mapper.map(functionSearchContract, domain);
		FunctionContract contract;
		ModelMapper model = new ModelMapper();
		List<FunctionContract> functionContracts = new ArrayList<>();
		Pagination<Function> functions = functionService.search(domain, errors);

		for (Function function : functions.getPagedData()) {
			contract = new FunctionContract();
			model.map(function, contract);
			functionContracts.add(contract);
		}

		FunctionResponse response = new FunctionResponse();
		response.setFunctions(functionContracts);
		response.setPage(new PaginationContract(functions));
		response.setResponseInfo(getResponseInfo(requestInfo));

		return response;

	}

}