import request from '@/utils/request'

export async function getProcessDefinitionPage(query) {
  const res = await request({
    url: '/bpm/process-definition/page',
    method: 'get',
    params: query
  })
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function getProcessDefinitionList(query) {
  const res = await request({
    url: '/bpm/process-definition/list',
    method: 'get',
    params: query
  })
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function getProcessDefinitionBpmnXML(id) {
  const res = await request({
    url: '/bpm/process-definition/get-bpmn-xml?id=' + id,
    method: 'get'
  })
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
