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

export const questionTeatherUserQuery = ({ courseCode, param }) => {
  return $postParam("/api/admin/sys/user/user_list", { courseCode, param });
};
export const unitQueryByType = (datas, dictionaryEnum) => {
  // dictionaryEnum: SEMESTER("学期"),COLLEGE("学院"),MAJOR("专业"),CLAZZ("班级"),STUDENT("学生")
  return $postParam("/api/admin/common/get_dictionary", {
    ...datas,
    dictionaryEnum
  });
};
export const enumsByType = type => {
  // type: PUSH_TYPE_ENUM("同步类型"),
  return $postParam("/api/admin/common/get_enums", {
    type
  });
};
// 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 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", {});
};

// 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
  });
};
// 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 = param => {
  return $postParam("/api/admin/basic/card_rule/query", { param });
};
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);
};
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 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 });
};
// 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 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);
};
// 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/create", 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);
};
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);
};

// 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);
};

// 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);
};

// 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 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", {});
};

// 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 = id => {
  return $postParam("/api/admin/basic/print_config/delete", { id });
};
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 });
};
