package com.yanzhu.module.bpm.service.oa.listener;

import com.yanzhu.module.bpm.api.event.BpmProcessInstanceStatusEvent;
import com.yanzhu.module.bpm.api.event.BpmProcessInstanceStatusEventListener;
import com.yanzhu.module.bpm.service.oa.BpmOALeaveService;
import com.yanzhu.module.bpm.service.oa.BpmOALeaveServiceImpl;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * OA 请假单的结果的监听器实现类
 *
 * @author 研筑科技
 */
@Component
public class BpmOALeaveStatusListener extends BpmProcessInstanceStatusEventListener {

    @Resource
    private BpmOALeaveService leaveService;

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

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

}
