import request from '@/utils/request'

// 查询定时任务列表
export function listJob(query) {
  return request({
    url: '/task/list',
    method: 'get',
    params: query
  })
}

// 查询定时任务调度详细
export function getJob(jobId) {
  return request({
    url: '/monitor/job/' + jobId,
    method: 'get'
  })
}

// 添加定时任务
export function addJob(data) {
  return request({
    url: '/task/add',
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: data
  })
}

// 修改定时任务
export function updateJob(data) {
  return request({
    url: '/task/update',
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: data
  })
}

// 删除定时任务
export function delJob(jobId) {
  return request({
    url: `/task/remove/${jobId}`,
    method: 'delete'
  })
}

// 切换定时任务状态
export function changeJobStatus(query) {
  return request({
    url: '/task/changeStatus',
    method: 'get',
    params: query
  })
}


// 立即运行任务
export function runJob(query) {
  return request({
    url: '/task/run',
    method: 'get',
    params: query
  })
}