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

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

// --------------------------------------------------------------------------
// 监测抽样方案管理服务
// --------------------------------------------------------------------------

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

/** 添加监测抽样方案 POST /api/exam/sample/add */
export async function add(data: API.AddExamSampleInput, options?: { [key: string]: any }) {
    const url = '/api/exam/sample/add';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 更新监测抽样方案 POST /api/exam/sample/update */
export async function update(data: API.UpdateExamSampleInput, options?: { [key: string]: any }) {
    const url = '/api/exam/sample/update';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 复制抽样方案信息 POST /api/exam/sample/duplicate */
export async function duplicate(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/sample/duplicate';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 删除监测抽样方案 POST /api/exam/sample/del */
export async function del(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/sample/del';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 保存全抽班级ID列表 POST /api/exam/sample/save-exam-sample-all-classes */
export async function saveExamSampleAllClasses(
    data: API.SaveExamSampleAllClasses,
    options?: { [key: string]: any },
) {
    const url = '/api/exam/sample/save-exam-sample-all-classes';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 切换全抽班级 POST /api/exam/sample/switch-exam-sample-all-class */
export async function switchExamSampleAllClass(
    data: API.SwitchExamSampleAllClassInput,
    options?: { [key: string]: any },
) {
    const url = '/api/exam/sample/switch-exam-sample-all-class';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 选定方案 POST /api/exam/sample/select-sample */
export async function selectSample(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/sample/select-sample';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 执行抽样 POST /api/exam/sample/execute-sample */
export async function executeSample(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/sample/execute-sample';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 导出抽样方案存档文件 POST /api/exam/sample/export-to-archived */
export async function exportToArchived(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/sample/export-to-archived';
    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;
}

/** 导出给印刷厂和网阅机构文件 POST /api/exam/sample/export-to-printshop */
export async function exportToPrintshop(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/sample/export-to-printshop';
    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;
}

/** 导出给学校 POST /api/exam/sample/export-to-org */
export async function exportToOrg(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/sample/export-to-org';
    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;
}

/** 导出抽样统计表 POST /api/exam/sample/export-sample-count */
export async function exportSampleCount(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/sample/export-sample-count';
    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;
}

/** 导出学校抽样统计表 POST /api/exam/sample/export-sample-count-to-org */
export async function exportSampleCountToOrg(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/sample/export-sample-count-to-org';
    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;
}

/** 根据ID获取抽样方案 GET /api/exam/sample/get-by-id */
export async function getById(
    params: {
        /**  */
        id: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/sample/get-by-id';
    const config = { method: 'GET', params, ...(options || {}) };
    const res = await request<API.ResponseType<API.ExamSampleOutput>>(url, config);
    return res?.data;
}

/** 根据监测计划ID获取全部抽样方案 GET /api/exam/sample/get-list-by-exam-plan-id */
export async function getListByExamPlanId(
    params: {
        /**  */
        examplanid: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/sample/get-list-by-exam-plan-id';
    const config = { method: 'GET', params, ...(options || {}) };
    const res = await request<API.ResponseType<API.ExamSampleOutput[]>>(url, config);
    return res?.data;
}

/** 查询已发布抽样 GET /api/exam/sample/get-by-exam-data-publish-id */
export async function getByExamDataPublishId(
    params: {
        /** 监测发布内容ID */
        examdatapublishid: number;
        /** 抽样数据发布类型 */
        type: DataPublishType;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/sample/get-by-exam-data-publish-id';
    const config = { method: 'GET', params, ...(options || {}) };
    const res = await request<API.ResponseType<API.ExamSamplePlanOutput>>(url, config);
    return res?.data;
}

/** 获取抽样统计表 GET /api/exam/sample/get-sample-count-list-by-id */
export async function getSampleCountListById(
    params: {
        /**  */
        id: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/sample/get-sample-count-list-by-id';
    const config = { method: 'GET', params, ...(options || {}) };
    const res = await request<API.ResponseType<API.ExamSampleCountOutput[]>>(url, config);
    return res?.data;
}

/** 获取学校抽样统计表 GET /api/exam/sample/get-org-sample-count-list-by-id */
export async function getOrgSampleCountListById(
    params: {
        /**  */
        id: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/sample/get-org-sample-count-list-by-id';
    const config = { method: 'GET', params, ...(options || {}) };
    const res = await request<API.ResponseType<API.ExamSampleCountOutput[]>>(url, config);
    return res?.data;
}

export default {
    /** 添加监测抽样方案 POST /api/exam/sample/add */
    add,
    /** 更新监测抽样方案 POST /api/exam/sample/update */
    update,
    /** 复制抽样方案信息 POST /api/exam/sample/duplicate */
    duplicate,
    /** 删除监测抽样方案 POST /api/exam/sample/del */
    del,
    /** 保存全抽班级ID列表 POST /api/exam/sample/save-exam-sample-all-classes */
    saveExamSampleAllClasses,
    /** 切换全抽班级 POST /api/exam/sample/switch-exam-sample-all-class */
    switchExamSampleAllClass,
    /** 选定方案 POST /api/exam/sample/select-sample */
    selectSample,
    /** 执行抽样 POST /api/exam/sample/execute-sample */
    executeSample,
    /** 导出抽样方案存档文件 POST /api/exam/sample/export-to-archived */
    exportToArchived,
    /** 导出给印刷厂和网阅机构文件 POST /api/exam/sample/export-to-printshop */
    exportToPrintshop,
    /** 导出给学校 POST /api/exam/sample/export-to-org */
    exportToOrg,
    /** 导出抽样统计表 POST /api/exam/sample/export-sample-count */
    exportSampleCount,
    /** 导出学校抽样统计表 POST /api/exam/sample/export-sample-count-to-org */
    exportSampleCountToOrg,
    /** 根据ID获取抽样方案 GET /api/exam/sample/get-by-id */
    getById,
    /** 根据监测计划ID获取全部抽样方案 GET /api/exam/sample/get-list-by-exam-plan-id */
    getListByExamPlanId,
    /** 查询已发布抽样 GET /api/exam/sample/get-by-exam-data-publish-id */
    getByExamDataPublishId,
    /** 获取抽样统计表 GET /api/exam/sample/get-sample-count-list-by-id */
    getSampleCountListById,
    /** 获取学校抽样统计表 GET /api/exam/sample/get-org-sample-count-list-by-id */
    getOrgSampleCountListById,
};
