package cn.reghao.autodop.dmaster.monitor;

import cn.reghao.autodop.common.http.DefaultWebRequest;
import cn.reghao.autodop.dmaster.app.db.query.AppRunningQuery;
import cn.reghao.autodop.dmaster.machine.db.crud.MachineHostCrud;
import cn.reghao.autodop.dmaster.machine.db.query.MachineHostQuery;
import cn.reghao.autodop.dmaster.notification.service.NotifyService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobDataMap;
import org.springframework.stereotype.Service;

/**
 * 监控任务需要的数据
 *
 * @author reghao
 * @date 2021-07-06 09:25:50
 */
@Slf4j
@Service
public class MonitorJobData {
    private MachineHostQuery machineHostQuery;
    private MachineHostCrud machineHostCrud;
    private AppRunningQuery appRunningQuery;
    private NotifyService notifyService;

    public MonitorJobData(MachineHostQuery machineHostQuery, MachineHostCrud machineHostCrud,
                          AppRunningQuery appRunningQuery, NotifyService notifyService) {
        this.machineHostQuery = machineHostQuery;
        this.machineHostCrud = machineHostCrud;
        this.appRunningQuery = appRunningQuery;
        this.notifyService = notifyService;
    }

    public JobDataMap machineDataMap() {
        JobDataMap jobDataMap = new JobDataMap();
        jobDataMap.put("notifyService", notifyService);
        return jobDataMap;
    }

    public JobDataMap appDataMap() {
        JobDataMap jobDataMap = new JobDataMap();
        jobDataMap.put("notifyService", notifyService);
        jobDataMap.put("webRequest", new DefaultWebRequest());
        return jobDataMap;
    }
}
