import { request } from '@/utils/request'
import { Project } from '@/enums/api'
import {
  OutcomeListResParams,
  OutcomeListReqParams,
  AddOutcomeReqParams,
  AddOutcomeResParams,
  RemoveOutcomeReqParams,
  ModifyOutcomeReqParams,
  OutcomeDetailReqParams,
  OutcomeDetailResParams,
  OutcomeUploadUrlReqParams,
  OutcomeUploadUrlResParams,
  RemoveOutcomeFileReqParams,
  OutcomeDownloadUrlReqParams,
  OutcomeDownloadUrlResParams
} from '@/types/outcome'

/**
 * 获取任务交付物列表
 * @param params OUTCOMEListReqParams
 */
export const getOutcomeList = (params: OutcomeListReqParams) => {
  return request.post<OutcomeListResParams>({
    url: Project.PROJECT_OUTCOME_LIST,
    data: params
  })
}

/**
 * 添加任务交付物信息
 * @param params AddOUTCOMEReqParams
 * @returns
 */
export const addOutcome = (params: AddOutcomeReqParams) => {
  return request.post<AddOutcomeResParams>({
    url: Project.PROJECT_OUTCOME_ADD,
    data: params
  })
}

/**
 * 修改任务交付物信息
 * @param params ModifyOUTCOMEReqParams
 * @returns
 */
export const modifyOutcome = (params: ModifyOutcomeReqParams) => {
  return request.post<BaseResParams>({
    url: Project.PROJECT_OUTCOME_MODIFY,
    data: params
  })
}

/**
 * 删除任务交付物信息
 * @param id 任务交付物编号
 * @returns
 */
export const removeOutcome = (params: RemoveOutcomeReqParams) => {
  return request.post<BaseResParams>({
    url: Project.PROJECT_OUTCOME_REMOVE,
    data: params
  })
}

/**
 * 获取任务交付物详情
 * @param params OUTCOMEDetailReqParams
 * @returns
 */
export const getOutcomeDetail = (params: OutcomeDetailReqParams) => {
  return request.post<OutcomeDetailResParams>({
    url: Project.PROJECT_OUTCOME_DETAIL,
    data: params
  })
}

/**
 * 获取上传任务交付物附件的url。
 * @param params OUTCOMEUploadDocUrlResParams
 * @returns
 */
export const getUploadOutcomeUrl = (params: OutcomeUploadUrlReqParams) => {
  return request.post<OutcomeUploadUrlResParams>({
    url: Project.PROJECT_OUTCOME_UPLOAD,
    data: params
  })
}

/**
 * 删除交付物文件
 * @param params
 * @returns
 */
export const removeOutcomeFile = (params: RemoveOutcomeFileReqParams) => {
  return request.post<BaseResParams>({
    url: Project.PROJECT_OUTCOME_REMOVE_FILE,
    data: params
  })
}

/**
 * 获取上传任务交付物附件的url。
 * @param params OUTCOMEUploadDocUrlResParams
 * @returns
 */
export const getDownloadOutcomeUrl = (params: OutcomeDownloadUrlReqParams) => {
  return request.post<OutcomeDownloadUrlResParams>({
    url: Project.PROJECT_OUTCOME_DOWNLOAD,
    data: params
  })
}
