Przeglądaj źródła

空指针异常修复

yangfeng 2 lat temu
rodzic
commit
a5e206bb39

+ 8 - 6
web/src/main/java/com/yntravelsky/buss/exam/exam/service/impl/ExamServiceImpl.java

@@ -301,12 +301,14 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
                         || userExamQuestion.getQuestionType().intValue() == QuestionType.MULTI.getCode()
                         || userExamQuestion.getQuestionType().intValue() == QuestionType.JUDGE.getCode()) {
                     String answer = userExamQuestion.getAnswer();
-                    List<QuestionAnswer> answerList = userExamQuestion.getQuestion().getAnswerList();
-                    if (StringUtils.isNotBlank(answer)) {
-                        List<String> answers = Arrays.asList(answer.split(","));
-                        List<QuestionAnswer> resultAnswerList = answerList.stream().filter(item -> answers.contains(item.getId())).collect(Collectors.toList());
-                        List<String> tagList = resultAnswerList.stream().map(QuestionAnswer::getTag).collect(Collectors.toList());
-                        userExamQuestion.setAnswer(String.join(",", tagList.stream().sorted().collect(Collectors.toList())));
+                    if (!Objects.isNull(userExamQuestion.getQuestion())) {
+                        List<QuestionAnswer> answerList = userExamQuestion.getQuestion().getAnswerList();
+                        if (StringUtils.isNotBlank(answer) && !CollectionUtils.isEmpty(answerList)) {
+                            List<String> answers = Arrays.asList(answer.split(","));
+                            List<QuestionAnswer> resultAnswerList = answerList.stream().filter(item -> answers.contains(item.getId())).collect(Collectors.toList());
+                            List<String> tagList = resultAnswerList.stream().map(QuestionAnswer::getTag).collect(Collectors.toList());
+                            userExamQuestion.setAnswer(String.join(",", tagList.stream().sorted().collect(Collectors.toList())));
+                        }
                     }
                 }
             });

+ 1 - 1
web/src/main/java/com/yntravelsky/buss/exam/userexamresult/mapper/xml/UserExamResultMapper.xml

@@ -7,7 +7,7 @@
                 u.*,
                 e.title as examTitle
         FROM user_exam_result u
-        LEFT JOIN exam e on u.exam_id = e.id
+        INNER JOIN exam e on u.exam_id = e.id
         <where>
             <if test="userExamResult.examTitle != null and userExamResult.examTitle != ''">
                 AND e.title like concat('%', #{userExamResult.examTitle}, '%')