import { request } from "@umijs/max";

export interface SampleVo {
  /**
   * 创建时间
   */
  createTime?: string[];
  /**
   * 页码，从 1 开始", example = "1
   */
  remark?: string;
  /**
   * 样本文件id
   */
  sampleFileId?: number;
  /**
   * 样本格式
   */
  sampleMineType?: string;
  /**
   * 样本名称
   */
  sampleName?: string;
  /**
   * 样本大小
   */
  sampleSize?: string;
  /**
   * 样本时长
   */
  sampleTime?: string[];
}

/**
 * 返回数据
 *
 * PageResultAiSampleRespVO
 */
export interface PageResultAiSampleRespVO {
  /**
   * 数据
   */
  list?: AiSampleRespVO[];
  /**
   * 总量
   */
  total?: number;
}

/**
 * com.tashow.cloud.ai.controller.admin.aisample.vo.AiSampleRespVO
 *
 * AiSampleRespVO
 */
export interface AiSampleRespVO {
  /**
   * 创建时间
   */
  createTime?: string;
  /**
   * 主键
   */
  id?: number;
  /**
   * 样本注释
   */
  remark?: string;
  /**
   * 样本文件id
   */
  sampleFileId?: number;
  /**
   * 样本格式
   */
  sampleMineType?: string;
  /**
   * 样本名称
   */
  sampleName?: string;
  /**
   * 样本大小
   */
  sampleSize?: string;
  /**
   * 样本时长
   */
  sampleTime?: string;
}

export interface SampleReqVo extends PageParam {
  name?: string;
  status?: number;
}

// 获得样本库分页
export const getSamplePage = async (params: SampleReqVo) => {
  return request("/ai/sample/page", {
    method: "GET",
    params,
  });
};
export const getSample = async (id: number) => {
  return request("/ai/sample/get", {
    method: "GET",
    params: { id },
  });
};

// 创建样本库
export const createSample = (formData: FormData) => {
  return request("/ai/sample/create", {
    method: "POST",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data: formData,
  });
};

export const updateSample = (params: SampleReqVo) => {
  return request("/ai/sample/update", {
    method: "PUT",
    data: params,
  });
};

export const deleteSample = (id: string) => {
  return request("/ai/sample/delete", {
    method: "DELETE",
    params: { id },
  });
};

//获得样本标签分组库列表
export const getSampleTagGroup = async () => {
  return request("/ai/sampleTagGroup/list", {
    method: "GET",
  });
};

//创建样本标签分组库
export const createSampleTagGroup = (data: { groupName: string }) => {
  return request("/ai/sampleTagGroup/create", {
    method: "POST",
    data,
  });
};

//添加关联标签

export const relateSample = (data: {
  tagId: number[];
  sampleIds: number[];
}) => {
  return request("/ai/sample/relate", {
    method: "PUT",
    data,
  });
};

// 删除管理标签
export const deleteSampleTagRelate = (data: {
  tagId: number[];
  sampleIds: number[];
}) => {
  return request("/ai/sample/deleteRelate", {
    method: "DELETE",
    data,
  });
};

//更新样本库
export const updateSamples = (
  params: { id: number; remark?: string; sampleName?: string }[]
) => {
  return request("/ai/sample/updates", {
    method: "PUT",
    data: params,
  });
};

// 删除样本标签分组库

export const deleteSampleTagGroup = async (id?: number) => {
  return request("/ai/sampleTagGroup/delete", {
    method: "DELETE",
    params: { id },
  });
};

//更新样本标签分组库

export const updateSampleTagGroup = async (params: {
  id: number;
  groupName: string;
}) => {
  return request("/ai/sampleTagGroup/update", {
    method: "PUT",
    data: params,
  });
};

//获得样本标签库分页

export const getSampleTagPage = async (params: {
  groupId?: number;
  pageNo?: number;
  pageSize?: number;
}) => {
  return request("/ai/sampleTag/page", {
    method: "GET",
    params,
  });
};

//创建样本标签库

export const createSampleTag = (data: {
  groupIds: number[];
  tagName: string;
}) => {
  return request("/ai/sampleTag/create", {
    method: "POST",
    data,
  });
};

// 删除样本标签库
export const deleteSampleTag = async (id?: number) => {
  return request("/ai/sampleTag/delete", {
    method: "DELETE",
    params: { id },
  });
};

//更新样本标签库

export const updateSampleTag = async (params: {
  groupIds: number[];
  tagName: string;
}) => {
  return request("/ai/sampleTag/update", {
    method: "PUT",
    data: params,
  });
};
