package com.ycl.jxkg.controller.student; import com.ycl.jxkg.base.BaseApiController; import com.ycl.jxkg.base.Result; import com.ycl.jxkg.domain.entity.ExamPaperScoreDetail; import com.ycl.jxkg.domain.entity.Subject; import com.ycl.jxkg.domain.question.QuestionObject; import com.ycl.jxkg.service.ExamPaperScoreDetailService; import com.ycl.jxkg.service.QuestionService; import com.ycl.jxkg.service.SubjectService; import com.ycl.jxkg.service.TextContentService; import com.ycl.jxkg.utils.DateTimeUtil; import com.ycl.jxkg.utils.HtmlUtil; import com.ycl.jxkg.utils.JsonUtil; import com.ycl.jxkg.utils.PageInfoHelper; import com.ycl.jxkg.domain.vo.admin.question.QuestionEditRequestVO; import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitItemVO; import com.ycl.jxkg.domain.vo.student.question.answer.QuestionAnswerVO; import com.ycl.jxkg.domain.vo.student.question.answer.QuestionPageStudentRequestVO; import com.ycl.jxkg.domain.vo.student.question.answer.QuestionPageStudentResponseVO; import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.*; @RequiredArgsConstructor @RestController("StudentQuestionAnswerController") @RequestMapping(value = "/api/student/question/answer") public class QuestionAnswerController extends BaseApiController { private final ExamPaperScoreDetailService examPaperScoreDetailService; private final QuestionService questionService; private final TextContentService textContentService; private final SubjectService subjectService; @RequestMapping(value = "/page", method = RequestMethod.POST) public Result> pageList(@RequestBody QuestionPageStudentRequestVO model) { model.setCreateUser(getCurrentUser().getId()); PageInfo pageInfo = examPaperScoreDetailService.studentPage(model); PageInfo page = PageInfoHelper.copyMap(pageInfo, q -> { Subject subject = subjectService.getById(q.getSubjectId()); QuestionPageStudentResponseVO vo = new QuestionPageStudentResponseVO(); BeanUtils.copyProperties(q, vo); vo.setCreateTime(DateTimeUtil.dateFormat(q.getCreateTime())); QuestionObject questionObject = JsonUtil.toJsonObject(q.getQuestionContent(), QuestionObject.class); String clearHtml = HtmlUtil.clear(questionObject.getTitleContent()); vo.setShortTitle(clearHtml); vo.setSubjectName(subject.getName()); return vo; }); return Result.ok(page); } @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) public Result select(@PathVariable Integer id) { QuestionAnswerVO vm = new QuestionAnswerVO(); ExamPaperScoreDetail examPaperScoreDetail = examPaperScoreDetailService.getById(id); ExamPaperSubmitItemVO questionAnswerVM = examPaperScoreDetailService.examPaperQuestionCustomerAnswerToVM(examPaperScoreDetail); QuestionEditRequestVO questionVM = questionService.getQuestionEditRequestVM(examPaperScoreDetail.getQuestionId()); vm.setQuestionVM(questionVM); vm.setQuestionAnswerVM(questionAnswerVM); return Result.ok(vm); } }