import request from '@/utils/request';

export function queryJobgroup(data) {
  return request({
    url: '/xxl-job/jobinfo/pageList',
    method: 'get',
    params: data
  });
}

export function playOneTime(data) {
  return request({
    url: '/xxl-job/jobinfo/trigger',
    method: 'post',
    data: data
  });
}

export function queryRegister(id) {
  const data = {
    id
  };
  return request({
    url: '/xxl-job/jobgroup/loadById',
    method: 'post',
    data: data
  });
}

export function queryNextTime(data) {
  return request({
    url: '/xxl-job/jobinfo/nextTriggerTime',
    method: 'post',
    data: data
  });
}

export function startData(id) {
  const data = {
    id
  };
  return request({
    url: '/xxl-job/jobinfo/start',
    method: 'post',
    data: data
  });
}

export function stopData(id) {
  const data = {
    id
  };
  return request({
    url: '/xxl-job/jobinfo/stop',
    method: 'post',
    data: data
  });
}

export function addXxlJobInfo(data) {
  return request({
    url: '/xxl-job/jobinfo/add',
    method: 'post',
    data: data
  });
}

export function updateXxlJobInfo(data) {
  return request({
    url: '/xxl-job/jobinfo/update',
    method: 'post',
    data: data
  });
}

export function deleteXxlJobInfo(id) {
  const data = {
    id
  };
  return request({
    url: '/xxl-job/jobinfo/remove',
    method: 'post',
    data: data
  });
}

/**
 * 获取执行管理器
 */
export function getJobgroup() {
  return request({
    url: '/xxl-job/jobinfo/queryJobgroup',
    method: 'post'
  });
}
