| | |
| | | import com.mindskip.xzs.base.RestResponse; |
| | | import com.mindskip.xzs.domain.ExamPaper; |
| | | import com.mindskip.xzs.domain.ExamPaperSubject; |
| | | import com.mindskip.xzs.service.ExamPaperDepartmentService; |
| | | import com.mindskip.xzs.service.ExamPaperService; |
| | | import com.mindskip.xzs.service.ExamPaperSubjectService; |
| | | import com.mindskip.xzs.utility.DateTimeUtil; |
| | |
| | | |
| | | private final ExamPaperService examPaperService; |
| | | private final ExamPaperSubjectService examPaperSubjectService; |
| | | private final ExamPaperDepartmentService examPaperDepartmentService; |
| | | |
| | | @Autowired |
| | | public ExamPaperController(ExamPaperService examPaperService, ExamPaperSubjectService examPaperSubjectService) { |
| | | public ExamPaperController(ExamPaperService examPaperService, ExamPaperSubjectService examPaperSubjectService, ExamPaperDepartmentService examPaperDepartmentService) { |
| | | this.examPaperService = examPaperService; |
| | | this.examPaperSubjectService = examPaperSubjectService; |
| | | this.examPaperDepartmentService = examPaperDepartmentService; |
| | | } |
| | | |
| | | @RequestMapping(value = "/page", method = RequestMethod.POST) |
| | | public RestResponse<PageInfo<ExamResponseVM>> pageList(@RequestBody ExamPaperPageRequestVM model) { |
| | | model.setType("0"); |
| | | PageInfo<ExamPaper> pageInfo = examPaperService.page(model); |
| | | PageInfo<ExamResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamResponseVM vm = modelMapper.map(e, ExamResponseVM.class); |
| | |
| | | PageInfo<ExamResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamResponseVM vm = modelMapper.map(e, ExamResponseVM.class); |
| | | vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | Integer[] ids = examPaperSubjectService.getByExamPaperId(vm.getId()) |
| | | .stream().map(ExamPaperSubject::getSubjectId).toArray(Integer[]::new); |
| | | vm.setSubjectId(ids); |
| | | return vm; |
| | | }); |
| | | return RestResponse.ok(page); |
| | |
| | | |
| | | |
| | | @RequestMapping(value = "/edit", method = RequestMethod.POST) |
| | | public RestResponse<ExamPaperEditRequestVM> edit(@RequestBody @Valid ExamPaperEditRequestVM model) { |
| | | public RestResponse<ExamPaperEditRequestVM> edit(@RequestBody @Valid ExamPaperEditRequestVM model) throws Exception { |
| | | ExamPaper examPaper = examPaperService.savePaperFromVM(model, getCurrentUser()); |
| | | ExamPaperEditRequestVM newVM = examPaperService.examPaperToVM(examPaper.getId()); |
| | | return RestResponse.ok(newVM); |
| | |
| | | ExamPaper examPaper = examPaperService.selectById(id); |
| | | examPaper.setDeleted(true); |
| | | examPaperService.updateByIdFilter(examPaper); |
| | | examPaperDepartmentService.removeByExamPaperId(id); |
| | | examPaperSubjectService.removeByExamPaperId(id); |
| | | return RestResponse.ok(); |
| | | } |
| | | } |