From d69a9a79a82c8a2f93efcd2b43b0a03ca57a031c Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期一, 08 七月 2024 17:37:19 +0800 Subject: [PATCH] 课目重构 --- src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java | 36 +++++++++++++++++++++++++++--------- 1 files changed, 27 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..c86f205 100644 --- a/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java +++ b/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java @@ -32,6 +32,7 @@ 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 lombok.RequiredArgsConstructor; @@ -39,6 +40,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; @@ -102,13 +104,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 +142,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 +301,11 @@ } @Override + public List<QuestionExportData> 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 +344,11 @@ return RestResponse.ok(null); } + @Override + public Integer countQuestionByTitle(String title) { + return questionMapper.countQuestionByTitle(title); + } + /** * 澶勭悊棰樼洰鍐呭JSON * -- Gitblit v1.8.0