import { config, networkUtils } from '../../utils';

const { request } = networkUtils;
const { api } = config;
const { sys, bpm } = api;
const { definitions, deploy, taskRoles, notifies } = sys;
const { commit } = bpm;

export async function queryHistoric(params) {
  return request({
    url: definitions,
    method: 'get',
    data: params,
  });
}

export async function queryLatest(params) {
  return request({
    url: `${definitions}/latest`,
    method: 'get',
    data: params,
  });
}

export async function doDeploy(params) {
  return request({
    url: deploy,
    method: 'upload',
    data: params,
  });
}

export async function commitModel(params) {
  return request({
    url: commit,
    method: 'form',
    params,
  });
}

export async function taskRolesOf(params) {
  return request({
    url: taskRoles,
    method: 'get',
    data: params,
  });
}

export async function saveTaskRoles(params) {
  return request({
    url: taskRoles,
    method: 'post',
    data: params,
  });
}

export async function taskNotifiesOf(params) {
  return request({
    url: notifies,
    method: 'get',
    data: params,
  });
}

export async function saveTaskNotifies(params) {
  return request({
    url: notifies,
    method: 'post',
    data: params,
  });
}
