RealExamController.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package com.ruoyi.sim.controller;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletResponse;
  4. import com.ruoyi.sim.service.impl.RealExamService;
  5. import io.swagger.annotations.Api;
  6. import io.swagger.annotations.ApiOperation;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.GetMapping;
  9. import org.springframework.web.bind.annotation.PostMapping;
  10. import org.springframework.web.bind.annotation.PutMapping;
  11. import org.springframework.web.bind.annotation.PathVariable;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import com.ruoyi.common.annotation.Log;
  16. import com.ruoyi.common.core.controller.BaseController;
  17. import com.ruoyi.common.core.domain.AjaxResult;
  18. import com.ruoyi.common.enums.BusinessType;
  19. import com.ruoyi.sim.domain.RealExam;
  20. import com.ruoyi.common.utils.poi.ExcelUtil;
  21. import com.ruoyi.common.core.page.TableDataInfo;
  22. /**
  23. * 考试Controller
  24. *
  25. * @author tom
  26. * @date 2024-12-15
  27. */
  28. @RestController
  29. @RequestMapping("/sim/real-exam")
  30. @Api("考试Controller")
  31. public class RealExamController extends BaseController {
  32. @Autowired
  33. private RealExamService realExamService;
  34. /**
  35. * 查询考试列表
  36. */
  37. // @GetMapping("/teacher/list")
  38. // @ApiOperation("[老师]查询学生考试列表")
  39. public TableDataInfo list(RealExam realExam) {
  40. startPage();
  41. List<RealExam> list = realExamService.selectRealExamList(realExam);
  42. return getDataTable(list);
  43. }
  44. @GetMapping("/student/exam/listByUserId/{userId}")
  45. @ApiOperation("[学生]查询userId学生考试列表")
  46. public TableDataInfo listByUserId(@PathVariable("userId") Long userId) {
  47. // todo:
  48. RealExam q = new RealExam();
  49. q.setUserId(userId);
  50. startPage();
  51. List<RealExam> list = realExamService.selectRealExamList(q);
  52. // todo:
  53. return getDataTable(list);
  54. }
  55. @GetMapping("/student/exam/enter/{examId}")
  56. @ApiOperation("[学生]进入考试")
  57. public AjaxResult studentEnterRealExam(@PathVariable("examId") Long examId) {
  58. return realExamService.studentEnterRealExam(examId);
  59. }
  60. @GetMapping("/student/exam/prepare/{examId}")
  61. @ApiOperation("[轮询][学生]准备考试界面")
  62. public AjaxResult studentLoopPrepareRealExam(@PathVariable("examId") Long examId) {
  63. return realExamService.studentLoopPrepareRealExam(examId);
  64. }
  65. @GetMapping("/student/exam/start/{examId}")
  66. @ApiOperation("[学生]开始考试")
  67. public AjaxResult studentStartRealExam(@PathVariable("examId") Long examId) {
  68. return realExamService.studentStartRealExam(examId);
  69. }
  70. @GetMapping("/student/exam/answering/{examId}")
  71. @ApiOperation("[轮询][学生]正在考试界面")
  72. public AjaxResult studentLoopAnsweringRealExam(@PathVariable("examId") Long examId) {
  73. return realExamService.studentLoopAnsweringRealExam(examId);
  74. }
  75. @GetMapping("/student/exam/submit/{examId}")
  76. @ApiOperation("[学生]交卷")
  77. public AjaxResult studentSubmitRealExam(@PathVariable("examId") Long examId) {
  78. return realExamService.studentSubmitRealExam(examId);
  79. }
  80. @GetMapping("/student/exam/report/{examId}")
  81. @ApiOperation("[轮询][学生]结束考试界面")
  82. public AjaxResult studentLoopPostRealExam(@PathVariable("examId") Long examId) {
  83. return realExamService.studentLoopPostRealExam(examId);
  84. }
  85. // @GetMapping(value = "/student/{examId}")
  86. // @ApiOperation("[学生][轮询]获取考试详细信息")
  87. public AjaxResult getInfoStudent(@PathVariable("examId") Long examId) {
  88. return success(realExamService.selectRealExamByExamId(examId));
  89. }
  90. // @PreAuthorize("@ss.hasPermi('sim:real-exam:query')")
  91. // @GetMapping(value = "/teacher/{examId}")
  92. // @ApiOperation("[老师]获取考试详细信息")
  93. public AjaxResult getInfoTeacher(@PathVariable("examId") Long examId) {
  94. return success(realExamService.selectRealExamByExamId(examId));
  95. }
  96. /**
  97. * 新增考试
  98. */
  99. // @PreAuthorize("@ss.hasPermi('sim:real-exam:add')")
  100. @Log(title = "考试", businessType = BusinessType.INSERT)
  101. @PostMapping
  102. public AjaxResult add(@RequestBody RealExam realExam) {
  103. return toAjax(realExamService.insertRealExam(realExam));
  104. }
  105. /**
  106. * 修改考试
  107. */
  108. // @PreAuthorize("@ss.hasPermi('sim:real-exam:edit')")
  109. @Log(title = "考试", businessType = BusinessType.UPDATE)
  110. @PutMapping
  111. public AjaxResult edit(@RequestBody RealExam realExam) {
  112. return toAjax(realExamService.updateRealExam(realExam));
  113. }
  114. /**
  115. * 删除考试
  116. */
  117. // @PreAuthorize("@ss.hasPermi('sim:real-exam:remove')")
  118. @Log(title = "考试", businessType = BusinessType.DELETE)
  119. // @DeleteMapping("/{examIds}")
  120. public AjaxResult remove(@PathVariable Long[] examIds) {
  121. return toAjax(realExamService.deleteRealExamByExamIds(examIds));
  122. }
  123. }