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