import { $get, $post, $del, $patch, $put } from "@/plugins/axios";

// login
export const login = datas => {
  return $post("/login", datas);
};
export const modifyPwd = datas => {
  return $post("/backend/sysuser/resetPwd", datas);
};
export const resetPwd = datas => {
  return $post("/backend/sysuser/resetPwd", datas);
};

// work-manage
export const workList = () => {
  return $get("/api/admin/works", {});
};
export const createWork = datas => {
  return $post("/api/admin/works", datas);
};
export const activeWork = workId => {
  return $patch(`/api/admin/works/${workId}`, {});
};
export const deleteWork = workId => {
  return $del(`/api/admin/works/${workId}`, {});
};

// work-overview
export const workOverviewDetail = workId => {
  return $get(`/api/admin/works/${workId}/overview`, {});
};

// paper-manage
export const paperPageList = datas => {
  return $get("/api/papers/listByQuestion", datas);
};
export const rotatePaper = (imageId, degree) => {
  return $get(`/api/images/${imageId}/rotate`, { degree });
};
export const absentPaper = imageId => {
  return $post(`/api/score/missing/${imageId}`, {});
};

// client-monitor
export const clientMonitorList = datas => {
  // return $get("/api/papers/listByQuestion", datas);
  return Promise.resolve(datas);
};

// student-manage
export const studentPageList = datas => {
  return $get("/api/students", datas);
};
export const uploadStudent = datas => {
  if (datas.id) {
    return $put(`/api/students/${datas.id}`, datas);
  } else {
    return $post(`/api/students`, datas);
  }
};
export const deleteStudent = studentId => {
  return $del(`/api/students/${studentId}`, {});
};

// client-set -------------------------->
// client-user-set
export const clientUserPageList = datas => {
  return $get("/api/admin/users/collect", datas);
};
export const uploadClientUser = datas => {
  if (datas.id) {
    return $put(`/api/admin/users/collect/${datas.id}`, datas);
  } else {
    return $post("/api/admin/users/collect", datas);
  }
};
export const deleteClientUser = userId => {
  return $del(`/api/admin/users/collect/${userId}`, {});
};
// inspection-user-set  TODO:换成真是的账号
export const inspectionUserPageList = datas => {
  return $get("/api/admin/users/collect", datas);
};
export const uploadInspectionUser = datas => {
  if (datas.id) {
    return $put(`/api/admin/users/collect/${datas.id}`, datas);
  } else {
    return $post("/api/admin/users/collect", datas);
  }
};
export const deleteInspectionUser = userId => {
  return $del(`/api/admin/users/collect/${userId}`, {});
};
// client-param-set -------------------------->
// subject-set
export const subjectList = datas => {
  // return $get("/api/admin/subjects", datas);
  return Promise.resolve(datas);
};
export const subjectDetail = subjectId => {
  // return $get("/api/admin/subjects", datas);
  return Promise.resolve({ id: subjectId, name: "素描" });
};
export const uploadSubject = datas => {
  if (datas.id) {
    return $put(`/api/admin/subject/${datas.id}`, datas);
  } else {
    return $post("/api/admin/subject", datas);
  }
};
export const deleteSubject = subjectId => {
  return $del(`/api/admin/subject/${subjectId}`, {});
};

// grading-set -------------------------->
// grading-level-set
export const levelList = workId => {
  return $get(`/api/admin/works/${workId}`, {});
};
export const uploadLevel = datas => {
  return $put(`/api/admin/works/${datas.id}`, datas);
};
// grading-rule-set
export const gradingRuleDetail = workId => {
  // TODO:
  return Promise.resolve({});
  // return $get(`/api/admin/works/${workId}`, {});
};
export const saveGradingRule = datas => {
  // TODO:
  return $post(`/api/admin/works/${datas.id}`, datas);
};
// upload-paper
// grading-rule-set
export const uploadPaperDetail = () => {
  // TODO:
  return Promise.resolve({});
  // return $get(`/api/admin/works/${workId}`, {});
};

// mark-set -------------------------->
// mark-rule-set
export const markRuleDetail = workId => {
  // TODO:
  return Promise.resolve({});
  // return $get(`/api/admin/works/${workId}`, {});
};
export const saveMarkRule = datas => {
  // TODO:
  return $post(`/api/admin/works/${datas.id}`, datas);
};

// quality-analysis -------------------------->
export const qualityAnalysisDetail = datas => {
  // TODO:
  return Promise.resolve(datas);
  // return $get(`/api/admin/works/${workId}`, {});
};

// student-score -------------------------->
export const studentScoreList = datas => {
  // TODO:
  return Promise.resolve(datas);
  // return $get(`/api/admin/works/${workId}`, {});
};

// grading -------------------------->
// grading-user-manage
export const gradingUserList = datas => {
  return $get("/api/admin/users", datas);
};
export const uploadGradingUser = datas => {
  if (datas.id) {
    return $put(`/api/admin/users/${datas.id}`, datas);
    // TODO:跟新之后没有返回任何东西，需要改一下
  } else {
    return $post("/api/admin/users", datas);
  }
};
export const deleteGradingUser = userId => {
  return $del(`/api/admin/users/${userId}`);
};
// grading-group-manage
export const gradingGroupList = subjectId => {
  return $get(`/api/marksubjects/${subjectId}/markergroups`, {});
};
export const updateGradingGroup = (subjectId, datas) => {
  if (datas.groupId) {
    return $patch(
      `/api/marksubjects/${subjectId}/markergroups/${datas.groupId}`,
      datas
    );
  } else {
    return $post(`/api/marksubjects/${subjectId}/markergroups`, datas);
  }
};
export const deleteGradingGroup = (subjectId, groupId) => {
  return $del(`/api/marksubjects/${subjectId}/markergroups/${groupId}`);
};
export const markUserList = ({ workId, subjectId }) => {
  return $get("/api/markers", { workId, subject: subjectId });
};
// grading-progress
export const gradingProgressDetail = subjectId => {
  // TODO:
  return $get(`/api/marksubjects/${subjectId}/markergroups`, {});
};
export const createTryGradingTask = datas => {
  // TODO:
  return $post(`/api/marksubjects/${datas.subjectId}/markergroups`, datas);
};
export const createGradingTask = datas => {
  // TODO:
  return $post(`/api/marksubjects/${datas.subjectId}/markergroups`, datas);
};

// mark -------------------------->
// mark-progress
export const markProgressDetail = subjectId => {
  // TODO:
  return $get(`/api/marksubjects/${subjectId}/markergroups`, {});
};

// mark-task-manage
export const markTaskInfo = subjectId => {
  // TODO:
  return $get(`/api/marksubjects/${subjectId}/markergroups`, {});
};
export const createMarkTask = (subjectId, datas) => {
  // TODO:
  return $post(`/api/marksubjects/${subjectId}/markergroups`, datas);
};

// inspection -------------------------->
// inspection-log
export const inspectionActionLogPageList = datas => {
  // TODO:
  return $get(`/api/marklog/selectMarkLog`, datas);
};
export const inspectionCollectLogPageList = datas => {
  // TODO:
  return $get(`/api/marklog/selectCollectMarkLog`, datas);
};
export const inspectionCheckGradePageList = datas => {
  // TODO:
  return $get(`/api/marklog/selectCollectMarkLog`, datas);
};
export const inspectionConfirmCheckGrade = datas => {
  // TODO:
  return $post(`/api/marklog/selectCollectMarkLog`, datas);
};
