import { request } from '@/utils/request'
import type { FileUploadResult } from '@/types'

/**
 * 文件上传
 * 后端：POST /api/file/upload (multipart/form-data, field=file, query bizType)
 */
export function uploadFileApi(file: File, bizType: string = 'common') {
  const fd = new FormData()
  fd.append('file', file)
  return request<FileUploadResult>({
    url: '/api/file/upload',
    method: 'POST',
    data: fd,
    params: { bizType }
    // 注意：axios 会在 FormData 场景下自动设置 Content-Type，勿手动覆盖
  })
}
