course-file.js 989 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import axios from '@/plugins/axios'
  2. import { useCourseFileServer } from '@/config/server-info'
  3. export function uploadCourseFile ({ courseId, file }) {
  4. let data = new FormData()
  5. data.append('courseId', courseId)
  6. data.append('file', file)
  7. return axios
  8. .post(useCourseFileServer(), data, {
  9. headers: {
  10. 'Content-Type': 'multipart/form-data'
  11. }
  12. })
  13. .then(res => res.data)
  14. }
  15. export function deleteCourseFile ({ courseFileId }) {
  16. return axios
  17. .delete(useCourseFileServer('/' + courseFileId))
  18. .then(res => {})
  19. }
  20. export function getOneCourseFile ({ courseId, key = '', page = 1, size = 10, sort = '' }) {
  21. return axios
  22. .get(useCourseFileServer('/course/' + courseId), {
  23. params: {
  24. key,
  25. page,
  26. size,
  27. sort
  28. }
  29. })
  30. .then(res => res.data)
  31. }
  32. export function getCourseFileUrl ({ courseFileId }) {
  33. return axios
  34. .get(useCourseFileServer('/' + courseFileId + '/url'))
  35. .then(res => res.data)
  36. }