| | |
| | | package com.ycl.jxkg.controller.student; |
| | | |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.RestResponse; |
| | | import com.ycl.jxkg.domain.ExamPaper; |
| | | import com.ycl.jxkg.service.ExamPaperAnswerService; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.entity.ExamPaper; |
| | | import com.ycl.jxkg.service.ExamPaperScoreService; |
| | | 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.ExamPaperEditRequestVM; |
| | | import com.ycl.jxkg.viewmodel.student.exam.ExamPaperPageResponseVM; |
| | | import com.ycl.jxkg.viewmodel.student.exam.ExamPaperPageVM; |
| | | import com.ycl.jxkg.utils.DateTimeUtil; |
| | | import com.ycl.jxkg.utils.PageInfoHelper; |
| | | import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperEditRequestVO; |
| | | import com.ycl.jxkg.domain.vo.student.exam.ExamPaperPageResponseVO; |
| | | import com.ycl.jxkg.domain.vo.student.exam.ExamPaperPageVO; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | |
| | | @RequiredArgsConstructor |
| | | @RestController("StudentExamPaperController") |
| | | @RequestMapping(value = "/api/student/exam/paper") |
| | | public class ExamPaperController extends BaseApiController { |
| | | |
| | | private final ExamPaperService examPaperService; |
| | | private final ExamPaperAnswerService examPaperAnswerService; |
| | | private final ExamPaperScoreService examPaperScoreService; |
| | | private final ApplicationEventPublisher eventPublisher; |
| | | |
| | | @Autowired |
| | | public ExamPaperController(ExamPaperService examPaperService, ExamPaperAnswerService examPaperAnswerService, ApplicationEventPublisher eventPublisher) { |
| | | this.examPaperService = examPaperService; |
| | | this.examPaperAnswerService = examPaperAnswerService; |
| | | this.eventPublisher = eventPublisher; |
| | | } |
| | | |
| | | |
| | | @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 = "/pageList", method = RequestMethod.POST) |
| | | public RestResponse<PageInfo<ExamPaperPageResponseVM>> pageList(@RequestBody @Valid ExamPaperPageVM model) { |
| | | public Result<PageInfo<ExamPaperPageResponseVO>> pageList(@RequestBody @Valid ExamPaperPageVO model) { |
| | | PageInfo<ExamPaper> pageInfo = examPaperService.studentPage(model); |
| | | PageInfo<ExamPaperPageResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamPaperPageResponseVM vm = modelMapper.map(e, ExamPaperPageResponseVM.class); |
| | | vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | return vm; |
| | | PageInfo<ExamPaperPageResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamPaperPageResponseVO vo = new ExamPaperPageResponseVO(); |
| | | BeanUtils.copyProperties(e, vo); |
| | | vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | return vo; |
| | | }); |
| | | return RestResponse.ok(page); |
| | | return Result.ok(page); |
| | | } |
| | | } |