import { AnnoTag } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 标注-标签管理
 */
// 获取命名标签列表
export const getTagTreeList = () => {
  return http.get<AnnoTag.ResTagTreeList[]>(PORT1 + `/tagLib/treeList`);
};

// 新增命名标签
export const addTag = (params: Partial<AnnoTag.TagItem>) => {
  return http.post(PORT1 + `/tagLib/tag/add`, params);
};

// 编辑命名标签
export const editTag = (params: { id: number; name: string }) => {
  return http.post(PORT1 + `/tagLib/tag/edit`, params);
};

// 删除命名标签
export const deleteTag = (params: { id: number }) => {
  return http.post(PORT1 + `/tagLib/tag/delete`, params);
};

// 导出命名标签
export const exportTag = () => {
  return http.get(PORT1 + `/tagLib/export`, {}, { responseType: "blob" });
};

// 导入命名标签
export const importTag = (params: FormData) => {
  return http.post(PORT1 + `/tagLib/import`, params, {
    headers: { "Content-Type": "multipart/form-data" },
    responseType: "blob"
  });
};

// 获取条文属性列表
export const getAttrTreeList = () => {
  return http.get<AnnoTag.ResTagTreeList[]>(PORT1 + `/attributeLib/treeList`);
};

// 新增条文属性
export const addAttr = (params: Partial<AnnoTag.TagItem>) => {
  return http.post(PORT1 + `/attributeLib/attributeLib/add`, params);
};

// 编辑条文属性
export const editAttr = (params: { id: number; name: string }) => {
  return http.post(PORT1 + `/attributeLib/attributeLib/edit`, params);
};

// 删除条文属性
export const deleteAttr = (params: { id: number }) => {
  return http.post(PORT1 + `/attributeLib/attributeLib/delete`, params);
};

// 导出条文属性
export const exporAttr = () => {
  return http.get(PORT1 + `/attributeLib/export`, {}, { responseType: "blob" });
};

// 导入条文属性
export const importAttr = (params: FormData) => {
  return http.post(PORT1 + `/attributeLib/import`, params, {
    headers: { "Content-Type": "multipart/form-data" },
    responseType: "blob"
  });
};
