import { get, post, put, del, download } from "@/utils/request";

// 知识集列表
export function queryKnowledgeSetsUsingGet(params?: Record<string, unknown>) {
  return get("/api/data-management/knowledge-sets", params);
}

// 创建知识集
export function createKnowledgeSetUsingPost(data: Record<string, unknown>) {
  return post("/api/data-management/knowledge-sets", data);
}

// 获取知识集详情
export function queryKnowledgeSetByIdUsingGet(setId: string) {
  return get(`/api/data-management/knowledge-sets/${setId}`);
}

// 更新知识集
export function updateKnowledgeSetByIdUsingPut(setId: string, data: Record<string, unknown>) {
  return put(`/api/data-management/knowledge-sets/${setId}`, data);
}

// 删除知识集
export function deleteKnowledgeSetByIdUsingDelete(setId: string) {
  return del(`/api/data-management/knowledge-sets/${setId}`);
}

// 知识条目列表
export function queryKnowledgeItemsUsingGet(setId: string, params?: Record<string, unknown>) {
  return get(`/api/data-management/knowledge-sets/${setId}/items`, params);
}

// 创建知识条目
export function createKnowledgeItemUsingPost(setId: string, data: Record<string, unknown>) {
  return post(`/api/data-management/knowledge-sets/${setId}/items`, data);
}

// 导入知识条目（数据集文件）
export function importKnowledgeItemsUsingPost(setId: string, data: Record<string, unknown>) {
  return post(`/api/data-management/knowledge-sets/${setId}/items/import`, data);
}

// 获取知识条目详情
export function queryKnowledgeItemByIdUsingGet(setId: string, itemId: string) {
  return get(`/api/data-management/knowledge-sets/${setId}/items/${itemId}`);
}

// 更新知识条目
export function updateKnowledgeItemByIdUsingPut(setId: string, itemId: string, data: Record<string, unknown>) {
  return put(`/api/data-management/knowledge-sets/${setId}/items/${itemId}`, data);
}

// 替换知识条目文件
export function replaceKnowledgeItemFileUsingPut(setId: string, itemId: string, data: FormData) {
  return put(`/api/data-management/knowledge-sets/${setId}/items/${itemId}/file`, data);
}

// 删除知识条目
export function deleteKnowledgeItemByIdUsingDelete(setId: string, itemId: string) {
  return del(`/api/data-management/knowledge-sets/${setId}/items/${itemId}`);
}

// 上传知识条目文件
export function uploadKnowledgeItemsUsingPost(setId: string, data: FormData) {
  return post(`/api/data-management/knowledge-sets/${setId}/items/upload`, data);
}

// 下载知识条目文件
export function downloadKnowledgeItemFileUsingGet(setId: string, itemId: string, fileName?: string) {
  return download(`/api/data-management/knowledge-sets/${setId}/items/${itemId}/file`, null, fileName || "");
}

// 导出知识条目
export function exportKnowledgeItemsUsingGet(setId: string) {
  return download(`/api/data-management/knowledge-sets/${setId}/items/export`);
}
