// @ts-ignore
/* eslint-disable */

// 该文件自动生成，请勿手动修改！

// --------------------------------------------------------------------------
// 学生成绩导入服务
// --------------------------------------------------------------------------

import { request, RequestOptions } from '@umijs/max';
import contentDisposition from 'content-disposition';

/** 上传文件并完成批量导入前期未上报学生名单的各科成绩 POST /api/exam/score/import/upload-import-without-student-total-score */
export async function uploadImportWithoutStudentTotalScore(
    data: FormData,
    options?: { [key: string]: any },
) {
    const url = '/api/exam/score/import/upload-import-without-student-total-score';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 批量导入学生总成绩 POST /api/exam/score/import/upload-import-student-total-score */
export async function uploadImportStudentTotalScore(
    data: FormData,
    options?: { [key: string]: any },
) {
    const url = '/api/exam/score/import/upload-import-student-total-score';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 导入区校合并小题成绩 POST /api/exam/score/import/upload-import-student-minor-score */
export async function uploadImportStudentMinorScore(
    data: FormData,
    options?: { [key: string]: any },
) {
    const url = '/api/exam/score/import/upload-import-student-minor-score';
    const config = {
        method: 'POST',
        data,
        ...(options || {}),
        responseType: 'blob',
        getResponse: true,
    } as RequestOptions;
    const res = await request(url, config);
    const hcd = res.request.getResponseHeader('Content-Disposition');
    if (!hcd) {
        return null;
    }
    let fileName = '';
    const cd = contentDisposition.parse(hcd);
    if (cd?.parameters?.filename) {
        fileName = cd?.parameters?.filename;
    }
    return { fileName, data: res.data as Blob } as API.FileResponse;
}

export default {
    /** 上传文件并完成批量导入前期未上报学生名单的各科成绩 POST /api/exam/score/import/upload-import-without-student-total-score */
    uploadImportWithoutStudentTotalScore,
    /** 批量导入学生总成绩 POST /api/exam/score/import/upload-import-student-total-score */
    uploadImportStudentTotalScore,
    /** 导入区校合并小题成绩 POST /api/exam/score/import/upload-import-student-minor-score */
    uploadImportStudentMinorScore,
};
