import { $httpWithMsg } from "../../plugins/axios";
import { QUESTION_API } from "@/constants/constants";

// common select
export const courseQueryApi = (name, enable) => {
  return $httpWithMsg.get(`${QUESTION_API}/course/query`, {
    params: {
      name,
      enable: enable || undefined,
    },
  });
};

//  build paper
export const buildPaperApi = (datas, mode) => {
  return $httpWithMsg.post(`${QUESTION_API}/gen/paper/${mode}`, datas);
};
export const questionGroupStructListApi = (datas) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/gen/paper/auto/distribute`,
    {},
    { params: datas }
  );
};
// build-paper-simple
export const paperSimpleTypeDistributeApi = (courseId) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/gen/paper/simple/type/distribute`,
    {},
    { params: { courseId } }
  );
};
export const paperSimpleCountDistributeApi = (params) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/gen/paper/simple/count/distribute`,
    {},
    { params }
  );
};
// build-paper-auto:build-struct
export const autoBuildPaperStructPageListApi = (params) => {
  return $httpWithMsg.post(`${QUESTION_API}/auto/struct/page`, {}, { params });
};
export const autoBuildPaperStructSaveApi = (datas) => {
  return $httpWithMsg.post(`${QUESTION_API}/auto/struct/save`, datas);
};
export const autoBuildPaperStructDeleteApi = (idList) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/auto/struct/delete`,
    {},
    {
      params: { idList },
    }
  );
};

// edit paper
export const paperDetailInfoApi = ({ paperId, seqMode }) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/paper/data`,
    {},
    {
      params: { paperId, seqMode },
    }
  );
};
export const paperDetailApi = (paperId) => {
  return $httpWithMsg.get(`${QUESTION_API}/paper/${paperId}`, {});
};
export const paperSaveApi = (paper) => {
  return $httpWithMsg.post(`${QUESTION_API}/paper`, paper);
};
export const paperDeleteApi = (paperId) => {
  return $httpWithMsg.delete(`${QUESTION_API}/paper/${paperId}`, {});
};
export const paperQuestionSaveApi = (questionUnit) => {
  return $httpWithMsg.put(`${QUESTION_API}/paperDetailUnit`, questionUnit);
};
export const paperDetailAddQuestionApi = (
  paperId,
  paperDetailId,
  questions
) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/paper/selectQuestions/${paperId}/${paperDetailId}`,
    questions
  );
};

// paper-info
export const paperAuditInfoApi = ({ paperId, curPage, pageSize }) => {
  return $httpWithMsg.get(
    `${QUESTION_API}/paper/audit/page/${curPage}/${pageSize}`,
    {
      params: {
        paperId,
      },
    }
  );
};
export const paperBlueInfoApi = ({ paperId, coursePropertyId, rootOrgId }) => {
  return $httpWithMsg.get(`${QUESTION_API}/paper/blue`, {
    params: {
      id: paperId,
      coursePropertyId,
      rootOrgId,
    },
  });
};
export const paperQtypeInfoApi = ({ paperId, type }) => {
  return $httpWithMsg.get(`${QUESTION_API}/paper/question/type`, {
    params: {
      id: paperId,
      type,
    },
  });
};
export const paperBaseInfoApi = (paperId) => {
  return $httpWithMsg.get(`${QUESTION_API}/paper/basic/composition`, {
    params: {
      id: paperId,
    },
  });
};
export const paperDetailUpdateApi = (paperId, datas) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/updatePaperDetail/${paperId}`,
    datas
  );
};
export const paperDetailMoveApi = ({ paperId, detailId, vector }) => {
  return $httpWithMsg.put(
    `${QUESTION_API}/paperDetail/${paperId}/${detailId}/${vector}`,
    {}
  );
};
export const paperDetailDeleteApi = ({ paperId, detailId }) => {
  return $httpWithMsg.delete(
    `${QUESTION_API}/paperDetail/${paperId}/${detailId}`,
    {}
  );
};
export const paperQuestionMoveApi = ({ detailId, unitid, vector }) => {
  return $httpWithMsg.put(
    `${QUESTION_API}/paperDetailUnit/${detailId}/${unitid}/${vector}`,
    {}
  );
};
export const paperQuestionDeleteApi = (unitid) => {
  return $httpWithMsg.delete(`${QUESTION_API}/paperDetailUnit/${unitid}`, {});
};
export const paperQuestionUnitDeleteApi = ({ unitid, questionId }) => {
  return $httpWithMsg.delete(
    `${QUESTION_API}/paper/deleteQuestion/${unitid}/${questionId}`,
    {}
  );
};

// audit-paper
export const auditPaperWaitPageListApi = (datas) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/find_pending_trial_paper`,
    {},
    {
      params: datas,
    }
  );
};
export const auditPaperAuditedPageListApi = (datas) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/find_my_audit_paper`,
    {},
    {
      params: datas,
    }
  );
};
export const auditPaperApplyPageListApi = (datas) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/find_my_paper_status`,
    {},
    {
      params: datas,
    }
  );
};
export const auditPaperUnsubmitPageListApi = (datas) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/find_will_submit_paper`,
    {},
    {
      params: datas,
    }
  );
};

export const auditPaperApi = (datas) => {
  // auditResult,auditRemark,paperIds
  return $httpWithMsg.post(
    `${QUESTION_API}/paper/audit`,
    {},
    { params: datas }
  );
};
export const withdrawPaperApi = (paperIds) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/paper/withdraw`,
    {},
    { params: { paperIds } }
  );
};
export const submitPaperApi = (paperIds) => {
  return $httpWithMsg.post(
    `${QUESTION_API}/paper/submit`,
    {},
    { params: { paperIds } }
  );
};

// paper-recycle
export function paperRecycleListApi(data = {}) {
  return $httpWithMsg.post(
    `${QUESTION_API}/paper/recycle_find`,
    {},
    { params: data }
  );
}
export function recoverPaperApi(recycleParamList) {
  return $httpWithMsg.post(
    `${QUESTION_API}/paper/recycle_recover`,
    recycleParamList
  );
}
export function thoroughDeletePaperApi(recycleParamList) {
  return $httpWithMsg.post(
    `${QUESTION_API}/paper/recycle_clear`,
    recycleParamList
  );
}
export function clearPaperRecycleApi() {
  return $httpWithMsg.post(`${QUESTION_API}/paper/recycle_clear_all`, {});
}
