package cn.iocoder.yudao.module.asset.service.returnorder.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.returnorder.ReturnOrderService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * 还车单审批状态监听器
 *
 * @author 芋道源码
 */
@Component
public class ReturnOrderBpmListener extends BpmProcessInstanceStatusEventListener {

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

    @Resource
    private ReturnOrderService returnOrderService;

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

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

}
