| | |
| | | import com.mindskip.xzs.utility.DateTimeUtil; |
| | | import com.mindskip.xzs.utility.PageInfoHelper; |
| | | import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM; |
| | | import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVO; |
| | | import com.mindskip.xzs.viewmodel.student.exam.ExamPaperPageResponseVM; |
| | | import com.mindskip.xzs.viewmodel.student.exam.ExamPaperPageVM; |
| | | import com.github.pagehelper.PageInfo; |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 开始考试 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) |
| | | public RestResponse<ExamPaperEditRequestVM> select(@PathVariable Integer id) { |
| | | ExamPaperEditRequestVM vm = examPaperService.examPaperToVM(id); |
| | | return RestResponse.ok(vm); |
| | | public RestResponse<ExamPaperEditRequestVO> select(@PathVariable Integer id) { |
| | | return RestResponse.ok(examPaperService.examPaperToVM(id)); |
| | | } |
| | | |
| | | |
| | |
| | | PageInfo<ExamPaperPageResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | Integer[] ids = examPaperDepartmentService.getByExamPaperId(e.getId()) |
| | | .stream().map(ExamPaperDepartment::getDepartmentId).toArray(Integer[]::new); |
| | | Integer[] userExamPaperIds = examPaperUserService.getByExamPaperId(e.getId()) |
| | | .stream().map(ExamPaperUser::getUserId).toArray(Integer[]::new); |
| | | if (Arrays.asList(ids).contains(user.getUserLevel())) { |
| | | ExamPaperPageResponseVM vm = modelMapper.map(e, ExamPaperPageResponseVM.class); |
| | | vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | return vm; |
| | | } |
| | | if (Arrays.asList(userExamPaperIds).contains(user.getId())) { |
| | | ExamPaperPageResponseVM vm = modelMapper.map(e, ExamPaperPageResponseVM.class); |
| | | vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | return vm; |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/edit", method = RequestMethod.POST) |
| | | public RestResponse<ExamPaperEditRequestVM> edit(@RequestBody @Valid ExamPaperEditRequestVM model) throws Exception { |
| | | public RestResponse<ExamPaperEditRequestVO> edit(@RequestBody @Valid ExamPaperEditRequestVM model) throws Exception { |
| | | ExamPaperUser examPaperUser = new ExamPaperUser(); |
| | | User user = getCurrentUser(); |
| | | model.setDepartmentIds(new Integer[0]); |
| | |
| | | examPaperUser.setDeleted("0"); |
| | | examPaperUserService.add(examPaperUser); |
| | | |
| | | |
| | | ExamPaperEditRequestVM newVM = examPaperService.examPaperToVM(examPaper.getId()); |
| | | return RestResponse.ok(newVM); |
| | | return RestResponse.ok(examPaperService.examPaperToVM(examPaper.getId())); |
| | | } |
| | | } |