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

export const questionTeatherUserQuery = ({ courseId, param }) => {
  return $postParam("/api/admin/sys/user/user_list", { courseId, param });
};
export const unitQueryByType = (datas, dictionaryEnum) => {
  // dictionaryEnum: SEMESTER("学期"),COLLEGE("学院"),MAJOR("专业"),CLAZZ("班级"),STUDENT("学生"),COURSE("课程")
  return $postParam("/api/admin/common/get_dictionary", {
    ...datas,
    dictionaryEnum,
  });
};
export const getEnums = (type) => {
  return $postParam("/api/admin/common/get_enums", { type });
};
// semester
export const conditionListSemester = (datas) => {
  // enable
  return $postParam("/api/admin/basic/condition/list_semester", datas);
};
// exam
export const conditionListExam = ({ semesterId, category, enable }) => {
  return $postParam("/api/admin/basic/condition/list_exam", {
    semesterId,
    category,
    enable,
  });
};
// print_plan
export const conditionListPrintPlan = ({ semesterId, examId }) => {
  return $postParam("/api/admin/basic/condition/list_print_plan", {
    semesterId,
    examId,
  });
};
// course
export const conditionListCourse = ({
  semesterId,
  examId,
  printPlanId,
  openCollegeId,
}) => {
  return $postParam("/api/admin/basic/condition/list_course", {
    semesterId,
    examId,
    printPlanId,
    openCollegeId,
  });
};
// paper_number
export const conditionListPaperNumber = ({
  semesterId,
  examId,
  courseId,
  printPlanId,
  openCollegeId,
}) => {
  return $postParam("/api/admin/basic/condition/list_paper_number", {
    semesterId,
    examId,
    courseId,
    printPlanId,
    openCollegeId,
  });
};
// clazz
export const conditionListClazz = ({ semesterId, examId, courseId }) => {
  return $postParam("/api/admin/basic/condition/list_clazz", {
    semesterId,
    examId,
    courseId,
  });
};
// professional
export const conditionProfessionalList = () => {
  return $postParam("/api/admin/basic/condition/list_professional", {});
};
// training-plan
export const conditionTrainingPlanList = (professionalId) => {
  return $postParam("/api/admin/basic/condition/list_culture_program", {
    professionalId,
  });
};
// training-plan-course
export const conditionTrainingPlanCourseList = ({
  professionalId,
  cultureProgramId,
}) => {
  return $postParam("/api/admin/basic/condition/list_culture_program_course", {
    professionalId,
    cultureProgramId,
  });
};

// user --------------------------------->
// user-manage
export const userListPage = (datas) => {
  return $postParam("/api/admin/sys/user/list", datas);
};
export const updateUser = (datas) => {
  return $post("/api/admin/sys/user/save", datas);
};
export const ableUser = ({ id, enable }) => {
  return $post("/api/admin/sys/user/enable", { id, enable });
};
export const resetPwd = (id) => {
  return $post("/api/admin/sys/user/reset_password", { id });
};
export const deleteUser = (id) => {
  return $postParam("/api/admin/sys/user/remove", { id });
};
export const updatePwd = (datas) => {
  return $post("/api/admin/sys/user/update_password", datas);
};
export const userBindRoles = ({ id, roleIds }) => {
  return $post("/api/admin/sys/user/bind_roles", { id, roleIds });
};
export const userRoleListPage = () => {
  return $postParam("/api/admin/sys/role/list_to_user", {});
};
export const syncUserToEcs = () => {
  return $postParam("/api/admin/sys/user/push", {});
};
export const roleUserTree = () => {
  return $postParam("/api/admin/sys/user/org-tree", {});
};
export const exportUser = (datas) => {
  return $postParam("/api/admin/sys/user/export", datas, {
    responseType: "blob",
  });
};

// role-manage
export const roleListPage = (datas) => {
  return $postParam("/api/admin/sys/role/list", datas);
};
export const ableRole = ({ id, enable }) => {
  return $post("/api/admin/sys/role/enable", { id, enable });
};
export const updateRole = (datas) => {
  return $post("/api/admin/sys/role/save", datas);
};
export const deleteRole = (id) => {
  return $postParam("/api/admin/sys/role/remove", { id });
};
export const userBoundRoles = (userId) => {
  return $postParam("/api/admin/sys/role/get_user_roles", { userId });
};
// role-user-manage
export const roleGroupList = (datas) => {
  return $postParam("/api/admin/sys/role/group/list", datas);
};
export const updateRoleGroup = (datas) => {
  return $post("/api/admin/sys/role/group/save", datas);
};
// menu-manage
export const menuAuthList = (datas) => {
  return $postParam("/api/admin/sys/privilege/list_auth", datas);
};
export const privilegeList = (datas) => {
  return $postParam("/api/admin/sys/privilege/list", datas);
};
export const roleBoundPrivileges = (roleId) => {
  return $postParam("/api/admin/sys/privilege/get_role_privileges", { roleId });
};
// organization-manage
export const organizationList = (datas) => {
  return $postParam("/api/admin/sys/org/list", datas);
};
export const organizationFindByTypeList = (datas) => {
  return $postParam("/api/admin/sys/org/find_by_type", datas);
};
export const updateOrganization = (datas) => {
  return $post("/api/admin/sys/org/save", datas);
};
export const ableOrganization = ({ id, enable }) => {
  return $post("/api/admin/sys/org/enable", { id, enable });
};
export const deleteOrganization = (id) => {
  return $post("/api/admin/sys/org/remove", { id });
};
export const teachCollegeList = (examId) => {
  return $postParam("/api/admin/grade/batch/paper/find_teach_college", {
    examId,
  });
};
export const exportOrganization = () => {
  return $postParam("/api/admin/sys/org/export", {}, { responseType: "blob" });
};
// setting --------------------------------->
// common-rule
export const examRuleDetail = (schoolId) => {
  return $postParam("/api/admin/basic/exam_rule/list", { schoolId });
};
export const saveExamRule = (datas) => {
  return $post("/api/admin/basic/exam_rule/save", datas);
};
// card-rule
export const cardRuleListPage = (datas) => {
  return $postParam("/api/admin/basic/card_rule/list", datas);
};
export const cardRuleQuery = (datas) => {
  return $postParam("/api/admin/basic/card_rule/query", datas);
};
export const cardRuleDetail = (id) => {
  return $postParam("/api/admin/basic/card_rule/get_one", { id });
};
export const saveCardRule = (datas) => {
  return $post("/api/admin/basic/card_rule/save", datas, {
    enableEmptyParam: true,
  });
};
export const ableCardRule = ({ id, enable }) => {
  return $post("/api/admin/basic/card_rule/enable", { id, enable });
};
export const deleteCardRule = (id) => {
  return $post("/api/admin/basic/card_rule/delete", { id });
};
// common-card-template / common-print-template / param-print-template
export const templateListPage = (datas) => {
  return $postParam("/api/admin/basic/template/list", datas);
};
export const templateDetail = (id) => {
  return $postParam("/api/admin/basic/template/get_one", { id });
};
export const updateTemplate = (datas) => {
  return $post("/api/admin/basic/template/save", datas);
};
export const ableTemplate = ({ id, enable }) => {
  return $post("/api/admin/basic/template/enable", { id, enable });
};
export const deleteTemplate = (id) => {
  return $postParam("/api/admin/basic/template/remove", { id });
};
export const templateCategoryList = (type) => {
  return $postParam("/api/admin/basic/template/list", type);
};
export const templateContentView = (id) => {
  return $postParam("/api/admin/basic/template/read_content", { id });
};
// card-manage
export const cardListPage = (datas) => {
  return $postParam("/api/admin/exam/card/page", datas);
};
export const updateCard = (datas) => {
  return $post("/api/admin/exam/card/save_generic", datas);
};
export const deleteCard = (id) => {
  return $postParam("/api/admin/exam/card/delete_generic", { id });
};
export const convertCardImage = (id) => {
  return $postParam("/api/admin/exam/card/convert_image", { id });
};
export const downloadCardFile = (id) => {
  return $postParam(
    "/api/admin/exam/card/download_card",
    { id },
    {
      responseType: "blob",
    }
  );
};
export const ableCard = ({ id, enable }) => {
  return $postParam("/api/admin/exam/card/enable", { id, enable });
};
// course-manage
export const courseListPage = (datas) => {
  return $postParam("/api/admin/basic/course/list", datas);
};
export const courseQuery = (datas) => {
  return $postParam("/api/admin/basic/course/query", datas);
};
export const courseQueryByOrg = (datas) => {
  return $postParam("/api/admin/basic/course/list_by_org", datas);
};
export const deleteCourse = (idList) => {
  return $postParam("/api/admin/basic/course/delete_batch", { idList });
};
export const batchDeleteCourse = (datas) => {
  return $postParam("/api/admin/basic/course/delete_by_query", datas);
};
export const updateCourse = (datas) => {
  return $post("/api/admin/basic/course/save", datas);
};
export const ableCourse = ({ idList, enable }) => {
  return $postParam("/api/admin/basic/course/enable", { idList, enable });
};
export const batchEnableCourse = (datas) => {
  return $postParam("/api/admin/basic/course/enable_by_query", datas);
};
export const exportCourse = (datas) => {
  return $postParam("/api/admin/basic/course/export", datas, {
    responseType: "blob",
  });
};

// clazz-manage
export const clazzListQuery = (datas) => {
  return $postParam("/api/admin/basic/clazz/query", datas);
};
export const deleteClazz = (idList) => {
  return $postParam("/api/admin/basic/clazz/delete_batch", { idList });
};
export const updateClazz = (datas) => {
  return $post("/api/admin/basic/clazz/save", datas);
};
export const clazzQuery = (datas) => {
  return $postParam("/api/admin/basic/clazz/datasource", datas);
};

// flow-manage
export const flowListPage = (datas) => {
  return $postParam("/api/admin/custom/flow/list", datas);
};
export const flowEnd = (flowId) => {
  return $post("/api/admin/custom/flow/end", { flowId });
};
export const flowDelete = ({ id, enable }) => {
  return $post("/api/admin/custom/flow/enable", { id, enable });
};
export const updateFlowName = (datas) => {
  return $post("/api/admin/custom/flow/rename", datas);
};
export const updateFlowDetail = (datas) => {
  return $post("/api/admin/custom/flow/save", datas);
};
export const flowDetail = (id) => {
  return $postParam("/api/admin/custom/flow/edit", { id });
};
export const flowDetailByType = (type = "ELECTRON_FLOW") => {
  return $postParam("/api/admin/custom/flow/get_flow_info_by_type", {
    type,
  });
};
export const flowDetailByFlowId = (flowId) => {
  return $postParam("/api/admin/custom/flow/get_flow_info_by_type", {
    flowId,
  });
};
export const taskFlowDetail = (flowId) => {
  return $postParam("/api/admin/custom/flow/view", { flowId });
};
export const taskFlowNodeInfo = (taskId) => {
  return $postParam("/api/admin/custom/flow/task/info", { taskId });
};
export const taskFlowApproverExchange = ({ taskId, userId }) => {
  return $postParam("/api/admin/custom/flow/task/approver/exchange", {
    taskId,
    userId,
  });
};
export const taskFlowApprover = (datas) => {
  return $post("/api/admin/custom/flow/task/approve", datas);
};
// approve-record
export const approveRecordListPage = (datas) => {
  return $postParam("/api/admin/custom/flow/approve/list", datas);
};
export const deleteApproveRecord = (datas) => {
  return $post("/api/admin/custom/flow/approve/enable", datas);
};

// dict --------------------------------->
// student-manage
export const studentListQuery = (datas) => {
  return $postParam("/api/admin/basic/student/query", datas);
};
export const deleteStudent = (idList) => {
  return $postParam("/api/admin/basic/student/delete_batch", { idList });
};
export const deleteFilterStudent = (datas) => {
  return $postParam("/api/admin/basic/student/delete_by_condition", datas);
};
export const updateStudent = (datas) => {
  return $post("/api/admin/basic/student/save", datas);
};

// semester-manage
export const semesterListQuery = (datas) => {
  return $postParam("/api/admin/basic/semester/query", datas);
};
export const examSemesterList = (datas) => {
  return $postParam("/api/admin/basic/semester/list", datas);
};
export const ableSemester = ({ id, enable }) => {
  return $post("/api/admin/basic/semester/enable", { id, enable });
};
export const deleteSemester = (id) => {
  return $postParam("/api/admin/basic/semester/delete", { id });
};
export const updateSemester = (datas) => {
  return $post("/api/admin/basic/semester/save", datas);
};
export const semesterSetInUsed = (id) => {
  return $postParam("/api/admin/basic/semester/set_in_used", { id });
};
// major-manage
export const majorListQuery = (datas) => {
  return $postParam("/api/admin/basic/major/query", datas);
};
export const deleteMajor = (idList) => {
  return $postParam("/api/admin/basic/major/delete", { idList });
};
export const updateMajor = (datas) => {
  return $post("/api/admin/basic/major/save", datas);
};
// college-manage
export const collegeListQuery = (datas) => {
  return $postParam("/api/admin/basic/college/query", datas);
};
export const deleteCollege = (idList) => {
  return $postParam("/api/admin/basic/college/delete", { idList });
};
export const updateCollege = (datas) => {
  return $post("/api/admin/basic/college/save", datas);
};

// other --------------------------------->
// print-plan-push-manage
export const printPlanPushListQuery = (datas) => {
  return $postParam("/api/admin/exam/print_sync/list_sync", datas);
};
export const printPlanBatchPush = (list) => {
  return $post("/api/admin/exam/print_sync/sync_data_cloud_batch", {
    list,
  });
};
export const printPlanPush = ({ printPlanId, thirdRelateId }) => {
  return $postParam("/api/admin/exam/print_sync/sync_data_cloud", {
    printPlanId,
    thirdRelateId,
  });
};
export const printPlanMergePush = (datas) => {
  return $post("/api/admin/exam/print_sync/sync_data_merge", datas);
};
export const printPlanSyncExamList = () => {
  return $post("/api/admin/exam/print_sync/list_relate_ids", {});
};
export const printPlanCheckSyncMode = (datas) => {
  return $post("/api/admin/exam/print_sync/check_sync_mode", datas);
};
// new
export const printPlanSyncRelateExamList = (datas = {}) => {
  return $postParam("/api/admin/basic/stmms_exam/sync", datas);
};
export const printPlanRelateExamList = (datas = {}) => {
  return $postParam("/api/admin/basic/stmms_exam/list", datas);
};
export const printPlanCourseRelateList = (datas) => {
  return $postParam("/api/admin/exam/print_sync/list_sync_exam_task", datas);
};
export const printPlanSyncStmms = (datas) => {
  return $post("/api/admin/exam/print_sync/sync_data_cloud", datas);
};
// sms-manage
export const smsListQuery = (datas) => {
  return $postParam("/api/admin/basic/message/list", datas);
};
export const smsTypes = () => {
  return $postParam("/api/admin/basic/message/list_message_types", {});
};
export const resendSms = (id) => {
  return $postParam("/api/admin/basic/message/resend", { id });
};

// exam-manage
export const examQuery = (datas) => {
  return $postParam("/api/admin/basic/exam/query", datas);
};
export const examListQuery = (datas) => {
  return $postParam("/api/admin/basic/exam/page", datas);
};
export const deleteExam = (id) => {
  return $postParam("/api/admin/basic/exam/delete", { id });
};
export const updateExam = (datas) => {
  return $post("/api/admin/basic/exam/save", datas);
};
export const ableExam = ({ id, enable }) => {
  return $postParam("/api/admin/basic/exam/enable", { id, enable });
};

// exam-config
export const examConfigQuery = (datas) => {
  return $postParam("/api/admin/basic/print_config/page", datas);
};
export const deleteExamConfig = (idList) => {
  return $postParam("/api/admin/basic/print_config/delete_batch", {
    idList,
  });
};
export const updateExamConfig = (datas) => {
  return $post("/api/admin/basic/print_config/save", datas);
};
export const ableExamConfig = ({ id, enable }) => {
  return $postParam("/api/admin/basic/print_config/enable", { id, enable });
};
export const examConfigByExamIdOrgId = (datas) => {
  return $postParam(
    "/api/admin/basic/print_config/get_by_exam_id_and_org_id",
    datas
  );
};
export const listOrgsByExamId = ({ id, examId }) => {
  return $postParam("/api/admin/basic/print_config/list_org_id_by_exam_id", {
    id,
    examId,
  });
};
// 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 });
};

// simple --------------->
// course-simple-manage
export const courseSimpleListPage = (datas) => {
  return $postParam("/api/admin/teach/course/page", datas);
};
export const courseSimpleQuery = (datas) => {
  return $postParam("/api/admin/teach/course/find_basic_course", datas);
};
export const deleteCourseSimple = (idList) => {
  return $postParam("/api/admin/teach/course/delete", { idList });
};
export const updateCourseSimple = (datas) => {
  return $post("/api/admin/teach/course/manual_create", datas);
};
export const batchAddCourseSimple = (datas) => {
  return $post("/api/admin/teach/course/select_create", datas);
};

// clazz-simple-manage
export const clazzSimpleListPage = (datas) => {
  return $postParam("/api/admin/teach/clazz/page", datas);
};
export const clazzTeachCourseQuery = (datas) => {
  return $postParam("/api/admin/teach/clazz/find_teach_course", datas);
};
export const deleteClazzSimple = (idList) => {
  return $postParam("/api/admin/teach/clazz/delete", { idList });
};
export const updateClazzSimple = (datas) => {
  return $post("/api/admin/teach/clazz/edit", datas);
};
export const basicTeachClazzListPage = (datas) => {
  return $postParam("/api/admin/basic/condition/list_basic_teach_clazz", datas);
};

// student-simple-manage
export const studentSimpleListQuery = (datas) => {
  return $postParam("/api/admin/teach/student/page", datas);
};
export const deleteStudentSimple = (idList) => {
  return $postParam("/api/admin/teach/student/delete", { idList });
};
export const updateStudentSimple = (datas) => {
  return $post("/api/admin/teach/student/create", datas);
};
export const batchAddStudentSimple = (datas) => {
  return $post("/api/admin/teach/student/create_batch", datas);
};
export const exportStudent = (datas) => {
  return $postParam("/api/admin/basic/student/export", datas, {
    responseType: "blob",
  });
};

// teacher-simple-manage
export const teacherSimpleListQuery = (datas) => {
  return $postParam("/api/admin/teach/course/teacher_team_page", datas);
};
export const courseTeachTeacherQuery = (orgId) => {
  return $postParam("/api/admin/teach/course/find_teacher_by_org", { orgId });
};
export const deleteTeacherSimple = (idList) => {
  return $postParam("/api/admin/teach/course/delete", { idList });
};
export const updateTeacherSimple = (datas) => {
  return $post("/api/admin/teach/course/manual_create_teacher", datas);
};
export const batchAddTeacherSimple = (datas) => {
  return $postParam("/api/admin/teach/course/select_create_teacher", datas);
};
export const teacherSimpleCourseQuery = (datas) => {
  return $postParam("/api/admin/teach/course/find_clazz_list", datas);
};
export const teacherSimpleAssignCourse = (datas) => {
  return $post("/api/admin/teach/course/assign_clazz", datas);
};
// course-target-manage
export const courseTargetList = (datas) => {
  return $postParam("/api/admin/teach/course_target/list", datas);
};
export const updateCourseTarget = (datas) => {
  return $post("/api/admin/teach/course_target/save", datas);
};
export const deleteCourseTarget = (id) => {
  return $postParam("/api/admin/teach/course_target/delete", { id });
};
export const courseDimensionTree = (datas) => {
  return $postParam("/api/admin/teach/course_target/dimension_tree", datas);
};
export const courseWeightSettingStatus = (datas) => {
  return $postParam(
    "/api/admin/teach/course/find_course_weight_setting_status",
    datas
  );
};

// comment-evaluation-manage
export const courseEvaluationList = (datas) => {
  return $postParam("/api/admin/teach/course_evaluation/list", datas);
};
export const updateCourseEvaluation = (datas) => {
  return $post("/api/admin/teach/course_evaluation/save", datas);
};
export const deleteCourseEvaluation = (id) => {
  return $postParam("/api/admin/teach/course_evaluation/delete", { id });
};
// course-weight-manage
export const courseWeightDetail = (datas) => {
  return $postParam("/api/admin/teach/course_weight/find", datas);
};
export const courseWeightSave = (datas) => {
  return $post("/api/admin/teach/course_weight/save", datas);
};

// exam-student-manage
export const examStudentListPage = (datas) => {
  return $postParam("/api/admin/basic/exam_student/page", datas);
};
export const getExamStudentStatus = (idList) => {
  return $postParam("/api/admin/basic/exam_student/mark_status", { idList });
};
export const deleteExamStudent = (idList) => {
  return $postParam("/api/admin/basic/exam_student/delete", { idList });
};
export const updateExamStudent = (datas) => {
  return $post("/api/admin/basic/exam_student/save", datas);
};
export const updateExamStudentStatus = (datas) => {
  return $postParam("/api/admin/basic/exam_student/status", datas);
};
export const exportExamStudent = (datas) => {
  return $postParam("/api/admin/basic/exam_student/export", datas, {
    responseType: "blob",
  });
};

// 专业管理 ------------------->
export const professionalListPage = (datas) => {
  return $postParam("/api/admin/basic/professional/page", datas);
};
export const deleteProfessional = (id) => {
  return $postParam("/api/admin/basic/professional/remove", { id });
};
export const updateProfessional = (datas) => {
  return $post("/api/admin/basic/professional/save", datas);
};
