import { http } from '@/utils/http/axios';

/**
 * @description: 定时任务列表
 */
export function getJobList(params?) {
  return http.request({
    url: '/job/page',
    method: 'GET',
    params,
  });
}

/**
 * 获取全部定时任务列表
 * @param params 参数
 * @returns 返回结果
 */
export function getJobAllList(params?) {
  return http.request({
    url: '/job/list',
    method: 'GET',
    params,
  });
}

/**
 * @description: 根据ID获取详情
 */
export function getJobDetail(id) {
  return http.request({
    url: '/job/detail/' + id,
    method: 'get',
  });
}

/**
 * @description: 添加定时任务
 */
export function jobAdd(data: any) {
  return http.request({
    url: '/job/add',
    method: 'POST',
    data,
  });
}

/**
 * @description: 更新定时任务
 */
export function jobUpdate(data: any) {
  return http.request({
    url: '/job/update',
    method: 'PUT',
    data,
  });
}

/**
 * @description: 删除定时任务
 */
export function jobDelete(id) {
  return http.request({
    url: '/job/delete/' + id,
    method: 'DELETE',
  });
}

/**
 * @description: 批量删除定时任务
 */
export function jobBatchDelete(data: any) {
  return http.request({
    url: '/job/batchDelete',
    method: 'DELETE',
    data,
  });
}

/**
 * @description: 执行一次
 */
export function getJobRunOnce(id) {
  return http.request({
    url: '/job/runOnce/' + id,
    method: 'get',
  });
}

/**
 * @description: 设置状态
 */
export function setJobStatus(data: any) {
  return http.request({
    url: '/job/status',
    method: 'post',
    data,
  });
}

/**
 * @description: 暂停任务
 */
export function getJobPause(id) {
  return http.request({
    url: '/job/pause/' + id,
    method: 'get',
  });
}

/**
 * @description: 恢复任务
 */
export function getJobResume(id) {
  return http.request({
    url: '/job/resume/' + id,
    method: 'get',
  });
}

/**
 * @description: 定时任务日志列表
 */
export function getJobLogList(params?) {
  return http.request({
    url: '/job/log/page',
    method: 'GET',
    params,
  });
}

/**
 * @description: 根据ID获取详情
 */
export function getJobLogDetail(id) {
  return http.request({
    url: '/job/log/detail/' + id,
    method: 'get',
  });
}

/**
 * @description: 删除定时任务日志
 */
export function jobLogDelete(id) {
  return http.request({
    url: '/job/log/delete/' + id,
    method: 'DELETE',
  });
}

/**
 * @description: 批量删除定时任务日志
 */
export function jobLogBatchDelete(data: any) {
  return http.request({
    url: '/job/log/batchDelete',
    method: 'DELETE',
    data,
  });
}
