import apiRequest from '@/network/http/apiRequest'

/**
 * 获取Job分页
 * @param data
 */
export function getJobByPage(data: any) {
  return apiRequest({
    url: '/job/page',
    method: 'GET',
    params: data,
  })
}

/**
 * 获取Job列表
 * @param data
 */
export function getJobByList(data: any) {
  return apiRequest({
    url: '/job',
    method: 'GET',
    params: data,
  })
}

/**
 * 获取Job列表
 * @param data
 */
export function getActiveJobByList(data: any) {
  return apiRequest({
    url: '/job/active',
    method: 'GET',
    params: data,
  })
}

/**
 * 根据Id获取Job
 * @param jobId
 */
export function getJobById(jobId: number) {
  return apiRequest({
    url: `/job/${jobId}`,
    method: 'GET',
  })
}

/**
 * 添加Job
 * @param data
 */
export function createJob(data: any) {
  return apiRequest({
    url: '/job/add',
    method: 'post',
    data,
  })
}

/**
 * 更新Job
 * @param data
 */
export function updateJob(data: any) {
  return apiRequest({
    url: '/job/update',
    method: 'PUT',
    data,
  })
}

/**
 * 启动Job
 * @param jobId
 */
export function startJob(jobId: number) {
  return apiRequest({
    url: `/job/start/${jobId}`,
    method: 'PUT',
  })
}

/**
 * 停止Job
 * @param jobId
 */
export function stopJob(jobId: number) {
  return apiRequest({
    url: `/job/stop/${jobId}`,
    method: 'PUT',
  })
}

/**
 * 删除Job
 * @param jobId
 */
export function deleteJobById(jobId: number) {
  return apiRequest({
    url: `/job/${jobId}`,
    method: 'DELETE',
  })
}
