package com.docus.server.jobadmin.config;

import com.docus.server.archivesqlserver.mapper.ArchiveMasterMapper;
import com.docus.server.jobadmin.scheduler.JobScheduler;
import com.docus.server.rpc.V2ViewTaskCollectService;
import com.docus.server.zjfsjhemr.mapper.ZjFsPatIndexViewMapper;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * job执行需要的一些必须得service，dao，mapper和配置等管理，从这里获取，保证依赖都有注入
 *
 * @author YongBin Wen
 * @date 2024/1/23 14:13
 */
@Component
public class JobAdminConfig implements InitializingBean, DisposableBean {

    private static JobAdminConfig jobAdminConfig = null;

    public static JobAdminConfig getJobAdminConfig() {
        return jobAdminConfig;
    }

    // ---------------------- JobScheduler ----------------------

    private JobScheduler xxlJobScheduler;

    @Override
    public void afterPropertiesSet() throws Exception {
        jobAdminConfig = this;

        xxlJobScheduler = new JobScheduler();
        xxlJobScheduler.init();
    }

    @Override
    public void destroy() throws Exception {
        xxlJobScheduler.destroy();
    }

    // dao  service

    @Resource
    private ZjFsPatIndexViewMapper zjFsPatIndexViewMapper;

    @Resource
    private ArchiveMasterMapper archiveMasterMapper;

    @Resource
    private V2ViewTaskCollectService v2ViewTaskCollectService;

    public ZjFsPatIndexViewMapper getZjFsPatIndexViewMapper() {
        return zjFsPatIndexViewMapper;
    }

    public ArchiveMasterMapper getArchiveMasterMapper() {
        return archiveMasterMapper;
    }

    public V2ViewTaskCollectService getV2ViewTaskCollectService() {
        return v2ViewTaskCollectService;
    }
}
