course.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import {axios} from "@/requests/axios.config";
  2. import courseSelectionAPIs from "@/api/course/courseSelection";
  3. const prefix = "/course";
  4. function createCourse(data) {
  5. console.log(data);
  6. return axios.post(`${prefix}/create`, data);
  7. }
  8. function getAllCourses() {
  9. return axios.get(`${prefix}/all`);
  10. }
  11. function getAllCoderCourses() {
  12. return axios.get(`${prefix}/coder_all`);
  13. }
  14. function getExampleCourses() {
  15. return axios.get(`${prefix}/example`);
  16. }
  17. function getTeacherCourses() {
  18. return axios.get(`${prefix}/teacher`);
  19. }
  20. function getStudentCourses() {
  21. return axios.get(`${prefix}/student`);
  22. }
  23. function getCourseById(id) {
  24. return axios.get(`${prefix}/getCourseById`, {
  25. params: {
  26. id
  27. },
  28. });
  29. }
  30. function updateCourse(data) {
  31. return axios.put(`${prefix}/update`, data);
  32. }
  33. function deleteCourse(courseId) {
  34. return axios.delete(`${prefix}/delete`, {
  35. params: {
  36. courseId,
  37. }
  38. });
  39. }
  40. function getCourseByCoderId(coderId) {
  41. return axios.get(`${prefix}/getCourseByCoderId`, {
  42. params: {
  43. coderId,
  44. }
  45. });
  46. }
  47. function getCourseByEvalId(evalId) {
  48. return axios.get(`${prefix}/getCourseByEvalId`, {
  49. params: {
  50. evalId,
  51. }
  52. });
  53. }
  54. function checkCourseNameUnique(id, name) {
  55. return axios.get(`${prefix}/checkName`, {
  56. params: {id, name}
  57. });
  58. }
  59. function checkCourseCodeUnique(id, code) {
  60. return axios.get(`${prefix}/checkCode`, {
  61. params: {id, code}
  62. });
  63. }
  64. function uploadCourseImage(name, image) {
  65. let data = new FormData();
  66. data.append("name", name);
  67. data.append("file", image);
  68. return axios.post(`${prefix}/uploadImage`, data, {
  69. headers: {
  70. "Content-Type": "multipart/form-data"
  71. }
  72. });
  73. }
  74. function uploadCarouselChart(input) {
  75. return axios.post(`${prefix}/uploadCarouseChart`, input);
  76. }
  77. function queryCarouselChart() {
  78. return axios.get(`${prefix}/queryCarouselChart`, {
  79. params: {}
  80. });
  81. }
  82. function findCourseByName(data) {
  83. return axios.get(`${prefix}/findCourseByName`, {
  84. params: {
  85. name: data,
  86. }
  87. });
  88. }
  89. const courseAPIs = {
  90. createCourse,
  91. getAllCourses,
  92. getAllCoderCourses,
  93. getTeacherCourses,
  94. getStudentCourses,
  95. getCourseById,
  96. deleteCourse,
  97. updateCourse,
  98. getExampleCourses,
  99. ...courseSelectionAPIs,
  100. getCourseByCoderId,
  101. checkCourseNameUnique,
  102. checkCourseCodeUnique,
  103. getCourseByEvalId,
  104. uploadCourseImage,
  105. uploadCarouselChart,
  106. queryCarouselChart,
  107. findCourseByName,
  108. };
  109. export default courseAPIs;