QuestionController.java 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. package com.qxgmat.controller.api;
  2. import com.github.pagehelper.Page;
  3. import com.nuliji.tools.*;
  4. import com.qxgmat.data.dao.entity.ExercisePaper;
  5. import com.qxgmat.data.dao.entity.User;
  6. import com.qxgmat.data.dao.entity.UserClass;
  7. import com.qxgmat.data.relation.entity.UserHomeworkPreviewRelation;
  8. import com.qxgmat.dto.extend.UserHomeworkPreviewExtendDto;
  9. import com.qxgmat.dto.response.UserClassDetailDto;
  10. import com.qxgmat.help.ShiroHelp;
  11. import com.qxgmat.service.HomeworkPreviewService;
  12. import com.qxgmat.service.UserPaperService;
  13. import com.qxgmat.service.inline.*;
  14. import io.swagger.annotations.Api;
  15. import io.swagger.annotations.ApiOperation;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RequestMethod;
  19. import org.springframework.web.bind.annotation.RequestParam;
  20. import org.springframework.web.bind.annotation.RestController;
  21. import javax.servlet.http.HttpSession;
  22. import java.util.Collection;
  23. import java.util.List;
  24. import java.util.Map;
  25. @RestController
  26. @RequestMapping("/api/question")
  27. @Api(tags = "题目", description = "题目接口")
  28. public class QuestionController {
  29. @Autowired
  30. private ShiroHelp shiroHelp;
  31. @Autowired
  32. private QuestionNoService questionNoService;
  33. @Autowired
  34. private UserPaperService userPaperService;
  35. @Autowired
  36. private UserReportService userReportService;
  37. @Autowired
  38. private UserQuestionService userQuestionService;
  39. @Autowired
  40. private HomeworkPreviewService homeworkPreviewService;
  41. @Autowired
  42. private UserClassService userClassService;
  43. @RequestMapping(value = "/class/process", method = RequestMethod.GET)
  44. @ApiOperation(value = "获取课程进度", notes = "获取所有课程及状态进度", httpMethod = "GET")
  45. public Response<List<UserClassDetailDto>> classProcess() {
  46. User user = (User) shiroHelp.getLoginUser();
  47. List<UserClass> userClassList = userClassService.getByUser(user.getId());
  48. // 获取每个科目的最后3次作业
  49. Map<Object, Collection<UserHomeworkPreviewRelation>> previewMap = homeworkPreviewService.groupByCategory(user.getId(), 3);
  50. List<UserClassDetailDto> dtos = Transform.convert(userClassList, UserClassDetailDto.class);
  51. Transform.combine(dtos, previewMap, UserClassDetailDto.class, "moduleId", "previews", UserHomeworkPreviewExtendDto.class);
  52. return ResponseHelp.success(dtos);
  53. }
  54. @RequestMapping(value = "/preview/list", method = RequestMethod.GET)
  55. @ApiOperation(value = "获取预习作业列表", notes = "获取预习作业列表", httpMethod = "GET")
  56. public Response<PageMessage<UserHomeworkPreviewExtendDto>> listPreview(
  57. @RequestParam(required = false, defaultValue = "1") int page,
  58. @RequestParam(required = false, defaultValue = "100") int size,
  59. @RequestParam(required = false) Number category,
  60. @RequestParam(required = false) String endTime,
  61. @RequestParam(required = false) Boolean finish
  62. ) {
  63. User user = (User) shiroHelp.getLoginUser();
  64. PageResult<UserHomeworkPreviewRelation> p = homeworkPreviewService.list(page, size, category, user.getId(), endTime, finish);
  65. List<UserHomeworkPreviewExtendDto> pr = Transform.convert(p, UserHomeworkPreviewExtendDto.class);
  66. return ResponseHelp.success(pr, page, size, p.getTotal());
  67. }
  68. @RequestMapping(value = "/exercise/process", method = RequestMethod.GET)
  69. @ApiOperation(value = "练习进度", httpMethod = "GET")
  70. public Response<PageMessage<ExercisePaper>> exerciseProcess(
  71. @RequestParam(required = false, defaultValue = "1") int page,
  72. @RequestParam(required = false, defaultValue = "100") int size,
  73. HttpSession session) {
  74. Page<ExercisePaper> p=null;
  75. return ResponseHelp.success(p, page, size, p.getTotal());
  76. }
  77. @RequestMapping(value = "/exercise/paper", method = RequestMethod.GET)
  78. @ApiOperation(value = "练习组卷列表", httpMethod = "GET")
  79. public Response<PageMessage<ExercisePaper>> listExercisePaper(
  80. @RequestParam(required = false, defaultValue = "1") int page,
  81. @RequestParam(required = false, defaultValue = "100") int size,
  82. HttpSession session) {
  83. Page<ExercisePaper> p = null;
  84. return ResponseHelp.success(p, page, size, p.getTotal());
  85. }
  86. @RequestMapping(value = "/examination/process", method = RequestMethod.GET)
  87. @ApiOperation(value = "模考进度", httpMethod = "GET")
  88. public Response<PageMessage<ExercisePaper>> examinationProcess(
  89. @RequestParam(required = false, defaultValue = "1") int page,
  90. @RequestParam(required = false, defaultValue = "100") int size,
  91. HttpSession session) {
  92. Page<ExercisePaper> p=null;
  93. return ResponseHelp.success(p, page, size, p.getTotal());
  94. }
  95. @RequestMapping(value = "/examination/paper", method = RequestMethod.GET)
  96. @ApiOperation(value = "模考组卷列表", httpMethod = "GET")
  97. public Response<PageMessage<ExercisePaper>> examinationPaperList(
  98. @RequestParam(required = false, defaultValue = "1") int page,
  99. @RequestParam(required = false, defaultValue = "100") int size,
  100. HttpSession session) {
  101. Page<ExercisePaper> p = null;
  102. return ResponseHelp.success(p, page, size, p.getTotal());
  103. }
  104. @RequestMapping(value = "/detail", method = RequestMethod.GET)
  105. @ApiOperation(value = "获取题目详情", notes = "获取题目详情", httpMethod = "GET")
  106. public Response<User> detail(
  107. @RequestParam(required = false) String questionNoId
  108. ) {
  109. User user = (User) shiroHelp.getLoginUser();
  110. return ResponseHelp.success(null);
  111. }
  112. @RequestMapping(value = "/start", method = RequestMethod.POST)
  113. @ApiOperation(value = "开始考试", notes = "提交考试设置", httpMethod = "POST")
  114. public Response<User> start(
  115. @RequestParam(required = false) String paperId
  116. ) {
  117. User user = (User) shiroHelp.getLoginUser();
  118. return ResponseHelp.success(null);
  119. }
  120. @RequestMapping(value = "/next", method = RequestMethod.POST)
  121. @ApiOperation(value = "获取下一题", notes = "获取下一题", httpMethod = "POST")
  122. public Response<User> next(
  123. @RequestParam(required = false) String reportId
  124. ) {
  125. User user = (User) shiroHelp.getLoginUser();
  126. return ResponseHelp.success(null);
  127. }
  128. @RequestMapping(value = "/submit", method = RequestMethod.POST)
  129. @ApiOperation(value = "提交题目答案", notes = "提交题目", httpMethod = "POST")
  130. public Response<User> submit(
  131. @RequestParam(required = false) String questionNoId
  132. ) {
  133. User user = (User) shiroHelp.getLoginUser();
  134. return ResponseHelp.success(null);
  135. }
  136. @RequestMapping(value = "/finish", method = RequestMethod.POST)
  137. @ApiOperation(value = "完成考试", notes = "完成考试", httpMethod = "POST")
  138. public Response<User> finish(
  139. @RequestParam(required = false) String paperId
  140. ) {
  141. User user = (User) shiroHelp.getLoginUser();
  142. return ResponseHelp.success(null);
  143. }
  144. }