import { request } from "umi";
import { commonParams } from "./";
import { ProjectInfo } from "@/type";
import { TableType } from "@/enum";

/**
 * 查询数据模型列表
 * @param
 * @returns
 */
export const GetDataModelList = (data: {
  name?: string;
  folder?: string;
  type?: TableType;
}) => {
  return request("/api/erDiagram/dataModel/list", {
    method: "POST",
    data,
  });
};

/**
 * 保存更新数据模型
 * @param
 * @returns
 */
export const SaveDataModel = (data: any) => {
  return request("/api/erDiagram/dataModel/saveOrUpdate", {
    method: "POST",
    data,
  });
};

/**
 * 删除数据模型
 * @param
 * @returns
 */
export const DeleteDataModel = (data: { id: string }) => {
  return request("/api/erDiagram/dataModel/delete", {
    method: "POST",
    data,
  });
};

/**
 * 模型详情
 * @param id
 */
export const GetDataModelDetail = (data: { id: string }) => {
  return request("/api/erDiagram/dataModel/detail", {
    method: "POST",
    data,
  });
};

/**
 * 同步推送数据表
 * @param data
 */
export const PushDataModelTable = (data: any) => {
  return request("/api/erDiagram/dataModel/push", {
    method: "POST",
    data,
  });
}

/**
 * 批量添加AI创建结果
 * @param data 
 */
export const BatchAddAICreateResult = (data: any) => {
  return request("/api/erDiagram/dataModel/doBatchCreateDataModel", {
    method: "POST",
    data,
  });
}

/**
 * 查询可以引入的表列表
 * @param data 
 */
export const GetCanUseTableList = (data: any) => {
  return request("/api/erDiagram/dataModel/unlinkedBusinessTables", {
    method: "POST",
    data
  });
}

/**
 * 导入引入的表
 * @param data 
 */
export const ImportFromBusinessTables = (data: any) => {
  return request("/api/erDiagram/dataModel/importFromBusinessTables", {
    method: "POST",
    data
  });
}