| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- import {axios} from "@/requests/axios.config";
- const prefix = "/courseWare";
- function createCourseWare(data) {
- return axios.post(`${prefix}/create`, data);
- }
- function setCanDownloadById(id, canDownload) {
- return axios.post(`${prefix}/setCanDownloadById`, null, {params: {id, canDownload}});
- }
- function uploadCourseWareFile(name, file) {
- let data = new FormData();
- data.append("name", name);
- data.append("file", file);
- return axios.post(`${prefix}/uploadCourseWareFile`, data);
- }
- function deleteCourseWare(id) {
- return axios.delete(`${prefix}/delete`, {params: {id}});
- }
- function getCourseWaresByCourseId(courseId) {
- return axios.get(`${prefix}/getCourseWaresByCourseId`, {params: {courseId}});
- }
- function getCourseWareById(id) {
- return axios.get(`${prefix}/getById`, {params: {id}});
- }
- function checkCourseWareNameUnique(courseId, name) {
- return axios.get(`${prefix}/checkName`, {params: {courseId, name}});
- }
- function changeCourseWareName(id, newName) {
- return axios.post(`${prefix}/changeCourseWareName`, null, {
- params: {
- id,
- newName,
- }
- });
- }
- function getCourseWareUrlById(id) {
- return axios.get(`${prefix}/getUrlById`, {params: {id}});
- }
- function getCourseIdById(id) {
- return axios.get(`${prefix}/getCourseIdById`, {params: {id}});
- }
- function previewpdf(fileUrl) {
- return axios({
- methods: "get",
- url: "/courseWare/readPdfFile",
- params: {
- fileUrl: fileUrl
- },
- responseType: "blob",
- headers:{
- "Content-Type": "application/json"
- }
- });
- }
- function getCanDownloadById(id) {
- return axios.get(`${prefix}/getCanDownloadById`, {params: {id}});
- }
- const courseWareAPIs = {
- createCourseWare,
- setCanDownloadById,
- deleteCourseWare,
- getCourseWaresByCourseId,
- getCourseWareById,
- uploadCourseWareFile,
- checkCourseWareNameUnique,
- changeCourseWareName,
- getCourseWareUrlById,
- previewpdf,
- getCourseIdById,
- getCanDownloadById
- };
- export default courseWareAPIs;
|