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

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

// --------------------------------------------------------------------------
// 监测机构反馈结果管理服务
// --------------------------------------------------------------------------

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

/** 上传监测机构反馈文件 POST /api/exam/org/result/upload */
export async function upload(data: FormData, options?: { [key: string]: any }) {
    const url = '/api/exam/org/result/upload';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 根据文件ID下载文件 GET /api/exam/org/result/download */
export async function download(
    params: {
        /**  */
        id: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/org/result/download';
    const config = {
        method: 'GET',
        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/org/result/del */
export async function del(data: API.BaseId, options?: { [key: string]: any }) {
    const url = '/api/exam/org/result/del';
    const config = { method: 'POST', data, ...(options || {}) };
    const res = await request<API.ResponseType<any>>(url, config);
    return res?.data;
}

/** 获取ID获取监测机构反馈文件信息 GET /api/exam/org/result/get-by-id */
export async function getById(
    params: {
        /**  */
        id: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/org/result/get-by-id';
    const config = { method: 'GET', params, ...(options || {}) };
    const res = await request<API.ResponseType<API.ExamOrgResultOutput>>(url, config);
    return res?.data;
}

/** 根据监测计划获取机构反馈文件列表 GET /api/exam/org/result/get-by-exam-plan-id */
export async function getByExamPlanId(
    params: {
        /**  */
        examplanid?: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/org/result/get-by-exam-plan-id';
    const config = { method: 'GET', params, ...(options || {}) };
    const res = await request<API.ResponseType<API.ExamDataPublishOrgResultOutput[]>>(url, config);
    return res?.data;
}

/** 根据发布内容ID获取机构文件列表 GET /api/exam/org/result/get-by-publish-id */
export async function getByPublishId(
    params: {
        /**  */
        publishid: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/org/result/get-by-publish-id';
    const config = { method: 'GET', params, ...(options || {}) };
    const res = await request<API.ResponseType<API.ExamOrgResultOutput[]>>(url, config);
    return res?.data;
}

export default {
    /** 上传监测机构反馈文件 POST /api/exam/org/result/upload */
    upload,
    /** 根据文件ID下载文件 GET /api/exam/org/result/download */
    download,
    /** 删除文件 POST /api/exam/org/result/del */
    del,
    /** 获取ID获取监测机构反馈文件信息 GET /api/exam/org/result/get-by-id */
    getById,
    /** 根据监测计划获取机构反馈文件列表 GET /api/exam/org/result/get-by-exam-plan-id */
    getByExamPlanId,
    /** 根据发布内容ID获取机构文件列表 GET /api/exam/org/result/get-by-publish-id */
    getByPublishId,
};
