| | |
| | | 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; |
| | |
| | | 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 -> { |
| | |
| | | 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()); |
| | |
| | | } |
| | | |
| | | @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( |
| | |
| | | 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 |
| | | * |