| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | examPaper.setScore(new BigDecimal(form.getScore())); |
| | | //随机试卷 |
| | | if (ExamPaperTypeEnum.Random.getCode().equals(form.getPaperType())) { |
| | | //校验题目数量 |
| | | //校验标题是否填写、校验题目数量 |
| | | List<PaperQuestionSettingDTO> questionSetting = form.getQuestionSetting(); |
| | | for (PaperQuestionSettingDTO settingDTO : questionSetting) { |
| | | if(StringUtils.isEmpty(settingDTO.getTitle())){ |
| | | return Result.fail(SystemCode.InnerError.getCode(),"标题不能为空"); |
| | | } |
| | | Integer questionType = settingDTO.getQuestionType(); |
| | | for (PaperSettingItem item : settingDTO.getSettingList()) { |
| | | Integer num = item.getNum(); |
| | |
| | | return Result.ok(); |
| | | } else if (ExamPaperTypeEnum.Fixed.getCode().equals(form.getPaperType())) { |
| | | //固定试卷 |
| | | List<PaperFixQuestionDTO> questionTitleList = form.getQuestionTitleList(); |
| | | for (PaperFixQuestionDTO dto : questionTitleList) { |
| | | if(StringUtils.isEmpty(dto.getTitle())){ |
| | | return Result.fail(SystemCode.InnerError.getCode(),"标题不能为空"); |
| | | } |
| | | } |
| | | examPaper.setContent(JSON.toJSONString(form.getQuestionTitleList())); |
| | | baseMapper.insert(examPaper); |
| | | return Result.ok(); |
| | |
| | | List<PaperSettingItem> settingList = settingDTO.getSettingList(); |
| | | List<PaperQuestion> questionList = new ArrayList<>(); |
| | | for (PaperSettingItem item : settingList) { |
| | | if(StringUtils.isEmpty(settingDTO.getTitle())){ |
| | | return Result.fail(SystemCode.InnerError.getCode(),"标题不能为空"); |
| | | } |
| | | Integer num = item.getNum(); |
| | | Integer difficult = item.getDifficult(); |
| | | //需要配置的题目数量为0则跳过 |
| | |
| | | public List<ExamPaper> myExamPaper(Integer paperType) { |
| | | Integer userId = webContext.getCurrentUser().getId(); |
| | | List<ExamPaper> list = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .select(ExamPaper::getId, ExamPaper::getName, ExamPaper::getVisibility) |
| | | .select(ExamPaper::getId, ExamPaper::getName, ExamPaper::getVisibility,ExamPaper::getSuggestTime) |
| | | .eq(ExamPaper::getCreateUser, userId) |
| | | .eq(Objects.nonNull(paperType), ExamPaper::getPaperType, paperType) |
| | | .or() |
| | | .eq(ExamPaper::getVisibility, VisibilityEnum.Public.getName()) |
| | | .eq(Objects.nonNull(paperType), ExamPaper::getPaperType, paperType) |
| | | .orderByDesc(ExamPaper::getId) |
| | | .list(); |
| | | list.stream().forEach(item -> { |
| | | if (VisibilityEnum.Public.getName().equals(item.getVisibility())) { |
| | |
| | | // 查出所有的课目(excel下拉数据) |
| | | List<Subject> subjects = subjectService.list(); |
| | | List<String> subjectNameList = subjects.stream().map(Subject::getName).collect(Collectors.toList()); |
| | | |
| | | EasyExcel.write(response.getOutputStream(), ExamPaperImportVO.class) |
| | | .sheet("模板") |
| | | .registerWriteHandler(new PaperSelectExcel(subjectNameList)) |