| | |
| | | package com.ycl.jxkg.controller.admin; |
| | | |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.RestResponse; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.ExamPaper; |
| | | import com.ycl.jxkg.service.ExamPaperService; |
| | | import com.ycl.jxkg.utility.DateTimeUtil; |
| | | import com.ycl.jxkg.utility.PageInfoHelper; |
| | | import com.ycl.jxkg.viewmodel.admin.exam.ExamPaperPageRequestVM; |
| | | import com.ycl.jxkg.viewmodel.admin.exam.ExamPaperEditRequestVM; |
| | | import com.ycl.jxkg.viewmodel.admin.exam.ExamResponseVM; |
| | | import com.ycl.jxkg.utils.DateTimeUtil; |
| | | import com.ycl.jxkg.utils.PageInfoHelper; |
| | | import com.ycl.jxkg.vo.admin.exam.ExamPaperPageRequestVO; |
| | | import com.ycl.jxkg.vo.admin.exam.ExamPaperEditRequestVO; |
| | | import com.ycl.jxkg.vo.admin.exam.ExamResponseVO; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/page", method = RequestMethod.POST) |
| | | public RestResponse<PageInfo<ExamResponseVM>> pageList(@RequestBody ExamPaperPageRequestVM model) { |
| | | public Result<PageInfo<ExamResponseVO>> pageList(@RequestBody ExamPaperPageRequestVO model) { |
| | | PageInfo<ExamPaper> pageInfo = examPaperService.page(model); |
| | | PageInfo<ExamResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamResponseVM vm = modelMapper.map(e, ExamResponseVM.class); |
| | | vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | return vm; |
| | | PageInfo<ExamResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamResponseVO vo = new ExamResponseVO(); |
| | | BeanUtils.copyProperties(e, vo); |
| | | vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | return vo; |
| | | }); |
| | | return RestResponse.ok(page); |
| | | return Result.ok(page); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/taskExamPage", method = RequestMethod.POST) |
| | | public RestResponse<PageInfo<ExamResponseVM>> taskExamPageList(@RequestBody ExamPaperPageRequestVM model) { |
| | | public Result<PageInfo<ExamResponseVO>> taskExamPageList(@RequestBody ExamPaperPageRequestVO model) { |
| | | PageInfo<ExamPaper> pageInfo = examPaperService.taskExamPage(model); |
| | | PageInfo<ExamResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamResponseVM vm = modelMapper.map(e, ExamResponseVM.class); |
| | | vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | return vm; |
| | | PageInfo<ExamResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamResponseVO vo = new ExamResponseVO(); |
| | | BeanUtils.copyProperties(e, vo); |
| | | vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | return vo; |
| | | }); |
| | | return RestResponse.ok(page); |
| | | return Result.ok(page); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/edit", method = RequestMethod.POST) |
| | | public RestResponse<ExamPaperEditRequestVM> edit(@RequestBody @Valid ExamPaperEditRequestVM model) { |
| | | public Result<ExamPaperEditRequestVO> edit(@RequestBody @Valid ExamPaperEditRequestVO model) { |
| | | ExamPaper examPaper = examPaperService.savePaperFromVM(model, getCurrentUser()); |
| | | ExamPaperEditRequestVM newVM = examPaperService.examPaperToVM(examPaper.getId()); |
| | | return RestResponse.ok(newVM); |
| | | ExamPaperEditRequestVO newVM = examPaperService.examPaperToVM(examPaper.getId()); |
| | | return Result.ok(newVM); |
| | | } |
| | | |
| | | @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) |
| | | public RestResponse<ExamPaperEditRequestVM> select(@PathVariable Integer id) { |
| | | ExamPaperEditRequestVM vm = examPaperService.examPaperToVM(id); |
| | | return RestResponse.ok(vm); |
| | | public Result<ExamPaperEditRequestVO> select(@PathVariable Integer id) { |
| | | ExamPaperEditRequestVO vm = examPaperService.examPaperToVM(id); |
| | | return Result.ok(vm); |
| | | } |
| | | |
| | | @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) |
| | | public RestResponse delete(@PathVariable Integer id) { |
| | | public Result delete(@PathVariable Integer id) { |
| | | ExamPaper examPaper = examPaperService.selectById(id); |
| | | examPaper.setDeleted(true); |
| | | examPaperService.updateByIdFilter(examPaper); |
| | | return RestResponse.ok(); |
| | | return Result.ok(); |
| | | } |
| | | } |