import request from '@/utils/http';
import { Project } from '@/enums/api'
import {
  DocumentDetailResParams,
  DocumentListReqParams,
  DocumentListResParams,
  DownloadDocumentReqParams,
  DownloadDocumentResParams,
  UploadDocumentReqParams,
  UploadDocumentResParams
} from '@/types/document'

/**
 * 获取项目文档列表
 * @param params DocumentListReqParams
 * @returns DocumentListResParams
 */
export const getDocumentList = (params: DocumentListReqParams) => {
  return request.post<DocumentListResParams>(
    Project.PROJECT_DOC_LIST,
     params
  )
}

/**
 * 获取上传项目文档Url
 * @param params UploadDocumentReqParams
 * @returns UploadDocumentResParams
 */
export const getUploadDocumentUrl = (params: UploadDocumentReqParams) => {
  return request.post<UploadDocumentResParams>(
    Project.PROJECT_DOC_UPLOAD,
    params
  )
}

/**
 * 获取下载项目文档Url
 * @param params DownloadDocumentReqParams
 * @returns DownloadDocumentResParams
 */
export const getDownloadDocumentUrl = (params: DownloadDocumentReqParams) => {
  return request.post<DownloadDocumentResParams>(
     Project.PROJECT_DOC_DOWNLOAD,
     params
  )
}

/**
 * 删除项目文档
 * @param params
 * @returns
 */
export const removeDocument = (params: { id: string }) => {
  return request.post<BaseResParams>(
    Project.PROJECT_DOC_REOMOVE,
    params
  )
}



/**
 * 删除项目文档
 * @param params
 * @returns
 */
export const getDocumentDetail = (params: { id: string }) => {
  return request.post<DocumentDetailResParams>(
    Project.PROJECT_DOC_DETAIL,
    params
  )
}



// 归档文件
export const archiveDocument = (params: { id: string; archive: boolean }) => {
  return request.post<BaseResParams>(
     Project.PROJECT_DOC_ARCHIVE,
    params
  )
}

// 复制文件
export const copyDocument = (params: { id: string; target: string }) => {
  return request.post<BaseResParams>(
     Project.PROJECT_DOC_COPY,
     params
  )
}

// 重命名
export const renameDocument = (params: { id: string; filename: string }) => {
  return request.post<BaseResParams>(
    Project.PROJECT_DOC_RENAME,
    params
  )
}