package com.ecep.contract.ds.contract.tasker;

import com.ecep.contract.MessageHolder;
import com.ecep.contract.cloud.u8.ctx.ContractCtx;
import com.ecep.contract.ds.contract.service.ContractService;
import com.ecep.contract.model.Contract;
import com.ecep.contract.ui.Tasker;

import lombok.Getter;
import lombok.Setter;

/**
 * 对合同的文件进行重置
 */
public class ContractFilesRebuildTasker extends Tasker<Object> {
    @Setter
    private ContractService contractService;

    @Setter
    private Contract contract;

    @Getter
    private boolean repaired = false;

    public ContractFilesRebuildTasker() {
        updateTitle("合同文件重置");
    }

    @Override
    protected Object execute(MessageHolder holder) {
        updateTitle("遍历合同的文件进行“重置”操作");

        ContractCtx contractCtx = new ContractCtx();
        if (contractCtx.syncContractFiles(contract, holder)) {
            repaired = true;
        }
        return null;
    }

    private ContractService getContractService() {
        if (contractService == null) {
            contractService = getBean(ContractService.class);
        }
        return contractService;
    }
}
