From cd59ededbf05a0ae73b8f4944fbf40a1fb01d28a Mon Sep 17 00:00:00 2001 From: luohairen <3399054449@qq.com> Date: 星期一, 11 十一月 2024 18:03:43 +0800 Subject: [PATCH] 错题详情 --- src/main/java/com/ycl/jxkg/service/impl/WrongServiceImpl.java | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 40 insertions(+), 9 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..5640104 100644 --- a/src/main/java/com/ycl/jxkg/service/impl/WrongServiceImpl.java +++ b/src/main/java/com/ycl/jxkg/service/impl/WrongServiceImpl.java @@ -1,10 +1,13 @@ package com.ycl.jxkg.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ycl.jxkg.domain.entity.ExamPaperScore; import com.ycl.jxkg.domain.entity.Question; 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.QuestionMapper; import com.ycl.jxkg.service.WrongService; @@ -30,17 +33,13 @@ /** - * 鍒嗛〉鏉′欢鏌ヨ閿欓 + * 鏉′欢鏌ヨ閿欓 * */ @Override - public List<DoQuestionVO> page(WrongRequestVo wrongRequestVo) { - // 鏌ヨ璇ョ敤鎴风殑鎵�鏈夐潪闅忔満璇曞嵎鍙婅瘯鍗烽敊棰� -// List<ExamPaperScore> examPaperScores = examPaperScoreMapper -// .selectList(new LambdaQueryChainWrapper<>(ExamPaperScore.class) -// .eq(ExamPaperScore::getUserId,wrongRequestVo.getUserId())); + public WrongResponseVO page(WrongRequestVo wrongRequestVo) { + WrongResponseVO wrongResponseVO = new WrongResponseVO(); // 鏌ヨ璇ョ敤鎴风殑鎵�鏈夎�冭瘯 List<ExamPaperScore> examPaperScores = examPaperScoreMapper.selectByUserId(wrongRequestVo.getUserId()); - List<PaperFixQuestionVO> paperList = new ArrayList<>(); List<DoQuestionVO> questions = new ArrayList<>(); // 閬嶅巻鎵�鏈夎�冭瘯鑾峰緱鑰冭瘯璇︽儏 examPaperScores.stream().forEach(examPaperScore -> { @@ -52,10 +51,13 @@ .filter(doQuestionVO -> !doQuestionVO.getRight()) .map(doQuestionVO -> { // 鏍规嵁id鏌ヨ棰樺共 - Question question = questionMapper.selectById(doQuestionVO.getId()); + Question question = questionMapper.selectOne(new LambdaQueryWrapper<>(Question.class).eq(Question::getId, doQuestionVO.getId())); +// Question question = questionMapper.selectById(doQuestionVO.getId()); doQuestionVO.setExamId(examPaperScore.getExamId()); doQuestionVO.setExamName(examPaperScore.getExamName()); doQuestionVO.setTitle(question.getTitle()); + // 鑰冭瘯缁撴灉璁板綍id + doQuestionVO.setId(examPaperScore.getId()); return doQuestionVO; }) .collect(Collectors.toList()); @@ -65,6 +67,35 @@ e.printStackTrace(); } }); - return questions; + // 鏉′欢鏌ヨ + // 瀵归泦鍚堜腑鐨勯鐩繘琛屾ā绯婃煡璇㈣繃婊� + List<DoQuestionVO> doQuestionVOS = questions.stream() + // 鏍囬涓嶄负绌烘垨绌哄瓧绗︿覆锛屾ā绯婃煡璇� + .filter(question -> { + if (wrongRequestVo.getTitle() == null || wrongRequestVo.getTitle().trim().equals("")) { + return true; + } + return question.getTitle().toLowerCase().contains(wrongRequestVo.getTitle().toLowerCase()); + }) + .filter(question -> { + if (wrongRequestVo.getQuestionType() == null) { + return true; + } + return question.getQuestionType().equals(wrongRequestVo.getQuestionType()); + }) + .filter(question -> { + if (wrongRequestVo.getExamName() == null || wrongRequestVo.getExamName().trim().equals("")) { + return true; + } + return question.getExamName().toLowerCase().contains(wrongRequestVo.getExamName().toLowerCase()); + }) + .collect(Collectors.toList()); + // 鍒嗛〉 + List<DoQuestionVO> list = doQuestionVOS.stream().skip((wrongRequestVo.getPageIndex() - 1) * wrongRequestVo.getPageSize()).collect(Collectors.toList()); + wrongResponseVO.setList(list); + wrongResponseVO.setTotal(doQuestionVOS.size()); + wrongResponseVO.setPageSize(wrongRequestVo.getPageSize()); + wrongResponseVO.setPageIndex(wrongRequestVo.getPageIndex()); + return wrongResponseVO; } } -- Gitblit v1.8.0