From 47cd9ecc0eff38ffe6b3b794b2bf197e958f4403 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 14 五月 2025 15:50:57 +0800
Subject: [PATCH] bug:学员有状态不能修改问题

---
 src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java |   42 +++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java
index 3c152c9..956e398 100644
--- a/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java
+++ b/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java
@@ -32,13 +32,16 @@
 import com.github.pagehelper.PageInfo;
 import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentRequestVM;
 import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentResponseVM;
+import com.mindskip.xzs.vo.QuestionExportData;
 import com.mindskip.xzs.vo.QuestionExportVO;
 import com.mindskip.xzs.vo.QuestionImportVO;
+import com.mindskip.xzs.vo.QuestionSubjectVO;
 import lombok.RequiredArgsConstructor;
 import org.modelmapper.ModelMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
 import java.util.Arrays;
@@ -102,13 +105,17 @@
         questionMapper.insertSelective(question);
 
         // 棰樼洰鎵�灞為儴闂ㄦ彃鍏�
-        List<DeptQuestion> deptQuestions = model.getDeptIds().stream().map(deptId -> {
-            DeptQuestion deptQuestion = new DeptQuestion();
-            deptQuestion.setQuestionId(question.getId());
-            deptQuestion.setDeptId(deptId);
-            return deptQuestion;
-        }).collect(Collectors.toList());
-        deptQuestionMapper.add(deptQuestions);
+        if (! CollectionUtils.isEmpty(model.getDeptIds())) {
+            List<DeptQuestion> deptQuestions = model.getDeptIds().stream().map(deptId -> {
+                DeptQuestion deptQuestion = new DeptQuestion();
+                deptQuestion.setQuestionId(question.getId());
+                deptQuestion.setDeptId(deptId);
+                return deptQuestion;
+            }).collect(Collectors.toList());
+            if (! CollectionUtils.isEmpty(model.getDeptIds())) {
+                deptQuestionMapper.add(deptQuestions);
+            }
+        }
 
         //鎵归噺娣诲姞
         List<QuestionSubject> list = Arrays.asList(model.getSubjectIds()).stream().map(e -> {
@@ -136,14 +143,16 @@
         questionMapper.updateByPrimaryKeySelective(question);
 
         // 澶勭悊棰樼洰鎵�灞為儴闂�
-        deptQuestionMapper.remove(question.getId(), model.getDeptIds());
+        deptQuestionMapper.remove(question.getId());
         List<DeptQuestion> deptQuestions = model.getDeptIds().stream().map(deptId -> {
             DeptQuestion deptQuestion = new DeptQuestion();
             deptQuestion.setQuestionId(question.getId());
             deptQuestion.setDeptId(deptId);
             return deptQuestion;
         }).collect(Collectors.toList());
-        deptQuestionMapper.add(deptQuestions);
+        if (! CollectionUtils.isEmpty(model.getDeptIds())) {
+            deptQuestionMapper.add(deptQuestions);
+        }
 
         //棰樺共銆佽В鏋愩�侀�夐」绛� 鏇存柊
         TextContent infoTextContent = textContentService.selectById(question.getInfoTextContentId());
@@ -293,6 +302,11 @@
     }
 
     @Override
+    public List<QuestionImportVO> exportData(QuestionExportVO query) {
+        return questionMapper.exportData(query);
+    }
+
+    @Override
     public PageInfo<QuestionPageStudentResponseVM> selectQuestion(QuestionPageStudentRequestVM model) {
         return PageHelper.startPage(model.getPageIndex(), model.getPageSize()).doSelectPageInfo(() ->
                 questionMapper.selectQuestion(model).stream().peek(
@@ -331,6 +345,16 @@
         return RestResponse.ok(null);
     }
 
+    @Override
+    public Integer countQuestionByTitle(String title) {
+        return questionMapper.countQuestionByTitle(title);
+    }
+
+    @Override
+    public List<QuestionSubjectVO> countQuestionByTitleAndSubject(String title, Integer subjectId) {
+        return questionMapper.countQuestionByTitleAndSubject(title, subjectId);
+    }
+
     /**
      * 澶勭悊棰樼洰鍐呭JSON
      *

--
Gitblit v1.8.0