| | |
| | | package com.mindskip.xzs.controller.student; |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.mindskip.xzs.base.BaseApiController; |
| | | import com.mindskip.xzs.base.RestResponse; |
| | | import com.mindskip.xzs.service.QuestionService; |
| | | import com.mindskip.xzs.service.SubjectService; |
| | | import com.mindskip.xzs.viewmodel.admin.question.ExamQuestionVO; |
| | | import com.mindskip.xzs.viewmodel.student.question.answer.QuestionAnswerVO; |
| | | import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentRequestVM; |
| | | import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentResponseVM; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | public class QuestionController extends BaseApiController { |
| | | |
| | | private final QuestionService questionService; |
| | | private final SubjectService subjectService; |
| | | |
| | | @Autowired |
| | | public QuestionController(QuestionService questionService) { |
| | | public QuestionController(QuestionService questionService, SubjectService subjectService) { |
| | | this.questionService = questionService; |
| | | this.subjectService = subjectService; |
| | | } |
| | | |
| | | @RequestMapping(value = "/select/question", method = RequestMethod.POST) |
| | | public RestResponse<PageInfo<QuestionPageStudentResponseVM>> selectQuestion(@RequestBody QuestionPageStudentRequestVM model) { |
| | | return RestResponse.ok(questionService.selectQuestion(model)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/select/question/{id}", method = RequestMethod.GET) |
| | | public RestResponse<QuestionAnswerVO> selectQuestionById(@PathVariable Integer id) { |
| | | QuestionAnswerVO vm = new QuestionAnswerVO(); |
| | | ExamQuestionVO question = questionService.getQuestionEditRequestVM(id); |
| | | vm.setQuestionVM(question); |
| | | return RestResponse.ok(vm); |
| | | } |
| | | |
| | | /** |
| | | * 查询题目内容 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/{id}") |
| | | public RestResponse getContentById(@PathVariable("id") Integer id) { |
| | | return questionService.selectContentById(id); |
| | | } |
| | | |
| | | /** |
| | | * 获取题目答案 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/answer/{id}") |
| | | public RestResponse getAnswer(@PathVariable("id") Integer id) { |
| | | return questionService.getAnswer(id); |
| | | } |
| | | |
| | | } |