| | |
| | | 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则跳过 |