import request from '@/utils/request'

export async function getActivityList(query) {

  const res= await request({
    url: '/bpm/activity/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 getProcessInstance(id) {

  const res= await request({
    url: '/bpm/process-instance/get?id=' + id,
    method: 'get',
  })

  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function getTaskListByProcessInstanceId(processInstanceId) {
  const res = await request({
    url:
      '/bpm/task/list-by-process-instance-id?processInstanceId=' +
      processInstanceId,
    method: 'get'
  });

  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));
}
