import { httpApp } from "@/plugins/axiosApp";
import { SasCourse, SASPaper, ServerPageResponse } from "@/types";

/** 试卷特征数分页查询 */
export function getSasPaperList(params: {
  courseId?: number;
  projectId: number;
  pageNo?: number;
  pageSize?: number;
  sortColName?: string;
  sortOrder?: string;
}) {
  return httpApp.post<any, ServerPageResponse<SASPaper>>(
    "/api/ess/sasPaper/page",
    params
  );
}

/** 科目成绩（总分）频率分布-科目成绩占初试总分权重 分页查询 */
export function getSasCourseList(params: {
  courseId?: number;
  projectId: number;
}) {
  return httpApp.post<any, { data: SasCourse[] }>(
    "/api/ess/sasCourse/list",
    params
  );
}

/** 科目成绩（总分）频率分布-分段设置 */
export function setSasCourseRangeConfig(params: {
  courseId?: number;
  projectId: number;
  rangeConfig: string;
}) {
  return httpApp.post("/api/ess/projectCourse/rangeConfig", params);
}

/** 整体分析-科目成绩占初试总分权重-分段设置 */
export function setSasCourseTotalRangeConfig(params: {
  courseId?: number;
  projectId: number;
  rangeConfig: string;
}) {
  return httpApp.post("/api/ess/projectCourse/totalRangeConfig", params);
}

/** 整体分析-报告导出 */
export function batchExportProjectReport(params: {
  compareProjectId?: number;
  projectId: number;
}) {
  return httpApp.post("/api/ess/project/report/export", {}, { params });
}

// 报告导出流程api ----->
// 获取报告导出任务信息
export function getProjectReportTask(params: {
  compareProjectId?: number;
  projectId: number;
}) {
  return httpApp.post<
    any,
    {
      data: {
        paperIds: number[];
        taskId: number;
      };
    }
  >("/api/ess/report/task/export", {}, { params });
}
// 上传报告html内容，后台生成报告pdf
export function uploadProjectReportCont(params: {
  taskId: number;
  paperId: number;
  htmlContent: string;
}) {
  return httpApp.post("/api/ess/report/task/html", { params });
}
// 报告文件生成进度结果查询
export function getProjectReportResult(taskId: number) {
  return httpApp.post<
    any,
    {
      data: {
        filePath: string;
        status: string;
      };
    }
  >("/api/ess/report/task/result", { taskId });
}
