import { $postParam, $post } from "@/plugins/axios";

export const semesterQuery = (datas) => {
  return $postParam("/api/exam_semester/list", datas);
};
export const ecsExamQuery = (collegeId = "") => {
  return $postParam("/api/cloud_marking_exam/list", { collegeId });
};
export const ecsExamSync = (collegeId = "") => {
  return $postParam("/api/cloud_marking_exam/sync", { collegeId });
};
export const examTypeQuery = (datas) => {
  return $postParam("/api/exam_type/list", datas);
};
export const collegeQuery = () => {
  return $postParam("/api/sys_college/list", {});
};
export const courseQuery = (datas) => {
  return $postParam("/api/common/course/list", datas);
};
export const kcCollegeQuery = (datas) => {
  // semesterId,examTypeId,courseCode,openCollege,
  return $postParam("/api/common/examine/college/list", datas);
};
export const examClazzQuery = (datas) => {
  // semesterId,examTypeId,courseCode,openCollege,kcCollege
  return $postParam("/api/common/clazz/list", datas);
};
export const examTeacherQuery = (datas) => {
  // semesterId,examTypeId,courseCode,openCollege,kcCollege,clazzId
  return $postParam("/api/common/teacher/list", datas);
};
// user --------------------------------->
// user-manage
export const userListPage = (datas) => {
  return $postParam("/api/sys_user/page", datas);
};
export const updateUser = (datas) => {
  return $post("/api/sys_user/save", datas);
};
export const ableUser = ({ id, enable }) => {
  return $post("/api/sys_user/enable", { id, enable });
};
export const resetPwd = (id) => {
  return $post("/api/sys_user/reset_password", { id });
};
export const userRoleListPage = () => {
  return $postParam("/api/sys_role/list", {});
};

// semester-manage
export const semesterListQuery = (datas) => {
  return $postParam("/api/exam_semester/page", datas);
};
export const deleteSemester = (id) => {
  return $postParam("/api/exam_semester/delete", { id });
};
export const updateSemester = (datas) => {
  return $post("/api/exam_semester/save", datas);
};
export const ableSemester = ({ id, enable }) => {
  return $postParam("/api/exam_semester/enable", { id, enable });
};
// no user
export const semesterSetInUsed = (id) => {
  return $postParam("/api/exam_semester/set_in_used", { id });
};

// exam-type-manage
export const examTypeListQuery = (datas) => {
  return $postParam("/api/exam_type/page", datas);
};
export const deleteExamType = (id) => {
  return $postParam("/api/exam_type/delete", {
    id,
  });
};
export const updateExamType = (datas) => {
  return $post("/api/exam_type/save", datas);
};
export const ableExamType = ({ id, enable }) => {
  return $postParam("/api/exam_type/enable", { id, enable });
};
// setting --------------------------------->
// time-task
export const timeTaskList = (datas) => {
  return $postParam("/api/exam_schedule_task/page", datas);
};
export const updateTimeTask = (datas) => {
  return $post("/api/exam_schedule_task/save", datas);
};

// business-data
export const businessDataList = (datas) => {
  return $postParam("/api/exam_sync_total/page", datas);
};
export const manualSync = () => {
  return $postParam("/api/exam_sync_total/manual_sync", {});
};
export const manualUse = (id) => {
  return $postParam("/api/exam_sync_total/used", { id });
};
export const downloadBusinessData = (id, writeLog) => {
  return $postParam(
    "/api/exam_sync_total/download",
    { id, writeLog },
    {
      responseType: "blob",
    }
  );
};
export const useSceneList = (datas) => {
  return $postParam("/api/exam_download_record/list_use_scene", datas);
};
// download-manage
export const downloadList = (datas) => {
  return $postParam("/api/exam_download_record/page", datas);
};
export const signPurpose = (datas) => {
  return $postParam("/api/exam_download_record/used", datas);
};
// ecs-data-manage
export const ecsDataList = (datas) => {
  return $postParam("/api/cloud_marking_score/page", datas);
};
export const syncEcsData = (datas) => {
  return $postParam("/api/cloud_marking_score/sync_student_score", datas);
};
// ecs-data-manage
export const dataTaskList = (datas) => {
  return $postParam("/api/sync_task/page", datas);
  // status（非必填）：INIT("未开始"),RUNNING("进行中"),FINISH("已完成");
  // type（必填）：WHU_TEACH_DATA("同步武大考务数据"),CLOUD_MARKING_STUDENT_SCORE("同步云阅卷考生成绩");
  // result（非必填）：SUCCESS("成功"),ERROR("失败");
};
export const dataReturnList = (datas) => {
  return $postParam("/api/cloud_marking_score_foreign/page", datas);
};
export const downloadDataReturn = (datas) => {
  return $postParam("/api/cloud_marking_score_foreign/download_score", datas, {
    responseType: "blob",
  });
};

// course-link-manage
export const courseLinkList = (datas) => {
  return $postParam("/api/exam_course_mapping/page", datas);
};
// common
export const uploadFile = (datas) => {
  return $post("/api/admin/common/file/upload", datas);
};
export const getCode = (type) => {
  return $postParam("/api/admin/common/get_code", { type });
};

// system-setting
export const systemSettingQuery = () => {
  return $postParam("/api/sys_setting/get", {});
};
export const updateSystemSetting = (datas) => {
  return $post("/api/sys_setting/save", datas);
};
export const flushCache = () => {
  return $postParam("/api/sys_setting/flush_cache", {});
};
// assignment-calculate
export const assignmentDataList = (datas) => {
  return $postParam("/api/assign/page", datas);
};
export const downloadAssignmentData = (datas) => {
  return $postParam("/api/assign/download", datas, {
    responseType: "blob",
  });
};
export const assignmentDetailInfo = (datas, silence = false) => {
  return $postParam("/api/assign/to_calc", datas, {
    silence,
  });
};
export const assignmentCalculate = (datas) => {
  return $post("/api/assign/calc", datas);
};
export const assignmentPublish = (datas) => {
  return $postParam("/api/assign/publish", datas);
};
export const assignmentCalcResult = (datas) => {
  // required: semesterId,examTypeId,courseCode,openCollege,
  // kcCollege,clazzId,teacherCode
  return $postParam("/api/assign/result", datas);
};
export const assignmentCompareResult = (datas) => {
  // semesterId,examTypeId,courseCode,openCollege,passScore
  return $postParam("/api/assign/contrast", datas);
};
