Просмотр исходного кода

fix: 安全性修复,部分查询接口采用token中的id而非前端传入的id

201250038 1 год назад
Родитель
Сommit
4720373104

+ 4 - 4
src/apis/course.ts

@@ -9,16 +9,16 @@ const courseApis = {
     createCourse(courseDTO: CourseDTO){
       return axiosInstance.post(`${COURSE_PREFIX}`, courseDTO)
     },
-    getCourseByStudentId(studentId: number, page: number=0, size: number=10){
-        return axiosInstance.get(`${COURSE_PREFIX}/byStudent/${studentId}`, {
+    getCourseByStudentId(page: number=0, size: number=10){
+        return axiosInstance.get(`${COURSE_PREFIX}/byStudent`, {
             params: {
                 page,
                 size
             }
         })
     },
-    getCourseByTeacherId(teacherId: number, page: number=0, size: number=10){
-        return axiosInstance.get(`${COURSE_PREFIX}/byTeacher/${teacherId}`, {
+    getCourseByTeacherId(page: number=0, size: number=10){
+        return axiosInstance.get(`${COURSE_PREFIX}/byTeacher`, {
             params: {
                 page,
                 size

+ 2 - 2
src/views/CourseSquare/component/AllCourse/MoreCourse.vue

@@ -205,7 +205,7 @@ const fetchAllCourse = () => {
 
 const fetchCourseByUserId = () => {
   if(role === 'student'){
-    apis.getCourseByStudentId(store.user.id, queryInfo.pageNow, queryInfo.pageSize)
+    apis.getCourseByStudentId(queryInfo.pageNow, queryInfo.pageSize)
         .then((res: any) => {
           console.log(res)
           pageInfo.courseData = res.data.data.records
@@ -218,7 +218,7 @@ const fetchCourseByUserId = () => {
         })
         .finally(() => {});
   } else if(role === "teachers"){
-    apis.getCourseByTeacherId(store.user.id, queryInfo.pageNow, queryInfo.pageSize)
+    apis.getCourseByTeacherId(queryInfo.pageNow, queryInfo.pageSize)
         .then((res: any) => {
           console.log(res.data.data)
           pageInfo.courseData = res.data.data.records

+ 2 - 2
src/views/CourseSquare/component/Course/index.vue

@@ -177,7 +177,7 @@
 
   const fetchCourseByUserId = () => {
     if(role === 'student'){
-      apis.getCourseByStudentId(store.user.id)
+      apis.getCourseByStudentId()
           .then((res: any) => {
             courses.course = res.data.data.records
             processCourses()
@@ -187,7 +187,7 @@
           })
           .finally(() => {});
     } else if(role === "teachers"){
-      apis.getCourseByTeacherId(store.user.id)
+      apis.getCourseByTeacherId()
           .then((res: any) => {
             courses.course = res.data.data.records
             processCourses()

+ 3 - 3
src/views/CourseSquare/component/CourseDetails/index.vue

@@ -376,7 +376,7 @@ const getHomeworkList = () => {
   学生,是否显示选课码输入框选课
  */
 const isShowCode = () => {
-  apis.getCourseByStudentId(store.user.id)
+  apis.getCourseByStudentId()
     .then((res: any) => {
       let data = res.data.data.records
       for(let i = 0 ; i < data.length; i++){
@@ -424,10 +424,10 @@ const enroll = () => {
   教师,是否显示编辑课程按钮
  */
 const isShowEdit = () => {
-  apis.getCourseByTeacherId(store.user.id)
+  apis.getCourseByTeacherId()
       .then((res: any) => {
         let total = res.data.data.total
-        apis.getCourseByTeacherId(store.user.id, 1, total)
+        apis.getCourseByTeacherId(1, total)
             .then((res: any) => {
               let data = res.data.data.records
               for(let i = 0 ; i < data.length; i++){

+ 4 - 4
src/views/HomeworkPage/index.vue

@@ -139,11 +139,11 @@
 
   const fetchData = () => {
     if (role === 'student') {
-      apis.getCourseByStudentId(store.user.id)
+      apis.getCourseByStudentId()
           .then((res: any) => {
             // 获取课程总数
             let total = res.data.data.total;
-            apis.getCourseByStudentId(store.user.id,1,total)
+            apis.getCourseByStudentId(1, total)
                 .then((res: any) => {
                   let data:CourseVO[] = res.data.data.records
                   for(let i = 0; i < data.length; i++){
@@ -152,11 +152,11 @@
                 })
           })
     } else if (role === "teachers") {
-      apis.getCourseByTeacherId(store.user.id)
+      apis.getCourseByTeacherId()
           .then((res: any) => {
             // 获取课程总数
             let total = res.data.data.total;
-            apis.getCourseByTeacherId(store.user.id,1,total)
+            apis.getCourseByTeacherId(1, total)
                 .then((res: any) => {
                   let data:CourseVO[] = res.data.data.records
                   for(let i = 0; i < data.length; i++){