| | |
| | | import com.ycl.jxkg.vo.student.question.answer.QuestionPageStudentRequestVO; |
| | | import com.ycl.jxkg.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 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<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()); |
| | | TextContent textContent = textContentService.getById(q.getQuestionTextContentId()); |
| | | QuestionObject questionObject = JsonUtil.toJsonObject(textContent.getContent(), QuestionObject.class); |
| | | String clearHtml = HtmlUtil.clear(questionObject.getTitleContent()); |
| | | vo.setShortTitle(clearHtml); |
| | |
| | | @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) |
| | | public Result<QuestionAnswerVO> select(@PathVariable Integer id) { |
| | | QuestionAnswerVO vm = new QuestionAnswerVO(); |
| | | ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer = examPaperQuestionCustomerAnswerService.selectById(id); |
| | | ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer = examPaperQuestionCustomerAnswerService.getById(id); |
| | | ExamPaperSubmitItemVO questionAnswerVM = examPaperQuestionCustomerAnswerService.examPaperQuestionCustomerAnswerToVM(examPaperQuestionCustomerAnswer); |
| | | QuestionEditRequestVO questionVM = questionService.getQuestionEditRequestVM(examPaperQuestionCustomerAnswer.getQuestionId()); |
| | | vm.setQuestionVM(questionVM); |