class RecoveryController {

    @PostMapping("/_update")
    @ResponseStatus(HttpStatus.CREATED)
    public RecoveryResponse update(@RequestBody RecoveryRequest recoveryRequest, BindingResult errors,@RequestParam String tenantId) {

        if (errors.hasErrors()) {
            throw new CustomBindException(errors);
        }
        recoveryRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE);

        ModelMapper model = new ModelMapper();
        RecoveryResponse recoveryResponse = new RecoveryResponse();
        recoveryResponse.setResponseInfo(getResponseInfo(recoveryRequest.getRequestInfo()));

        List<Recovery> recoverys = new ArrayList<>();
        Recovery recovery;
        List<RecoveryContract> recoveryContracts = new ArrayList<>();
        RecoveryContract contract;


        for (RecoveryContract recoveryContract : recoveryRequest.getRecoverys()) {
            recovery = new Recovery();
            model.map(recoveryContract, recovery);
            recoveryContract.setLastModifiedBy(recoveryRequest.getRequestInfo().getUserInfo());
            recoveryContract.setLastModifiedDate(new Date());
            recoverys.add(recovery);
        }

        recoverys = recoveryService.update(recoverys, errors, recoveryRequest.getRequestInfo());

        for (Recovery recoveryObj : recoverys) {
            contract = new RecoveryContract();
            model.map(recoveryObj, contract);
            recoveryObj.setLastModifiedDate(new Date());
            recoveryContracts.add(contract);
        }

        recoveryResponse.setRecoverys(recoveryContracts);

        return recoveryResponse;
    }

}