package com.malk.delegate.impl;

import com.malk.delegate.DDEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * OA审批事件 [主项目若无实现, 项目启动异常; 若子项目有订阅需添加 @Primary 以实现优先注入]
 * -
 * 取消方案: 撤销和拒绝流程不继续执行连接器, 因此不使用连接器与轮询审批记录方案 [低效而且占用较高钉钉api调次数];
 * 优化方案: 通过事件订阅实现实时同步所有审批状态, 定时查询钉钉回调失败记录 [配置钉钉事件Delegate, 添加定时任务]
 */
@Slf4j
@Service
public class DDImplEvent implements DDEvent {

    // 审批任务回调执行业务逻辑
    @Async
    @Override
    public void executeEvent_Task_Finish(String processInstanceId, String processCode, boolean isAgree, String remark) {
        log.info("executeEvent_Task_Finish: 未被代理");
    }

    @Async
    @Override
    public void executeEvent_Task_Start(String processInstanceId, String processCode) {
        log.info("executeEvent_Task_Start: 未被代理");
    }

    @Async
    @Override
    public void executeEvent_Task_Redirect(String processInstanceId, String processCode) {
        log.info("executeEvent_Task_Redirect: 未被代理");
    }

    @Async
    @Override
    public void executeEvent_Instance_Start(String processInstanceId, String processCode) {
        log.info("executeEvent_Instance_Start: 未被代理");
    }

    // 审批实例回调执行业务逻辑
    @Async
    @Override
    public void executeEvent_Instance_Finish(String processInstanceId, String processCode, boolean isAgree, boolean isTerminate, String staffId) {
        log.info("executeEvent_Instance_Finish: 未被代理");
    }

    // 考勤打卡事件回调
    @Override
    public void executeEvent_attendance_check(Map<String, ?> record) {
        log.info("executeEvent_attendance_check: 未被代理");
    }
}
