
import http from '@/utils/request'
// import axios from 'axios'

// 元数据相关
const metadata = {
  // 新增元数据
  metadataAdd (params) {
    return http.post('/meta/node/add', params)
  },
  // 更新元数据
  metadataUpdate (params) {
    return http.post('/meta/node/update', params)
  },
  // 删除元数据
  deleteMetadata: (param) => {
    return http.post('/meta/node/delete', param)
  },
  // 查看元数据详情
  getMetadataDetails: (param) => {
    return http.post('/meta/node/edit', param)
  },
  // 元数据列表
  getMetaDataList: (param) => {
    return http.post('/meta/node/list', param)
  },
  // 元数据图谱
  getMetaDataGraph: (param) => {
    return http.post('/meta/node/graph', param)
  }
}

// 数据资源
const dataResource = {
  // 资源列表
  getResourceList: (param) => {
    return http.post('/resource/list', param)
  },
  // 资源详情
  getResourceDetails: (param) => {
    return http.post('/resource/detail', param)
  },
  // 查看资源图谱   没接
  getResourceListToGraph: (param) => {
    return http.post('/resource/list/graph', param)
  },
  // 删除资源
  deleteSource: (param) => {
    return http.post('/resource/delete', param)
  },
  // 大模型模型翻译元数据  上传接口参数不对
  resourceTranslate: (param) => {
    return http.formData('/resource/translate', param)
  },
  // 保存数据资源
  saveResource: (param) => {
    return http.post('/resource/save', param)
  },
  // 数据资源上传  未知
  uploadResource: (param) => {
    return http.upload('/meta/resource/upload', param)
  },
  // 获取数据资源文件流
  getResourceFile: (param) => {
    return http.getDownload('/meta/resource/download', param)
  },
  // 解析非结构化文本展示信息
  getUnstructured: (param) => {
    return http.post('/text/resource/translate', param)
  },
  // 查看资源图谱
  getResourceGraph: (param) => {
    return http.post('/resource/graph/all', param)
  },
  // 解析一个文件中多份DDL 文件上传接口 参数错误 预留接口
  resourceParseByDDL: (param) => {
    return http.upload('/resource/ddl/identify', param)
  },
  resourceParseDDL: (param) => {
    return http.upload('/resource/ddl/parse', param)
  },
  // DDL数据资源更新 未确认
  resourceUpdateByDDL: (param) => {
    return http.post('/resource/update', param)
  },
  // 通过资源id查找元数据
  getMetaDataById: (param) => {
    return http.post('/resource/search', param)
    // return http.post('/id/data/search', param)
  },
  // 数据资源生产线调度 结构化 手动执行
  productionLineDispatch: (param) => {
    return http.post('/pipeline/production/line/execute', param)
  }
}

// 数据模型
const dataModel = {
  // 模型列表
  getModelList: (param) => {
    return http.post('/model/data/model/list', param)
  },
  // 查看模型详情
  getModelDetails: (param) => {
    return http.post('/model/data/model/detail', param)
  },
  // 查看模型图谱
  getModelListToGraph: (param) => {
    return http.post('/model/data/model/graph/all', param)
  },
  // 新增模型 -> 通过资源新增模型
  addModel: (param) => {
    // return http.post('/model/model/data/model/add', param)
    return http.post('/model/data/search', param)
  },
  // 删除模型
  deleteModel: (param) => {
    return http.post('/model/data/model/delete', param)
  },
  // 通过资源id查找元数据
  getMetaDataByModelId: (param) => {
    return http.post('/model/search', param)
    // return http.post('/id/data/search', param)
  },
  // 新增模型：模型选择模型
  addModelByModel: (param) => {
    return http.post('/model/data/model/add', param)
  },
  // 查看模型图谱
  getModelGraph: (param) => {
    return http.post('/model/data/model/graph/all', param)
  },
  // 更新模型
  updateModel: (param) => {
    return http.post('/model/data/model/update', param)
  },
  // 通过ddl保存模型
  saveModelByDDL: (param) => {
    return http.post('/model/data/model/save', param)
  },
  // 通过ddl保存模型
  savePythonCode: (param) => {
    return http.post('/model/data/model/python', param)
  }
}

// 数据标签
const dataLabel = {
  // 列表
  dataLabelList: (param) => {
    return http.post('/interface/data/label/list', param)
  },
  // 新增
  dataLabelAdd: (param) => {
    return http.post('/interface/data/label/add', param)
  },
  // 详情
  dataLabelDetails: (param) => {
    return http.post('/interface/data/label/detail', param)
  },
  // 标签图谱
  dataLabelGraph: (param) => {
    return http.post('/interface/data/label/graph/all', param)
  },
  // 数据标签动态识别分组
  dataLabelIdentifyGroup: (param) => {
    return http.post('/interface/data/label/dynamic/identify', param)
  },
  // 删除数据标签
  deleteDataLabel: (param) => {
    return http.post('/interface/data/label/delete', param)
  }
}

// 数据标准
const dataStandard = {
  // 标准列表
  dataStandardList: (param) => {
    return http.post('/interface/data/standard/list', param)
  },
  // 新增
  dataStandardAdd: (param) => {
    return http.post('/interface/data/standard/add', param)
  },
  // 详情
  dataStandardDetails: (param) => {
    return http.post('/interface/data/standard/detail', param)
  },
  // 生成操作代码
  dataStandardCodeGenerate: (param) => {
    return http.post('/interface/data/standard/code', param)
  },
  // 标签图谱
  dataStandardGraph: (param) => {
    return http.post('/interface/data/standard/graph/all', param)
  }
}

// 数据指标
const dataIndicator = {
  // 指标列表
  dataIndicatorList: (param) => {
    return http.post('/metric/list', param)
  },
  // 指标列表切换图谱
  dataIndicatorListToGraph: (param) => {
    return http.post('/metric/list/graph', param)
  },
  // 新增指标
  dataIndicatorAdd: (param) => {
    return http.post('/metric/add', param)
  },
  // 新增更新
  dataIndicatorUpdate: (param) => {
    return http.post('/metric/update', param)
  },
  // 指标详情
  dataIndicatorDetails: (param) => {
    return http.post('/metric/detail', param)
  },
  // 指标血缘关系检测
  dataIndicatorRelation: (param) => {
    return http.post('/metric/relation', param)
  },
  // 指标生成代码
  dataIndicatorCodeGenerate: (param) => {
    return http.post('/metric/code', param)
  },
  // 指标图谱
  dataIndicatorGraph: (param) => {
    return http.post('/metric/graph/all', param)
  },
  // 删除指标
  deleteDataIndicator: (param) => {
    return http.post('/metric/delete', param)
  },
  // 指标规则效验
  dataIndicatorRuleValidate: (param) => {
    return http.post('/metric/check', param)
  }
}

const dataFlow = {
  // 获取数据流列表
  getDataFlowList: (param) => {
    return http.get('/dataflow/get-dataflows-list', param)
  },
  // 获取数据流详情
  getDataFlowDetails: (id) => {
    return http.get(`/dataflow/get-dataflow/${id}`)
  },
  // 新增数据流
  addDataFlow: (param) => {
    return http.post('/dataflow/add-dataflow', param)
  },
  // 更新数据流
  updateDataFlow: (id, param) => {
    return http.put(`/dataflow/update-dataflow/${id}`, param)
  },
  // 删除数据流
  deleteDataFlow: (id) => {
    return http.del(`/dataflow/delete-dataflow/${id}`)
  },
  // 运行数据流
  runDataFlow: (id, param) => {
    return http.post(`/dataflow/execute-dataflow/${id}`, param)
  },
  // 数据流运行进度
  getDataFlowExecute: (id) => {
    return http.get(`/dataflow/get-dataflow-status/${id}`)
  },
  // 数据流运行日志
  getDataFlowLog: (id) => {
    return http.get(`/dataflow/get-dataflow-logs/${id}`)
  },
  // AI生成脚本
  getDataFlowScript: (param) => {
    return http.post('/dataflow/create-script', param)
  },
  // 获取数据流脚本内容
  getDataFlowScriptContent: (dataflowId) => {
    return http.get(`/dataflow/get-script/${dataflowId}`)
  }
}

const LLM = {

  // 模型训练
  setDDLTrain: (param) => {
    return http.post('/vanna/api/v0/train', param)
  },
  // 图表sql信息
  getSql: (param) => {
    return http.get('/vanna/api/v0/generate_sql', param)
  },
  // 图表sql信息
  getToTable: (param) => {
    return http.get('/vanna/api/v0/run_sql', param)
  },
  // 知识库+图谱问答
  ask: (param) => {
    return http.post('/rag/ask', param)
  },
  // 产品知识库问答 RAG
  askToProduct: (param) => {
    return http.post('/rag/ask/rag', param)
  },
  // 非结构化知识库问答 RAG + Graph
  askToUnstructured: (param) => {
    return http.post('/rag/ask/unstructure/rag', param)
  }
}

// 业务域
const businessDomain = {
  // 获取业务域列表
  getBusinessDomainList: (param) => {
    return http.post('/bd/list', param)
  },
  // 获取业务域详情
  getBusinessDomainDetail: (param) => {
    return http.post('/bd/detail', param)
  },
  // 删除业务域
  deleteBusinessDomain: (param) => {
    return http.post('/bd/delete', param)
  },
  // 保存业务域
  saveBusinessDomain: (param) => {
    return http.post('/bd/save', param)
  },
  // 更新业务域
  updateBusinessDomain: (param) => {
    return http.post('/bd/update', param)
  },
  // 上传文件
  uploadFile: (param) => {
    return http.upload('/bd/upload', param)
  },
  // 下载文件
  downloadFile: (param) => {
    return http.getDownload('/bd/download', param)
  },
  // 获取关系图谱
  getBusinessDomainGraph: (param) => {
    return http.post('/bd/graphall', param)
  },
  // 解析DDL文件
  parseDDLFile: (param) => {
    return http.upload('/bd/ddlparse', param)
  },
  // 搜索关联元数据
  searchAssociatedMetadata: (param) => {
    return http.post('/bd/search', param)
  },
  // 组合创建业务领域
  combinationCreateBusinessDomain: (param) => {
    return http.post('/bd/compose', param)
  }
}

const other = {
// 资源 & 模型 列表
  getResourceAndModelList: (param) => {
    return http.post('/resource/model/list', param)
  },
  // 获取资源ddl
  getDDL: (param) => {
    return http.post('/id/data/ddl', param)
  },

  // 生产线执行非结构化文档 实体 关系
  runUnstructured: (param) => {
    return http.post('/text/resource/node', param)
  },
  // 生产线执行非结构化文档 元数据内容
  runUnstructuredMetadata: (param) => {
    return http.post('/processing/unstructured/data', param)
  },
  // 产品知识库列表
  productKnowledgeBaseList: (param) => {
    return http.post('/text/product/list', param)
  },
  // 直接删除图谱元素
  graphDataDelete: (param) => {
    return http.post('/metric/label/standard/delete', param)
  },
  // 直接删除图谱元素
  getGraphMetadataById: (param) => {
    return http.post('/graph/meta/include', param)
  },
  // 获取业务域列表
  getBusinessDomainList2: () => {
    return http.get('/dataflow/get-BD-list')
  },
  // 获取标签列表
  getLabelList: (param) => {
    return http.post('/interface/labellist', param)
  },
  // 元数据、业务域关系图谱
  getGraphAll: (param) => {
    return http.post('/interface/graphall', param)
  }
}

// 整合api
export const api = {
  // 元数据
  ...metadata,
  // 数据资源
  ...dataResource,
  // 数据模型
  ...dataModel,

  // 数据标签
  ...dataLabel,

  // 数据标准
  ...dataStandard,

  // 数据指标
  ...dataIndicator,

  // 数据流程
  ...dataFlow,

  // 业务域
  ...businessDomain,

  // 大语言模型对话接口
  ...LLM,

  ...other

}
