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

export const questionTeacherQueryApi = (name) => {
  return $httpWithMsg.get(`${QUESTION_API}/user/assignteacher/1/100`, {
    params: {
      name,
    },
  });
};
export const courseQueryApi = (name) => {
  return $httpWithMsg.get(QUESTION_API + "/course/query", {
    params: { name },
  });
};
// card-mamage
export const cardListApi = (datas) => {
  return $httpWithMsg.post(`${QUESTION_API}/card/page`, datas);
};
export const cardDeleteApi = (ids) => {
  return $httpWithMsg.post(
    QUESTION_API + "/card/delete",
    {},
    {
      params: { ids: ids.join() },
    }
  );
};
export const cardDownloadApi = (ids) => {
  return $httpWithMsg.get(QUESTION_API + "/card/download", {
    params: { ids: ids.join() },
    responseType: "blob",
  });
};
export const cardPackageDownloadApi = (ids) => {
  return $httpWithMsg.get(QUESTION_API + "/card/data/download", {
    params: { ids: ids.join() },
    responseType: "blob",
  });
};
export const cardEnableApi = ({ id, enable }) => {
  return $httpWithMsg.post(
    QUESTION_API + "/card/toggle",
    {},
    {
      params: { id, enable },
    }
  );
};
export const cardUpdateApi = (datas) => {
  return $httpWithMsg.post(QUESTION_API + "/card/edit", {}, { params: datas });
};
// card-head-manage
export const cardHeadListApi = (datas) => {
  return $httpWithMsg.post(`${QUESTION_API}/card/head/page`, datas);
};
export const cardHeadDeleteApi = (ids) => {
  return $httpWithMsg.post(
    QUESTION_API + "/card/head/delete",
    {},
    {
      params: { ids: ids.join() },
    }
  );
};
export const cardHeadDetailApi = (cardHeadId) => {
  return $httpWithMsg.post(
    QUESTION_API + "/card/head/find",
    {},
    {
      params: { id: cardHeadId },
    }
  );
};
export const cardHeadUpdateApi = (datas) => {
  return $httpWithMsg.post(QUESTION_API + "/card/head/save", datas);
};
export const cardHeadEnableApi = ({ id, enable }) => {
  return $httpWithMsg.post(
    QUESTION_API + "/card/head/toggle",
    {},
    {
      params: { id, enable },
    }
  );
};
export const cardTemplateListApi = () => {
  return $httpWithMsg.post(QUESTION_API + "/card/template/list", {});
};

// card-edit
export const cardConfigInfos = () => {
  return $httpWithMsg.post(QUESTION_API + "/card/head/get", {});

  // return Promise.resolve({
  //   id: "173438690998091776",
  //   createId: "173437828976345088",
  //   createTime: 1632291806278,
  //   updateId: null,
  //   updateTime: 1632291806278,
  //   name: "测试题卡规则1-版头名称",
  //   cardTitle: "测试题卡规则1-题卡标题",
  //   attention:
  //     "测试题卡规则1-注意事项\n测试题卡规则1-注意事项\n测试题卡规则1-注意事项",
  //   objectiveAttention: "测试题卡规则1-客观题-注意事项",
  //   subjectiveAttention: "测试题卡规则1-主观题-注意事项",
  //   paperSize: "A3",
  //   cardTemplateId: "1",
  // });
};
export const cardTemplateDetail = (cardTemplateId) => {
  return $httpWithMsg.post(
    QUESTION_API + "/card/template/find",
    {},
    {
      params: { id: cardTemplateId },
    }
  );
};
export const cardDetail = (cardId) => {
  return $httpWithMsg.post(
    QUESTION_API + "/card/find",
    {},
    {
      params: { id: cardId },
    }
  );
};
export const cardDetailByPaperId = (paperId) => {
  return $httpWithMsg.post(
    QUESTION_API + "/card/paper",
    {},
    {
      params: { paperId },
    }
  );
};

export const saveCard = (datas) => {
  return $httpWithMsg.post(QUESTION_API + "/card/save/structure", datas);
};
export const saveCardByPaper = (datas) => {
  return $httpWithMsg.post(QUESTION_API + "/card/save/paper", datas);
};
export const paperDetailApi = (paperId) => {
  return $httpWithMsg.get(`${QUESTION_API}/paper/${paperId}`, {});
};
