package com.yonge.cooleshow.task.service;

import java.util.List;
import java.util.Map;

import org.quartz.Scheduler;
import org.quartz.SchedulerException;

import com.yonge.cooleshow.task.core.TaskStatus;
import com.yonge.cooleshow.task.dal.model.Task;

public interface TaskService {

	/**
	 * 查询所有任务列表
	 * @return
	 */
	public List<Task> queryTasks();

	/**
	 * 分页查询
	 * @param params
	 * @return
	 */
	public List<Task> queryPage(Map<String, Object> params);

	/**
	 * 查询记录数
	 * @param params
	 * @return
	 */
	public int queryCount(Map<String, Object> params);

	/**
	 * 根据任务ID查询任务对象
	 * @param taskId
	 * @return
	 */
	public Task queryTask(Long taskId);

	/**
	 * 根据任务名称和任务组获取任务对象
	 * @param jobName
	 * @param groupName
	 * @return
	 */
	public Task queryTask(String jobName, String groupName);

	/**
	 * 更新指定任务id的状态
	 * @param taskId
	 * @param oldStatus
	 * @param curStatus
	 * @return
	 */
	public boolean updateTaskStatus(Long taskId, TaskStatus oldStatus, TaskStatus curStatus);

	/**
	 * 执行指定任务编号的任务
	 * @param taskId
	 * @param scheduler
	 * @return
	 * @throws SchedulerException
	 */
	public boolean execute(Long taskId, Scheduler scheduler) throws SchedulerException;

	/**
	 * 暂停任务
	 * @param taskId
	 * @param scheduler
	 * @return
	 * @throws SchedulerException
	 */
	public boolean pause(Long taskId, Scheduler scheduler) throws SchedulerException;

	/**
	 * 恢复任务
	 * @param taskId
	 * @param scheduler
	 * @return
	 * @throws SchedulerException
	 */
	public boolean resume(Long taskId, Scheduler scheduler) throws SchedulerException;
}
