import axios from 'axios';
import { publishType, appFlowModel, flowType, queryParams, apiResData } from '@/api/interface/index';

// 公共路径
const urlPrefix = '/api/v1/bpms-workbench';

// 发布流程
export function appPublish(data: publishType) {
  return axios.post(`${urlPrefix}/flow/appPublish`, data);
}

// 引用已发布流程到子流程
export function copyPublish(data: appFlowModel) {
  return axios.post(`${urlPrefix}/flow/copyPublish`, data);
}

// 获取已经发布的流程
export function getIsPublish() {
  return axios.get(`${urlPrefix}/flow/getIsPublish`);
}

// 分页获取已经发布的 复合/公共流程
export function getPublishPage() {
  return axios.post(`${urlPrefix}/flow/getPublishPage`);
}

// 分页获取已经发布的 我的流程
export function getMineSubs(data: flowType) {
  return axios.post(`${urlPrefix}/flow/getMineSubs`, data);
}

// 流程库个人分页
export function getMyFlowList(data: queryParams) {
  return axios.post<apiResData>(`${urlPrefix}/flow/minePage`, data);
}

// 流程库公共分页
export function getPubFlowList(data: queryParams) {
  return axios.post<apiResData>(`${urlPrefix}/flow/publicList`, data);
}

// 删除流程库
export function deleteFlow(id: string) {
  return axios.delete(`${urlPrefix}/flow/${id}`);
}
