From 12b7bf2629926c8acbd451f48aa815a2fb59fa50 Mon Sep 17 00:00:00 2001
From: luohairen <3399054449@qq.com>
Date: 星期三, 13 十一月 2024 11:51:17 +0800
Subject: [PATCH] 优化错题详情

---
 src/main/java/com/ycl/jxkg/service/impl/WrongServiceImpl.java |   48 +++++++++++++++---------------------------------
 1 files changed, 15 insertions(+), 33 deletions(-)

diff --git a/src/main/java/com/ycl/jxkg/service/impl/WrongServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/WrongServiceImpl.java
index aaa7bb6..03736e3 100644
--- a/src/main/java/com/ycl/jxkg/service/impl/WrongServiceImpl.java
+++ b/src/main/java/com/ycl/jxkg/service/impl/WrongServiceImpl.java
@@ -1,21 +1,30 @@
 package com.ycl.jxkg.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.ycl.jxkg.domain.entity.ExamPaperScore;
 import com.ycl.jxkg.domain.entity.Question;
+import com.ycl.jxkg.domain.entity.QuestionAnswerRecord;
 import com.ycl.jxkg.domain.vo.DoQuestionVO;
 import com.ycl.jxkg.domain.vo.PaperFixQuestionVO;
+import com.ycl.jxkg.domain.vo.student.wrong.WrongPageVo;
 import com.ycl.jxkg.domain.vo.student.wrong.WrongRequestVo;
+import com.ycl.jxkg.domain.vo.student.wrong.WrongResponseVO;
 import com.ycl.jxkg.mapper.ExamPaperScoreMapper;
+import com.ycl.jxkg.mapper.QuestionAnswerRecordMapper;
 import com.ycl.jxkg.mapper.QuestionMapper;
 import com.ycl.jxkg.service.WrongService;
 import com.ycl.jxkg.utils.JsonUtil;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 @Service
@@ -26,45 +35,18 @@
     private ExamPaperScoreMapper examPaperScoreMapper;
     @Autowired
     private QuestionMapper questionMapper;
+    @Autowired
+    private QuestionAnswerRecordMapper questionAnswerRecordMapper;
 
 
 
     /**
-     * 鍒嗛〉鏉′欢鏌ヨ閿欓
+     * 鏉′欢鏌ヨ閿欓
      * */
     @Override
-    public List<DoQuestionVO> page(WrongRequestVo wrongRequestVo) {
-        // 鏌ヨ璇ョ敤鎴风殑鎵�鏈夐潪闅忔満璇曞嵎鍙婅瘯鍗烽敊棰�
-//        List<ExamPaperScore> examPaperScores = examPaperScoreMapper
-//                .selectList(new LambdaQueryChainWrapper<>(ExamPaperScore.class)
-//                        .eq(ExamPaperScore::getUserId,wrongRequestVo.getUserId()));
-        // 鏌ヨ璇ョ敤鎴风殑鎵�鏈夎�冭瘯
-        List<ExamPaperScore> examPaperScores = examPaperScoreMapper.selectByUserId(wrongRequestVo.getUserId());
-        List<PaperFixQuestionVO> paperList = new ArrayList<>();
-        List<DoQuestionVO> questions = new ArrayList<>();
-        // 閬嶅巻鎵�鏈夎�冭瘯鑾峰緱鑰冭瘯璇︽儏
-        examPaperScores.stream().forEach(examPaperScore -> {
-            try{
-                // 瑙f瀽json瀛楃涓�
-                List<PaperFixQuestionVO> paperFixQuestionVOS = JsonUtil.toJsonListObject(examPaperScore.getPaperContent(), PaperFixQuestionVO.class);
-                paperFixQuestionVOS.stream().forEach(paperFixQuestionVO -> {
-                    List<DoQuestionVO> doQuestionVOS = paperFixQuestionVO.getQuestionList().stream()
-                            .filter(doQuestionVO -> !doQuestionVO.getRight())
-                            .map(doQuestionVO -> {
-                                // 鏍规嵁id鏌ヨ棰樺共
-                                Question question = questionMapper.selectById(doQuestionVO.getId());
-                                doQuestionVO.setExamId(examPaperScore.getExamId());
-                                doQuestionVO.setExamName(examPaperScore.getExamName());
-                                doQuestionVO.setTitle(question.getTitle());
-                                return doQuestionVO;
-                            })
-                            .collect(Collectors.toList());
-                    questions.addAll(doQuestionVOS);
-                });
-            }catch (Exception e){
-                e.printStackTrace();
-            }
+    public PageInfo<WrongResponseVO> list(WrongRequestVo wrongRequestVo) {
+        return PageHelper.startPage(wrongRequestVo.getPageIndex(), wrongRequestVo.getPageSize()).doSelectPageInfo(() -> {
+            questionAnswerRecordMapper.selectWrongQuestion(wrongRequestVo);
         });
-        return questions;
     }
 }

--
Gitblit v1.8.0