RealExamController.java 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. package com.ruoyi.sim.controller;
  2. import java.util.List;
  3. import com.ruoyi.common.utils.SecurityUtils;
  4. import com.ruoyi.sim.domain.RealExamCollection;
  5. import com.ruoyi.sim.domain.vo.RealExamVo;
  6. import com.ruoyi.sim.service.impl.RealExamService;
  7. import io.swagger.annotations.Api;
  8. import io.swagger.annotations.ApiOperation;
  9. import org.slf4j.Logger;
  10. import org.slf4j.LoggerFactory;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.*;
  13. import com.ruoyi.common.annotation.Log;
  14. import com.ruoyi.common.core.controller.BaseController;
  15. import com.ruoyi.common.core.domain.AjaxResult;
  16. import com.ruoyi.common.enums.BusinessType;
  17. import com.ruoyi.sim.domain.RealExam;
  18. import com.ruoyi.common.core.page.TableDataInfo;
  19. /**
  20. * 考试Controller
  21. *
  22. * @author tom
  23. * @date 2024-12-15
  24. */
  25. @RestController
  26. @RequestMapping("/sim/real-exam")
  27. @Api("考试Controller")
  28. public class RealExamController extends BaseController {
  29. private static final Logger l = LoggerFactory.getLogger(RealExamController.class);
  30. @Autowired
  31. private RealExamService realExamService;
  32. /**
  33. * 查询考试列表
  34. */
  35. // @GetMapping("/teacher/list")
  36. // @ApiOperation("[老师]查询学生考试列表")
  37. public TableDataInfo list(RealExam realExam) {
  38. startPage();
  39. List<RealExam> list = realExamService.selectRealExamList(realExam);
  40. return getDataTable(list);
  41. }
  42. @GetMapping("/student/exam/listByUserId/")
  43. @ApiOperation("[学生]查询userId学生考试列表")
  44. public TableDataInfo listByUserId() {
  45. // todo:
  46. RealExam q = new RealExam();
  47. q.setUserId(SecurityUtils.getUserId());
  48. startPage();
  49. List<RealExamVo> list = realExamService.list(q);
  50. // todo:
  51. return getDataTable(list);
  52. }
  53. @GetMapping("/student/exam/enter/{examId}")
  54. @ApiOperation("[学生]进入考试")
  55. public AjaxResult studentEnterRealExam(@PathVariable("examId") Long examId) {
  56. return realExamService.studentEnterRealExam(examId);
  57. }
  58. @GetMapping("/student/exam/prepare/{examId}")
  59. @ApiOperation("[轮询][学生]准备考试界面")
  60. public AjaxResult studentLoopPrepareRealExam(@PathVariable("examId") Long examId) {
  61. return realExamService.studentLoopPrepareRealExam(examId);
  62. }
  63. @GetMapping("/student/exam/start/{examId}")
  64. @ApiOperation("[学生][正式使用]开始考试")
  65. public AjaxResult studentStartRealExam(@PathVariable("examId") Long examId, @RequestParam final String ip) {
  66. l.info("[学生][正式使用]开始考试;examId = {};ip = {}", examId, ip);
  67. return realExamService.studentStartRealExam(examId, ip, RealExamCollection.Type.EXAM);
  68. }
  69. @GetMapping("/student/exercise/start/{examId}")
  70. @ApiOperation("[学生][正式使用]开始训练")
  71. public AjaxResult studentStartRealExercise(@PathVariable("examId") Long examId, @RequestParam final String ip) {
  72. l.info("[学生][正式使用]开始训练;examId = {};ip = {}", examId, ip);
  73. return realExamService.studentStartRealExam(examId, ip, RealExamCollection.Type.EXERCISE);
  74. }
  75. @GetMapping("/student/self-exercise/start/{examId}")
  76. @ApiOperation("[学生][正式使用]开始练习")
  77. public AjaxResult studentStartRealSelfExercise(@PathVariable("examId") Long examId, @RequestParam final String ip) {
  78. l.info("[学生][正式使用]开始练习;examId = {};ip = {}", examId, ip);
  79. return realExamService.studentStartRealExam(examId, ip, RealExamCollection.Type.SELF_EXERCISE);
  80. }
  81. @GetMapping("/student/refresh-sim-state")
  82. @ApiOperation("刷新模拟器状态")
  83. public AjaxResult studentRefreshSimState(@RequestParam final String ip) {
  84. l.info("刷新模拟器状态;ip = {}", ip);
  85. return realExamService.studentRefreshSimState(ip);
  86. }
  87. @GetMapping("/student/exam/answering/{examId}")
  88. @ApiOperation("[轮询][学生]正在考试界面")
  89. public AjaxResult studentLoopAnsweringRealExam(@PathVariable("examId") Long examId) {
  90. return realExamService.studentLoopAnsweringRealExam(examId);
  91. }
  92. @GetMapping("/student/exam/submit/{examId}")
  93. @ApiOperation("[学生][正式使用]交卷考试")
  94. public AjaxResult studentSubmitRealExam(@PathVariable("examId") Long examId, @RequestParam final String ip) {
  95. l.info("[学生][正式使用]交卷考试;examId = {};ip = {}", examId, ip);
  96. return realExamService.studentSubmitRealExam(examId, ip, RealExamCollection.Type.EXAM);
  97. }
  98. @GetMapping("/student/exercise/submit/{examId}")
  99. @ApiOperation("[学生][正式使用]交卷训练")
  100. public AjaxResult studentSubmitRealExercise(@PathVariable("examId") Long examId, @RequestParam final String ip) {
  101. l.info("[学生][正式使用]交卷训练;examId = {};ip = {}", examId, ip);
  102. return realExamService.studentSubmitRealExam(examId, ip, RealExamCollection.Type.EXERCISE);
  103. }
  104. @GetMapping("/student/self-exercise/submit/{examId}")
  105. @ApiOperation("[学生][正式使用]交卷练习")
  106. public AjaxResult studentSubmitRealSelfExercise(@PathVariable("examId") Long examId, @RequestParam final String ip) {
  107. l.info("[学生][正式使用]交卷练习;examId = {};ip = {}", examId, ip);
  108. return realExamService.studentSubmitRealExam(examId, ip, RealExamCollection.Type.SELF_EXERCISE);
  109. }
  110. @GetMapping("/student/exam/report/{examId}")
  111. @ApiOperation("[轮询][学生]结束考试界面")
  112. public AjaxResult studentLoopPostRealExam(@PathVariable("examId") Long examId) {
  113. return realExamService.studentLoopPostRealExam(examId);
  114. }
  115. @GetMapping("/student/exam/login-success")
  116. @ApiOperation("[学员]登录成功后调用")
  117. public AjaxResult studentLoginSuccess(@RequestParam final Long userId, @RequestParam final String ip) {
  118. return realExamService.studentLoginSuccess(userId, ip);
  119. }
  120. // @GetMapping(value = "/student/{examId}")
  121. // @ApiOperation("[学生][轮询]获取考试详细信息")
  122. public AjaxResult getInfoStudent(@PathVariable("examId") Long examId) {
  123. return success(realExamService.selectRealExamByExamId(examId));
  124. }
  125. // @PreAuthorize("@ss.hasPermi('sim:real-exam:query')")
  126. // @GetMapping(value = "/teacher/{examId}")
  127. // @ApiOperation("[老师]获取考试详细信息")
  128. public AjaxResult getInfoTeacher(@PathVariable("examId") Long examId) {
  129. return success(realExamService.selectRealExamByExamId(examId));
  130. }
  131. /**
  132. * 新增考试
  133. */
  134. // @PreAuthorize("@ss.hasPermi('sim:real-exam:add')")
  135. @Log(title = "考试", businessType = BusinessType.INSERT)
  136. @PostMapping
  137. public AjaxResult add(@RequestBody RealExam realExam) {
  138. return toAjax(realExamService.insertRealExam(realExam));
  139. }
  140. /**
  141. * 修改考试
  142. */
  143. // @PreAuthorize("@ss.hasPermi('sim:real-exam:edit')")
  144. @Log(title = "考试", businessType = BusinessType.UPDATE)
  145. @PutMapping
  146. public AjaxResult edit(@RequestBody RealExam realExam) {
  147. return toAjax(realExamService.updateRealExam(realExam));
  148. }
  149. /**
  150. * 删除考试
  151. */
  152. // @PreAuthorize("@ss.hasPermi('sim:real-exam:remove')")
  153. @Log(title = "考试", businessType = BusinessType.DELETE)
  154. // @DeleteMapping("/{examIds}")
  155. public AjaxResult remove(@PathVariable Long[] examIds) {
  156. return toAjax(realExamService.deleteRealExamByExamIds(examIds));
  157. }
  158. }