package com.younike.common.quartz.service;

import com.younike.common.quartz.entity.JobEntity;
import org.quartz.SchedulerException;


public interface JobService {

    /**
     * 新增并启动 一个定时任务
     * @param jobEntity
     * @throws Exception
     */
    void addJob(JobEntity jobEntity) throws Exception;

    /**
     * 删除 一个定时任务
     * @param jobEntity
     * @throws SchedulerException
     */
    void deleteJob(JobEntity jobEntity) throws SchedulerException;

    /**
     * 立即 执行一次定时任务
     * @param jobEntity
     * @throws Exception
     */
    void startOnce(JobEntity jobEntity) throws Exception;

    /**
     * 获取 定时任务状态
     * @param jobEntity
     * @return
     * @throws SchedulerException
     */
    String getJobState(JobEntity jobEntity) throws SchedulerException;

    /**
     * 停止 定时任务
     * @param jobEntity
     * @throws SchedulerException
     */
    void pauseJob(JobEntity jobEntity) throws SchedulerException;

    /**
     * 恢复 定时任务
     * @param jobEntity
     * @throws SchedulerException
     */
    void resumeJob(JobEntity jobEntity) throws SchedulerException;

    /**
     * 修改 定时任务的触发时间
     * @param jobEntity
     * @throws Exception
     */
    void cronJob(JobEntity jobEntity) throws Exception;

    /**
     * 保存 定时任务（判断定时任务是否存在，执行 新增或修改操作）
     * @param jobEntity
     * @throws Exception
     */
    void createJob(JobEntity jobEntity) throws Exception;

    /**
     *  创建可修改定时任务的共通
     * @param oldCron
     * @param newCron
     * @param message
     * @param className
     * @param groupName
     * @return
     * @throws Exception
     */
    JobEntity createJob(String oldCron, String newCron, String message, String className, String groupName) throws Exception;

}
