|
@@ -584,14 +584,27 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
pageList = page(page, queryWrapper);
|
|
|
break;
|
|
|
}
|
|
|
- List<String> questionIds = pageList.getRecords().stream().map(Question::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //设置题目的答案
|
|
|
+ setQuestionAnswer(pageList.getRecords());
|
|
|
+ return pageList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置题目的答案
|
|
|
+ *
|
|
|
+ * @param questionList
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void setQuestionAnswer(List<Question> questionList) {
|
|
|
+ List<String> questionIds = questionList.stream().map(Question::getId).collect(Collectors.toList());
|
|
|
|
|
|
//获取题目答案
|
|
|
List<QuestionAnswer> answerList = questionAnswerService.listAnswerByQuestionIds(questionIds);
|
|
|
if (!CollectionUtils.isEmpty(answerList)) {
|
|
|
Map<String, List<QuestionAnswer>> answerMap = answerList.stream().collect(Collectors
|
|
|
.groupingBy(QuestionAnswer::getQuestionId, Collectors.toList()));
|
|
|
- pageList.getRecords().forEach(item -> {
|
|
|
+ questionList.forEach(item -> {
|
|
|
List<QuestionAnswer> answers = answerMap.get(item.getId());
|
|
|
if (!CollectionUtils.isEmpty(answers)) {
|
|
|
//答案排序
|
|
@@ -599,6 +612,5 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- return pageList;
|
|
|
}
|
|
|
}
|