package cn.iocoder.yudao.module.asset.service.contract.listener;

import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent;
import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEventListener;
import cn.iocoder.yudao.module.asset.service.contract.ContractService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * 车辆租赁合同审批状态监听器
 *
 * @author 芋道源码
 */
@Component
public class ContractBpmListener extends BpmProcessInstanceStatusEventListener {

    /**
     * 流程定义 Key
     */
    public static final String PROCESS_KEY = "asset_contract";

    @Resource
    private ContractService contractService;

    @Override
    protected String getProcessDefinitionKey() {
        return PROCESS_KEY;
    }

    @Override
    protected void onEvent(BpmProcessInstanceStatusEvent event) {
        contractService.updateContractApprovalStatus(Long.parseLong(event.getBusinessKey()), event.getStatus());
    }

}
