import { httpApp } from "@/plugins/axiosIndex"; import { pickBy } from "lodash-es"; import { object2QueryString } from "@/utils/utils"; export function searchCourses({ id = "", examId = "", code = "", hasPaper = "", pageNumber = 1, pageSize = 10, }) { const data = pickBy( { id, examId, code, hasPaper, pageNumber, pageSize }, (v) => v !== "" ); if (data.examId || data.id) return httpApp.post( "/api/admin/exam/course/query?" + object2QueryString(data) ); } export function searchPapers({ examId = "", courseCode = "" }) { const data = pickBy({ examId, courseCode }, (v) => v !== ""); return httpApp.post( "/api/admin/exam/paper/query?" + object2QueryString(data) ); } export function saveCourse({ examId = "", courseCode = "", objectiveShuffle = "", optionShuffle = "", }) { const data = pickBy( { examId, courseCode, objectiveShuffle, optionShuffle, }, (v) => v !== "" ); return httpApp.post("/api/admin/exam/course/save", data); } export function savePaper({ id = "", weight = "", audioPlayCount = "" }) { const data = pickBy( { id, weight, audioPlayCount, }, (v) => v !== "" ); return httpApp.post("/api/admin/exam/paper/save", data); } /** * * @param {Object[]} papers * @param {String} papers.id * @param {Number} papers.weight * @param {Number} papers.audioPlayCount */ export function savePapers(papers) { return httpApp.post("/api/admin/exam/paper/save", papers); }