| | |
| | | package com.ycl.jxkg.controller.admin; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.entity.ExamPaperScore; |
| | | import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperEditRequestVO; |
| | | import com.ycl.jxkg.domain.entity.User; |
| | | import com.ycl.jxkg.domain.vo.PaperFixQuestionVO; |
| | | import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperMarkNavbarVO; |
| | | import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperScoreVO; |
| | | import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperAnswerPageRequestVO; |
| | | import com.ycl.jxkg.domain.vo.student.exam.ExamPaperReadVO; |
| | | import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitVO; |
| | | import com.ycl.jxkg.domain.vo.admin.paper.UserAnswerPageRequestVO; |
| | | import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerExportVO; |
| | | import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO; |
| | | import com.ycl.jxkg.domain.vo.student.exampaper.UserAnswerPageResponseVO; |
| | | import com.ycl.jxkg.service.ExamPaperScoreService; |
| | | import com.ycl.jxkg.service.ExamPaperService; |
| | | import com.ycl.jxkg.service.UserService; |
| | | import com.ycl.jxkg.utils.ExcelUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author gonghl |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @RestController("AdminExamPaperAnswerController") |
| | | @RequestMapping(value = "/api/admin/examPaperAnswer") |
| | | public class ExamPaperScoreController extends BaseApiController { |
| | | |
| | | private final ExamPaperScoreService examPaperScoreService; |
| | | private final ExamPaperService examPaperService; |
| | | private final UserService userService; |
| | | |
| | | @PostMapping("/pageExamPaper") |
| | | public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageExamPaper(@RequestBody ExamPaperAnswerPageRequestVO model) { |
| | |
| | | return Result.ok(examPaperScoreService.adminPage(model)); |
| | | } |
| | | |
| | | @PostMapping("/pageUser") |
| | | public Result<PageInfo<UserAnswerPageResponseVO>> pageUser(@RequestBody UserAnswerPageRequestVO model) { |
| | | return Result.ok(examPaperScoreService.pageUser(model)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/exportExcel", method = RequestMethod.POST) |
| | | @SneakyThrows |
| | | public void exportExcel(ExamPaperAnswerPageRequestVO model, HttpServletResponse response) { |
| | |
| | | } |
| | | |
| | | @PostMapping("/read/{id}") |
| | | public Result<ExamPaperReadVO> read(@PathVariable Integer id) { |
| | | public Result<ExamPaperScoreVO> read(@PathVariable Integer id) { |
| | | ExamPaperScore examPaperScore = examPaperScoreService.getById(id); |
| | | ExamPaperReadVO vm = new ExamPaperReadVO(); |
| | | ExamPaperEditRequestVO paper = examPaperService.examPaperToVM(examPaperScore.getPaperId()); |
| | | ExamPaperSubmitVO answer = examPaperScoreService.examPaperAnswerToVM(examPaperScore.getId()); |
| | | vm.setPaper(paper); |
| | | vm.setAnswer(answer); |
| | | return Result.ok(vm); |
| | | ExamPaperScoreVO examPaperScoreVO = new ExamPaperScoreVO(); |
| | | BeanUtils.copyProperties(examPaperScore, examPaperScoreVO); |
| | | User user = userService.getById(examPaperScore.getUserId()); |
| | | examPaperScoreVO.setUserName(Objects.nonNull(user) ? user.getRealName() : "用户已注销"); |
| | | examPaperScoreVO.setNavbar(JSON.parseArray(examPaperScore.getNavbar(), ExamPaperMarkNavbarVO.class)); |
| | | examPaperScoreVO.setTitleItems(JSON.parseArray(examPaperScore.getPaperContent(), PaperFixQuestionVO.class)); |
| | | return Result.ok(examPaperScoreVO); |
| | | } |
| | | |
| | | } |