| | |
| | | import com.mindskip.xzs.domain.TextContent; |
| | | import com.mindskip.xzs.domain.enums.QuestionTypeEnum; |
| | | import com.mindskip.xzs.domain.question.QuestionObject; |
| | | import com.mindskip.xzs.domain.vo.ExamVO; |
| | | import com.mindskip.xzs.service.QuestionService; |
| | | import com.mindskip.xzs.service.TextContentService; |
| | | import com.mindskip.xzs.repository.DepartmentMapper; |
| | | import com.mindskip.xzs.repository.SubjectMapper; |
| | | import com.mindskip.xzs.service.*; |
| | | import com.mindskip.xzs.utility.*; |
| | | import com.mindskip.xzs.utility.convert.QuestionClassConvert; |
| | | import com.mindskip.xzs.utility.excel.ExcelUtils; |
| | | import com.mindskip.xzs.viewmodel.admin.education.SubjectPageRequestVM; |
| | | import com.mindskip.xzs.viewmodel.admin.question.*; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | private final QuestionService questionService; |
| | | private final TextContentService textContentService; |
| | | |
| | | private final SubjectMapper subjectMapper; |
| | | |
| | | private final DepartmentMapper departmentMapper; |
| | | |
| | | private final QuestionSubjectService questionSubjectService; |
| | | |
| | | @Autowired |
| | | public QuestionController(QuestionService questionService, TextContentService textContentService) { |
| | | public QuestionController(QuestionService questionService, TextContentService textContentService, SubjectMapper subjectMapper, DepartmentMapper departmentMapper, QuestionSubjectService questionSubjectService) { |
| | | this.questionService = questionService; |
| | | this.textContentService = textContentService; |
| | | this.subjectMapper = subjectMapper; |
| | | this.departmentMapper = departmentMapper; |
| | | this.questionSubjectService = questionSubjectService; |
| | | } |
| | | |
| | | @RequestMapping(value = "/page", method = RequestMethod.POST) |
| | |
| | | QuestionObject questionObject = JsonUtil.toJsonObject(textContent.getContent(), QuestionObject.class); |
| | | String clearHtml = HtmlUtil.clear(questionObject.getTitleContent()); |
| | | vm.setShortTitle(clearHtml); |
| | | vm.setQuestionSubjects(questionSubjectService.getQuestion(vm.getId()).stream().map(e -> { |
| | | SubjectPageRequestVM subjectPageRequestVM = new SubjectPageRequestVM(); |
| | | subjectPageRequestVM.setId(e.getSubjectId()); |
| | | e.setSubName(subjectMapper.page(subjectPageRequestVM).get(0).getName()); |
| | | return e; |
| | | }).collect(Collectors.toList())); |
| | | return vm; |
| | | }); |
| | | return RestResponse.ok(page); |
| | |
| | | |
| | | @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) |
| | | public RestResponse delete(@PathVariable Integer id) { |
| | | Question question = questionService.selectById(id); |
| | | question.setDeleted(true); |
| | | questionService.updateByIdFilter(question); |
| | | return RestResponse.ok(); |
| | | return RestResponse.ok(questionService.remove(id)); |
| | | } |
| | | |
| | | private RestResponse validQuestionEditRequestVM(QuestionEditRequestVM model) { |
| | |
| | | |
| | | @PostMapping("/import") |
| | | public void importUser(@RequestPart("file") MultipartFile file) throws Exception { |
| | | List<QuestionEditVO> questionEditVOS = ExcelUtils.readMultipartFile(file, QuestionEditVO.class); |
| | | List<QuestionEditVO> questionEditVOS = ExcelUtils.readMultipartFile(file, QuestionEditVO.class) |
| | | .stream().map(e -> { |
| | | e.setQuestionType(QuestionTypeEnum.get(e.getType())); |
| | | e.setSubjectId(subjectMapper.getName(e.getSubjectName()).getId()); |
| | | e.setGradeLevel(departmentMapper.getName(e.getDepartment()).getId()); |
| | | return e; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | List<QuestionEditRequestVM> list = QuestionClassConvert.INSTANCE.QuestionEditVOListToQuestionEditRequestVMList(questionEditVOS); |
| | | |