From 02ba23adb5897029dc898ae5e2549a3fab067a93 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 24 九月 2024 10:56:15 +0800
Subject: [PATCH] 学生查课目只查自己单位的

---
 src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
index efce24b..cb7c8be 100644
--- a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
+++ b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
@@ -279,7 +279,7 @@
 
     @Override
     public PageInfo<ExamPaperAnswer> adminPage(com.mindskip.xzs.viewmodel.admin.paper.ExamPaperAnswerPageRequestVM requestVM) {
-        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "user_score desc").doSelectPageInfo(() ->
+        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "create_time desc").doSelectPageInfo(() ->
                 examPaperAnswerMapper.adminPage(requestVM));
     }
 
@@ -404,22 +404,25 @@
     }
 
     @Override
-    public void maxGrade(ExamPaperAnswer examPaperAnswer) {
-        // 鑾峰彇鏌愪竴鍦鸿�冭瘯鐨勬渶楂樻垚缁�
+    public void maxGrade(ExamPaperAnswer examPaperAnswer, Integer templateId) {
+        // 鑾峰彇鏌愪竴鍦鸿�冭瘯鏇剧粡鐨勬渶楂樻垚缁�
         ExamPaperAnswer maxGrade;
         if (Objects.equals(examPaperAnswer.getPaperType(), 7)) {
-            maxGrade = examPaperAnswerMapper.getTemplateOtherExamAnswer(examPaperAnswer);
+            maxGrade = examPaperAnswerMapper.getTemplateOtherExamAnswer(examPaperAnswer, templateId);
         } else {
             maxGrade = examPaperAnswerMapper.getPaperOtherExamAnswer(examPaperAnswer);
         }
-        // 鏈涓嶆槸鏈�楂樺垎
-        if (!Objects.equals(maxGrade.getId(), examPaperAnswer.getId())) {
+        if (Objects.isNull(maxGrade)) {
+            return;
+        }
+        // 鏈鑰冭瘯鍒嗘暟涓嶅涔嬪墠锛屾湰娆℃棤鏁�
+        if (maxGrade.getUserScore() > examPaperAnswer.getUserScore()) {
             // 涔嬪墠鐨勬垚缁╂湁鏁�
             maxGrade.setInvalid(AnswerInvalidEnum.VALID);
-            examPaperAnswerMapper.updateByPrimaryKey(maxGrade);
+            examPaperAnswerMapper.updateByPrimaryKeySelective(maxGrade);
             // 鏈鐨勪笉鏄渶楂樺垎锛屾棤鏁�
             examPaperAnswer.setInvalid(AnswerInvalidEnum.INVALID);
-            examPaperAnswerMapper.updateByPrimaryKey(examPaperAnswer);
+            examPaperAnswerMapper.updateByPrimaryKeySelective(examPaperAnswer);
         }
     }
 

--
Gitblit v1.8.0