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

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