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

fix: eval接口更新,按课程排序

mjh 4 лет назад
Родитель
Сommit
4653644f0e

+ 2 - 2
src/api/announcement.js

@@ -30,8 +30,8 @@ function getUnreadAnnouncements() {
   return axios.get(`${prefix}/getUnreadByUserId`);
 }
 
-function readAnnouncement(data) {
-  return axios.put(`${prefix}/read`, data);
+function readAnnouncement(id) {
+  return axios.put(`${prefix}/read`, {id});
 }
 
 const announcementAPIs = {

+ 7 - 2
src/api/eval.js

@@ -18,10 +18,14 @@ function getStudentEvalExams({pageSize, pageNum, state}) {
     params: {pageSize, pageNum, state,}});
 }
 
-function getExampleEvalExams() {
+function getRecommendEvalExams() {
   return axios.get(`${prefix}/exam/recommend`);
 }
 
+function getRecommendEvalExamsGroupByCourse(){
+  return axios.get(`${prefix}/exam/recommend/groupByCourse`);
+}
+
 function getTeacherEvalExamsByCourseId(courseId) {
   return axios.get(`${prefix}/exam/teacher/course`, {
     params: {
@@ -42,7 +46,8 @@ const evalAPIs = {
   getAllEvalExams,
   getTeacherEvalExams,
   getStudentEvalExams,
-  getExampleEvalExams,
+  getRecommendEvalExams,
+  getRecommendEvalExamsGroupByCourse,
   getTeacherEvalExamsByCourseId,
   getStudentEvalExamsByCourseId,
 };

+ 12 - 2
src/api/message.js

@@ -5,8 +5,8 @@ const prefix = "/message";
 function getUnreadMessages(period) {
   if (period === undefined) {
     return axios.get(`${prefix}/getUnread`);
-  }else{
-    return axios.get(`${prefix}/getUnread`, {params:{day: period}});
+  } else {
+    return axios.get(`${prefix}/getUnread`, {params: {day: period}});
   }
 }
 
@@ -26,12 +26,22 @@ function getCommentsByCourseId(courseId) {
   return axios.get(`${prefix}/getByCourseId`, {params: {courseId}});
 }
 
+function getViewByMessage(id) {
+  return axios.get(`${prefix}/getView`, {params: {id}});
+}
+
+function readMessage(id) {
+  return axios.put(`${prefix}/read`, {id});
+}
+
 const messageAPIs = {
   getUnreadMessages,
   createMessage,
   updateMessage,
   getCommentsByCourseId,
   deleteMessage,
+  getViewByMessage,
+  readMessage,
 };
 
 export default messageAPIs;

+ 8 - 4
src/views/CoursePage/CourseDetail.vue

@@ -365,9 +365,13 @@ export default {
     },
   },
   mounted() {
-    if (this.$route.params.jump_from_message === "1") {
-      this.tabName = "comment";
-      this.switchTab(this.tabName);
+    switch (this.$route.params.jump_from_message) {
+      case "1":
+        this.tabName = "notice";
+        break;
+      case "2":
+        this.tabName = "comment";
+        break;
     }
     this.$apis.getCourseById(this.$route.params.id)
       .then(res => {
@@ -597,7 +601,7 @@ export default {
     },
     readAnnouncement(item) {
       if (!item.read) {
-        this.$apis.readAnnouncement({id: item.id})
+        this.$apis.readAnnouncement(item.id)
           .then(res => {
             item.read = true;
             this.$refs["noticeItem" + item.id][0].setNoticeInfo(item);

+ 7 - 6
src/views/MessagePage/components/MessageCard.vue

@@ -41,11 +41,11 @@
 </template>
 
 <script>
-import { ArrowRightBold } from "@element-plus/icons-vue";
+import {ArrowRightBold} from "@element-plus/icons-vue";
 
 export default {
   name: "MessageCard",
-  components: { ArrowRightBold },
+  components: {ArrowRightBold},
   props: {
     messageVO: {
       type: Object
@@ -85,12 +85,13 @@ export default {
   },
 
   methods: {
-    jump() {
+    async jump() {
       if (this.messageVO.courseId) {
-        this.$router.push({ name: "CourseDetail", params: { jump_from_message: "1", id: this.messageVO.courseId } });
+        this.$router.push({name: "CourseDetail", params: {jump_from_message: "1", id: this.messageVO.courseId}});
       } else {
-        // todo @mjh
-        alert("todo@mjh,跳转回复所在目标课程页");
+        const viewInfo = (await this.$apis.getViewByMessage(this.messageVO.id)).data.data;
+        await this.$apis.readMessage(this.messageVO.id);
+        this.$router.push({name: "CourseDetail", params: {jump_from_message: "2", id: viewInfo["course"]}});
       }
     }
   }

+ 1 - 2
src/views/PortalPage/PortalPage.vue

@@ -199,7 +199,6 @@ export default {
           let b_time = b.startAt * 1000 || new Date(b.startTime).getTime();
           return a_time - b_time;
         });
-      ;
     },
     showExampleCourseList() {
       return this.exampleCourseList.slice((this.showCourseList_current - 1) * 6, this.showCourseList_current * 6);
@@ -223,7 +222,7 @@ export default {
     const that = this;
 
     this.exampleCourseList = (await this.$apis.getExampleCourses()).data.data;
-    this.exampleEvalTestList = (await this.$apis.getExampleEvalExams()).data.data;
+    this.exampleEvalTestList = (await this.$apis.getRecommendEvalExams()).data.data;
     this.exampleCoderTestList = (await this.$apis.getExampleCoderExams({})).data.data.res.filter(i => this.state(i) === "RUNNING");
 
     if (this.isLogin && this.isStudent) {

+ 3 - 2
src/views/TestPage/TestPage.vue

@@ -101,8 +101,9 @@ export default {
     },
   },
   mounted() {
-    this.$apis.getAllEvalExams().then(res => {
-      this.evalExamList = res.data.data["examVOList"];
+    this.$apis.getRecommendEvalExamsGroupByCourse().then(res => {
+      this.evalExamList = res.data.data;
+      console.log(this.evalExamList);
     });
     // this.$apis.getAllCoderExams().then(res => {
     //   this.coderExamList = res.data.data.res;