import { ResPage, AnnoLexicon } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 标注-语表库管理
 */
// 获取标注词列表
export const getTandardWordList = (params: AnnoLexicon.ReqStandardParams) => {
  return http.get<ResPage<AnnoLexicon.ResStandardList>>(PORT1 + `/standardWordLib/lib/list`, params);
};

// 获取标注词详情
export const getTandardWordDetail = (params: { id: number }) => {
  return http.get<AnnoLexicon.ResStandardDetail[]>(PORT1 + `/standardWordLib/lib/detail/${params.id}`, params);
};

// 标准词新增
export const addTandardWord = (params: { parentStandardWordId?: number; standardWordName: string }) => {
  return http.post(PORT1 + `/standardWordLib/word/add`, params);
};

// 标准词编辑
export const editTandardWord = (params: { standardWordId: number; standardWordName: string }) => {
  return http.post(PORT1 + `/standardWordLib/update`, params);
};

// 标准词删除
export const deleteTandardWord = (params: { id: number }) => {
  return http.post(PORT1 + `/standardWordLib/del`, params);
};

// 标准词启用
export const enabledTandardWord = (params: { id: number }) => {
  return http.post(PORT1 + `/standardWordLib/lib/on`, params);
};

// 标准词禁用
export const disabledTandardWord = (params: { id: number }) => {
  return http.post(PORT1 + `/standardWordLib/lib/off`, params);
};

// 获取同义词列表
export const getSynonymWordList = (params: { id: number }) => {
  return http.get<AnnoLexicon.ResSynonymList[]>(PORT1 + `/synonymWord/list/${params.id}`, params);
};

// 编辑同义词
export const editSynonymWord = (params: { synonymWordId: number; synonymWordName: string }) => {
  return http.post(PORT1 + `/synonymWord/update`, params);
};

// 删除同义词
export const deleteSynonymWord = (params: { id: number }) => {
  return http.post(PORT1 + `/synonymWord/del`, params);
};

// 导出
export const exportLexicon = (params: { ids: string[] }) => {
  return http.download(PORT1 + `/standardWordLib/excel/export`, params);
};

// 导入
export const importLexicon = (params: FormData) => {
  return http.post(PORT1 + `/standardWordLib/excel/import `, params, {
    headers: { "Content-Type": "multipart/form-data" },
    responseType: "blob"
  });
};
