From 13a68df58b3f937db5ba6437c814bafdcd8d37f8 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期一, 27 五月 2024 16:09:41 +0800
Subject: [PATCH] 登录时如果不是部门管理员则deptIds填充为用户所在部门

---
 src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 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..3e5ce6b 100644
--- a/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java
+++ b/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java
@@ -39,6 +39,7 @@
 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;
@@ -108,7 +109,9 @@
             deptQuestion.setDeptId(deptId);
             return deptQuestion;
         }).collect(Collectors.toList());
-        deptQuestionMapper.add(deptQuestions);
+        if (! CollectionUtils.isEmpty(model.getDeptIds())) {
+            deptQuestionMapper.add(deptQuestions);
+        }
 
         //鎵归噺娣诲姞
         List<QuestionSubject> list = Arrays.asList(model.getSubjectIds()).stream().map(e -> {
@@ -136,14 +139,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());

--
Gitblit v1.8.0