| | |
| | | |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.ExamPaperQuestionCustomerAnswer; |
| | | import com.ycl.jxkg.domain.Subject; |
| | | import com.ycl.jxkg.domain.TextContent; |
| | | 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.ExamPaperQuestionCustomerAnswerService; |
| | | 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.HtmlUtil; |
| | | import com.ycl.jxkg.utils.JsonUtil; |
| | | import com.ycl.jxkg.utils.PageInfoHelper; |
| | | import com.ycl.jxkg.vo.admin.question.QuestionEditRequestVO; |
| | | import com.ycl.jxkg.vo.student.exam.ExamPaperSubmitItemVO; |
| | | import com.ycl.jxkg.vo.student.question.answer.QuestionAnswerVO; |
| | | import com.ycl.jxkg.vo.student.question.answer.QuestionPageStudentRequestVO; |
| | | import com.ycl.jxkg.vo.student.question.answer.QuestionPageStudentResponseVO; |
| | | 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.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | @RequiredArgsConstructor |
| | | @RestController("StudentQuestionAnswerController") |
| | | @RequestMapping(value = "/api/student/question/answer") |
| | | public class QuestionAnswerController extends BaseApiController { |
| | | |
| | | private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService; |
| | | private final ExamPaperScoreDetailService examPaperScoreDetailService; |
| | | private final QuestionService questionService; |
| | | private final TextContentService textContentService; |
| | | private final SubjectService subjectService; |
| | | |
| | | @Autowired |
| | | public QuestionAnswerController(ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService, QuestionService questionService, TextContentService textContentService, SubjectService subjectService) { |
| | | this.examPaperQuestionCustomerAnswerService = examPaperQuestionCustomerAnswerService; |
| | | this.questionService = questionService; |
| | | this.textContentService = textContentService; |
| | | this.subjectService = subjectService; |
| | | } |
| | | |
| | | @RequestMapping(value = "/page", method = RequestMethod.POST) |
| | | public Result<PageInfo<QuestionPageStudentResponseVO>> pageList(@RequestBody QuestionPageStudentRequestVO model) { |
| | | model.setCreateUser(getCurrentUser().getId()); |
| | | PageInfo<ExamPaperQuestionCustomerAnswer> pageInfo = examPaperQuestionCustomerAnswerService.studentPage(model); |
| | | PageInfo<ExamPaperScoreDetail> pageInfo = examPaperScoreDetailService.studentPage(model); |
| | | PageInfo<QuestionPageStudentResponseVO> page = PageInfoHelper.copyMap(pageInfo, q -> { |
| | | Subject subject = subjectService.selectById(q.getSubjectId()); |
| | | Subject subject = subjectService.getById(q.getSubjectId()); |
| | | QuestionPageStudentResponseVO vo = new QuestionPageStudentResponseVO(); |
| | | BeanUtils.copyProperties(q, vo); |
| | | vo.setCreateTime(DateTimeUtil.dateFormat(q.getCreateTime())); |
| | | TextContent textContent = textContentService.selectById(q.getQuestionTextContentId()); |
| | | QuestionObject questionObject = JsonUtil.toJsonObject(textContent.getContent(), QuestionObject.class); |
| | | QuestionObject questionObject = JsonUtil.toJsonObject(q.getQuestionContent(), QuestionObject.class); |
| | | String clearHtml = HtmlUtil.clear(questionObject.getTitleContent()); |
| | | vo.setShortTitle(clearHtml); |
| | | vo.setSubjectName(subject.getName()); |
| | |
| | | @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) |
| | | public Result<QuestionAnswerVO> select(@PathVariable Integer id) { |
| | | QuestionAnswerVO vm = new QuestionAnswerVO(); |
| | | ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer = examPaperQuestionCustomerAnswerService.selectById(id); |
| | | ExamPaperSubmitItemVO questionAnswerVM = examPaperQuestionCustomerAnswerService.examPaperQuestionCustomerAnswerToVM(examPaperQuestionCustomerAnswer); |
| | | QuestionEditRequestVO questionVM = questionService.getQuestionEditRequestVM(examPaperQuestionCustomerAnswer.getQuestionId()); |
| | | 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); |