| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | * 条件查询错题 |
| | | * */ |
| | | @Override |
| | | public WrongResponseVO page(WrongRequestVo wrongRequestVo) { |
| | | public WrongResponseVO list(WrongRequestVo wrongRequestVo) { |
| | | WrongResponseVO wrongResponseVO = new WrongResponseVO(); |
| | | // 查询该用户的所有考试 |
| | | List<ExamPaperScore> examPaperScores = examPaperScoreMapper.selectByUserId(wrongRequestVo.getUserId()); |
| | |
| | | doQuestionVO.setExamId(examPaperScore.getExamId()); |
| | | doQuestionVO.setExamName(examPaperScore.getExamName()); |
| | | doQuestionVO.setTitle(question.getTitle()); |
| | | // 考试结果记录id |
| | | doQuestionVO.setId(examPaperScore.getId()); |
| | | return doQuestionVO; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | |
| | | List<DoQuestionVO> doQuestionVOS = questions.stream() |
| | | // 标题不为空或空字符串,模糊查询 |
| | | .filter(question -> { |
| | | if (wrongRequestVo.getTitle() == null || wrongRequestVo.getTitle().trim().equals("")) { |
| | | if (wrongRequestVo.getTitle() == null || wrongRequestVo.getTitle().trim().isEmpty()) { |
| | | return true; |
| | | } |
| | | return question.getTitle().toLowerCase().contains(wrongRequestVo.getTitle().toLowerCase()); |
| | | return Optional.ofNullable(question.getTitle()).orElse("").toLowerCase().contains(wrongRequestVo.getTitle().toLowerCase()); |
| | | }) |
| | | .filter(question -> { |
| | | if (wrongRequestVo.getQuestionType() == null) { |
| | |
| | | return question.getQuestionType().equals(wrongRequestVo.getQuestionType()); |
| | | }) |
| | | .filter(question -> { |
| | | if (wrongRequestVo.getExamName() == null || wrongRequestVo.getExamName().trim().equals("")) { |
| | | if (wrongRequestVo.getExamName() == null || wrongRequestVo.getExamName().trim().isEmpty()) { |
| | | return true; |
| | | } |
| | | return question.getExamName().toLowerCase().contains(wrongRequestVo.getExamName().toLowerCase()); |
| | | return Optional.ofNullable(question.getExamName()).orElse("").toLowerCase().contains(wrongRequestVo.getExamName().toLowerCase()); |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | // 分页 |
| | | List<DoQuestionVO> list = doQuestionVOS.stream().skip((wrongRequestVo.getPageIndex() - 1) * wrongRequestVo.getPageSize()).collect(Collectors.toList()); |
| | | List<DoQuestionVO> list = doQuestionVOS.stream().skip((wrongRequestVo.getPageIndex() - 1) * wrongRequestVo.getPageSize()).collect(Collectors.toList()).stream().limit(wrongRequestVo.getPageSize()).collect(Collectors.toList()); |
| | | wrongResponseVO.setList(list); |
| | | wrongResponseVO.setTotal(doQuestionVOS.size()); |
| | | wrongResponseVO.setPageSize(wrongRequestVo.getPageSize()); |