import request from '@/utils/request'
export function uploadFile(file, type, id) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: `/file/uploadFile/${type}/${id}`,
    method: 'post',
    data: formData
  })
}

export function deleteAttachment(id, filePath) {
  return request({
    url: `/attachment/deleteAttachment`,
    method: 'delete',
    data: { Id: id, Path: filePath }
  })
}

export function getAttachmentByType(doctorId, type) {
  return request({
    url: `/attachment/getAttachmentByType/${doctorId}/${type}`,
    method: 'get'
  })
}

export function saveAttachments(param) {
  return request({
    url: `/attachment/saveAttachments`,
    method: 'post',
    data: param
  })
}

export function setOfficial(doctorId, attachmentId, language) {
  return request({
    url: `/attachment/setOfficial/${doctorId}/${attachmentId}/${language}`,
    method: 'post'
  })
}

export function uploadNonDoctorFile(file, type, config = {}) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: `/file/uploadNonDoctorFile/${type}`,
    method: 'post',
    data: formData,
    ...config
  })
}

export function setLanguageForResume(doctorId, attachmentId, language) {
  return request({
    url: `/attachment/setLanguage/${doctorId}/${attachmentId}/${language}`,
    method: 'post'
  })
}
