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

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

// --------------------------------------------------------------------------
// 试卷管理服务
// --------------------------------------------------------------------------

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

/** 按监测计划初始化试卷 POST /api/exam/paper/batch-init */
export async function batchInit(
    data: API.ExamPaperBatchInitInput,
    options?: { [key: string]: any },
) {
    const url = '/api/exam/paper/batch-init';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 分配双向细目表编制人 POST /api/exam/paper/assign-twcl-writer */
export async function assignTwclWriter(
    data: API.AssignExamPaperWriterInput,
    options?: { [key: string]: any },
) {
    const url = '/api/exam/paper/assign-twcl-writer';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 分配问题建议撰写人 POST /api/exam/paper/assign-suggestion-writer */
export async function assignSuggestionWriter(
    data: API.AssignExamPaperWriterInput,
    options?: { [key: string]: any },
) {
    const url = '/api/exam/paper/assign-suggestion-writer';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

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

/** 根据监测计划ID获取试卷列表（管理端） GET /api/exam/paper/get-list-by-exam-plan-id */
export async function getListByExamPlanId(
    params: {
        /**  */
        examplanid?: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/paper/get-list-by-exam-plan-id';
    const config = { method: 'GET', params, ...(options || {}) };
    const res = await request<API.ResponseType<API.ExamPaperLiteOutput[]>>(url, config);
    return res?.data;
}

/** 获取双向细目表监测计划列表（管理端） POST /api/exam/paper/query-exam-plan-page-list */
export async function queryExamPlanPageList(
    data: API.ExamPlanPageInput,
    options?: { [key: string]: any },
) {
    const url = '/api/exam/paper/query-exam-plan-page-list';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<API.PageResponse<API.ExamPaperTodoPlanOutput>>>(
        url,
        config,
    );
    return res?.data;
}

/** 导出TQES导入文件格式文件包 POST /api/exam/paper/export-tqes-file */
export async function exportTqesFile(
    params: {
        /**  */
        examplanid: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/paper/export-tqes-file';
    const config = {
        method: 'POST',
        params,
        ...(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/paper/query-writer-exam-plan-page-list */
export async function queryWriterExamPlanPageList(
    data: API.ExamPaperExamPlanPageInput,
    options?: { [key: string]: any },
) {
    const url = '/api/exam/paper/query-writer-exam-plan-page-list';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<API.PageResponse<API.ExamPaperTodoPlanOutput>>>(
        url,
        config,
    );
    return res?.data;
}

/** 根据监测计划ID获取待处理试卷列表 GET /api/exam/paper/get-writer-list-by-exam-plan-id */
export async function getWriterListByExamPlanId(
    params: {
        /**  */
        examplanid: number;
        /**  */
        writertype: ExamPaperWriterType;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/paper/get-writer-list-by-exam-plan-id';
    const config = { method: 'GET', params, ...(options || {}) };
    const res = await request<API.ResponseType<API.ExamPaperLiteOutput[]>>(url, config);
    return res?.data;
}

/** 保存问题建议 POST /api/exam/paper/save-suggestion */
export async function saveSuggestion(
    data: API.SaveExamPaperSuggestion,
    options?: { [key: string]: any },
) {
    const url = '/api/exam/paper/save-suggestion';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 提交双向细目表 POST /api/exam/paper/submit-twcl */
export async function submitTwcl(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/paper/submit-twcl';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 提交问题建议 POST /api/exam/paper/submit-suggestion */
export async function submitSuggestion(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/paper/submit-suggestion';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

export default {
    /** 按监测计划初始化试卷 POST /api/exam/paper/batch-init */
    batchInit,
    /** 分配双向细目表编制人 POST /api/exam/paper/assign-twcl-writer */
    assignTwclWriter,
    /** 分配问题建议撰写人 POST /api/exam/paper/assign-suggestion-writer */
    assignSuggestionWriter,
    /** 根据ID获取试卷详情 GET /api/exam/paper/get-by-id */
    getById,
    /** 根据监测计划ID获取试卷列表（管理端） GET /api/exam/paper/get-list-by-exam-plan-id */
    getListByExamPlanId,
    /** 获取双向细目表监测计划列表（管理端） POST /api/exam/paper/query-exam-plan-page-list */
    queryExamPlanPageList,
    /** 导出TQES导入文件格式文件包 POST /api/exam/paper/export-tqes-file */
    exportTqesFile,
    /** 分页查询编撰人监测计划列表 POST /api/exam/paper/query-writer-exam-plan-page-list */
    queryWriterExamPlanPageList,
    /** 根据监测计划ID获取待处理试卷列表 GET /api/exam/paper/get-writer-list-by-exam-plan-id */
    getWriterListByExamPlanId,
    /** 保存问题建议 POST /api/exam/paper/save-suggestion */
    saveSuggestion,
    /** 提交双向细目表 POST /api/exam/paper/submit-twcl */
    submitTwcl,
    /** 提交问题建议 POST /api/exam/paper/submit-suggestion */
    submitSuggestion,
};
