fuliqi
2024-06-28 16b4725365f3286c2d2a80945e26f35f89b53f24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.ycl.jxkg.controller.admin;
 
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.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.student.exampaper.ExamPaperAnswerExportVO;
import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO;
import com.ycl.jxkg.service.ExamPaperScoreService;
import com.ycl.jxkg.service.ExamPaperService;
import com.ycl.jxkg.utils.ExcelUtils;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
@RequiredArgsConstructor
@RestController("AdminExamPaperAnswerController")
@RequestMapping(value = "/api/admin/examPaperAnswer")
public class ExamPaperScoreController extends BaseApiController {
 
    private final ExamPaperScoreService examPaperScoreService;
    private final ExamPaperService examPaperService;
 
    @PostMapping("/pageExamPaper")
    public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageExamPaper(@RequestBody ExamPaperAnswerPageRequestVO model) {
        return Result.ok(examPaperScoreService.pageExamPaper(model));
    }
 
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageJudgeList(@RequestBody ExamPaperAnswerPageRequestVO model) {
        return Result.ok(examPaperScoreService.adminPage(model));
    }
 
    @RequestMapping(value = "/exportExcel", method = RequestMethod.POST)
    @SneakyThrows
    public void exportExcel(ExamPaperAnswerPageRequestVO model, HttpServletResponse response) {
        List<ExamPaperAnswerPageResponseVO> list = examPaperScoreService.list(model);
        ExcelUtils.exportExcelToTarget(response, "", "成绩列表", list, ExamPaperAnswerExportVO.class);
    }
 
    @PostMapping("/read/{id}")
    public Result<ExamPaperReadVO> 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);
    }
 
}