package cn.iocoder.yudao.module.bpm.service.oa.listener;

import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEvent;
import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventListener;
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAWorkTaskService;
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAWorkTaskServiceImpl;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * OA 分配工作 的结果的监听器实现类
 *
 * @author 姚君
 */
@Component
public class BpmOAWorkTaskResultListener extends BpmProcessInstanceResultEventListener {

    @Resource
    private BpmOAWorkTaskService workTaskService;

    @Override
    protected String getProcessDefinitionKey() {

        return BpmOAWorkTaskServiceImpl.PROCESS_KEY;
    }

    @Override
    protected void onEvent(BpmProcessInstanceResultEvent event) {
        workTaskService.updateWorkTaskResult(Long.parseLong(event.getBusinessKey()), event.getResult());
    }
}
