Browse Source

修改试题

tags/正式版本
雍文秀 2 years ago
parent
commit
a447ac95da

+ 19
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/service/question/QuestionService.java View File

@@ -52,6 +52,25 @@ public class QuestionService {
52 52
     //修改
53 53
     public Integer update(TQuestion model) {
54 54
         model.setCreatetime(N_Utils.getSecondTimestamp());
55
+        if (model.getQlevel() == 2) {
56
+            List<TQuestion> questions = model.getQuestions();
57
+            List<TQuestion> updateQuestions = new ArrayList<>();//要更新试题集合
58
+            List<TQuestion> addQuestions = new ArrayList<>();//要添加试题集合
59
+            for (TQuestion question : questions) {
60
+                if (N_Utils.isEmpty(question.getQuestionid())) {
61
+                    question.setQuestionid(StudyUtil.getId());
62
+                    question.setQuestionpid(model.getQuestionid());
63
+                    question.setCreatetime(N_Utils.getSecondTimestamp());
64
+                    question.setQstate(1);
65
+                    question.setHashear(0);
66
+                    addQuestions.add(question);
67
+                } else {
68
+                    updateQuestions.add(question);
69
+                }
70
+            }
71
+            if (N_Utils.isListNotEmpty(updateQuestions)) questionMapper.updateBatch(updateQuestions);
72
+            if (N_Utils.isListNotEmpty(addQuestions)) questionMapper.saveBathQuestion(addQuestions);
73
+        }
55 74
         return questionMapper.updateByPrimaryKeySelective(model);
56 75
     }
57 76
 

Loading…
Cancel
Save