qirong
2023-06-20 983a2d36e9d3ca4ff2da89bbaca687fc55e92610
src/main/java/com/mindskip/xzs/controller/admin/ExamPaperAnswerController.java
@@ -3,6 +3,7 @@
import com.mindskip.xzs.base.BaseApiController;
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.domain.ExamPaperAnswer;
import com.mindskip.xzs.domain.ExamPaperSubject;
import com.mindskip.xzs.domain.Subject;
import com.mindskip.xzs.domain.User;
import com.mindskip.xzs.service.*;
@@ -24,12 +25,14 @@
    private final ExamPaperAnswerService examPaperAnswerService;
    private final SubjectService subjectService;
    private final UserService userService;
    private final ExamPaperSubjectService examPaperSubjectService;
    @Autowired
    public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, SubjectService subjectService, UserService userService) {
    public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, SubjectService subjectService, UserService userService, ExamPaperSubjectService examPaperSubjectService) {
        this.examPaperAnswerService = examPaperAnswerService;
        this.subjectService = subjectService;
        this.userService = userService;
        this.examPaperSubjectService = examPaperSubjectService;
    }
@@ -43,12 +46,20 @@
            if (user == null) {
                return null;
            }
            Subject subject = subjectService.selectById(vm.getSubjectId());
//            Subject subject = subjectService.selectById(vm.getSubjectId());
            ExamPaperAnswer examPaperAnswer = examPaperAnswerService.getById(vm.getId());
            Integer[] ids = examPaperSubjectService.getByExamPaperId(examPaperAnswer.getExamPaperId())
                    .stream().map(ExamPaperSubject::getSubjectId).toArray(Integer[]::new);
            String name = "";
            if(ids.length>0){
                name = subjectService.selectByIds(ids)
                        .stream().map(Subject::getName).collect(Collectors.joining(","));
            }
            vm.setDoTime(ExamUtil.secondToVM(e.getDoTime()));
            vm.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore()));
            vm.setUserScore(ExamUtil.scoreToVM(e.getUserScore()));
            vm.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore()));
            vm.setSubjectName(subject.getName());
            vm.setSubjectName(name);
            vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
            vm.setUserName(user.getUserName());