import { FileModel, FileModelQueryParam } from "@/types";
import request from "@/until/request";

/**
 * 获取文档列表
 * @param data FileModelQueryParam
 */
const QueryFileModelList = (data: FileModelQueryParam) =>
  request({
    url: "/FileUploadAction/list/",
    method: "post",
    data: data,
  });

/**
 * 获取文档类型列表
 * @param data FileModelQueryParam
 */
const QueryFileTypeModelList = () =>
  request({
    url: "/FileUploadTypeAction/list/",
    method: "get",
  });

/**
 * 新增文档
 * @param params FileModel
 * @param data FormData
 */
const AddFileModel = (params: FileModel, data: FormData) =>
  request({
    url: "/FileUploadAction/saveFileUpload/file",
    method: "post",
    headers: { "Content-Type": "multipart/form-data" },
    params: params,
    data: data,
  });

/**
 * 删除文档
 * @param  data FileModel
 */
const DeleteFileModel = (data: FileModel) =>
  request({
    url: "/FileUploadAction/deleteFileUpload/" + data.id,
    method: "get",
  });

export default {
  QueryFileModelList,
  QueryFileTypeModelList,
  AddFileModel,
  DeleteFileModel,
};
