import { request } from "umi";
import { LineType } from "@/enum";

export type LinkType = {
  id: string;
  startNodeId: string;
  endNodeId: string;
  wfdWorkflowId: string;
  lineType: LineType;
  m: number;
};

export type PointType = {
  x: number;
  y: number;
  order: number;
  wfdWorkflowLinkId: string;
  wfdWorkflowId: string;
};

export type LinkItemType = {
  workflowId: string;
  link: LinkType;
  points: PointType[];
};


/**
 * 新增/编辑连线
 * @param data
 * @returns
 */
export const SaveLink = (data: LinkItemType) => {
  return request("/api/workflow/SaveLink", {
    method: "POST",
    data,
  });
};

/**
 * 获取连线详情
 * @param data
 * @returns
 */
export const GetLink = (data: {id: string;}) => {
  return request("/api/workflow/GetLink", {
    method: "POST",
    data,
  });
};

/**
 * 保存连线数据
 * @param data
 * @returns
 */
export const SaveSingleLink = (data: any) => {
  return request("/api/workflow/SaveSingleLink", {
    method: "POST",
    data,
  });
};

/**
 * 删除连线
 * @param data { id: string; }
 * @returns
 */
export const DeleteLink = (data: {id: string}) => {
  return request("/api/workflow/DeleteLink", {
    method: "POST",
    data,
  });
};

