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.BpmOAEntryService;
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAEntryServiceImpl;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * OA 入职申请的结果的监听器实现类
 *
 * @author 符溶馨
 */
@Component
public class BpmOAEntryResultListener extends BpmProcessInstanceResultEventListener {

    @Resource
    private BpmOAEntryService entryService;

    @Override
    protected String getProcessDefinitionKey() {

        return BpmOAEntryServiceImpl.PROCESS_KEY;
    }

    @Override
    protected void onEvent(BpmProcessInstanceResultEvent event) {

        entryService.updateEntryResult(event.getId(), Long.parseLong(event.getBusinessKey()), event.getResult());
    }
}
