StudentExamResultController.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package com.keao.edu.user.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.keao.edu.auth.api.client.SysUserFeignService;
  4. import com.keao.edu.auth.api.entity.SysUser;
  5. import com.keao.edu.common.controller.BaseController;
  6. import com.keao.edu.common.entity.HttpResponseResult;
  7. import com.keao.edu.common.page.PageInfo;
  8. import com.keao.edu.user.api.enums.StudentExamResultApiDto;
  9. import com.keao.edu.user.dto.RecordNotify;
  10. import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
  11. import com.keao.edu.user.entity.Employee;
  12. import com.keao.edu.user.entity.StudentExamResult;
  13. import com.keao.edu.user.page.StudentExamResultQueryInfo;
  14. import com.keao.edu.user.service.EmployeeService;
  15. import com.keao.edu.user.service.StudentExamResultService;
  16. import io.swagger.annotations.Api;
  17. import io.swagger.annotations.ApiOperation;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.web.bind.annotation.*;
  20. import java.util.Objects;
  21. /**
  22. * @Author Joburgess
  23. * @Date 2020.06.30
  24. */
  25. @RestController
  26. @RequestMapping("studentExamResult")
  27. @Api(tags = "考试结果服务")
  28. public class StudentExamResultController extends BaseController {
  29. @Autowired
  30. private StudentExamResultService studentExamResultService;
  31. @Autowired
  32. private SysUserFeignService sysUserFeignService;
  33. @Autowired
  34. private EmployeeService employeeService;
  35. @RequestMapping(value = "/recordSync")
  36. public void recordSync(@RequestBody String body) throws Exception {
  37. RecordNotify recordNotify = JSONObject.parseObject(body, RecordNotify.class);
  38. studentExamResultService.recordSync(recordNotify);
  39. }
  40. @ApiOperation("查询考试结果")
  41. @GetMapping(value = "/queryStudentExamResult")
  42. public HttpResponseResult<PageInfo<StudentExamResult>> queryStudentExamResult(StudentExamResultQueryInfo queryInfo){
  43. SysUser sysUser = sysUserFeignService.queryUserInfo();
  44. if(!sysUser.getIsSuperAdmin()&&Objects.isNull(queryInfo.getOrganId())){
  45. Employee employee = employeeService.get(sysUser.getId());
  46. if(Objects.isNull(employee)){
  47. return failed("用户信息异常");
  48. }
  49. queryInfo.setOrganId(employee.getOrganId());
  50. }
  51. return succeed(studentExamResultService.queryStudentExamResult(queryInfo));
  52. }
  53. @ApiOperation("修改考试结果")
  54. @PostMapping(value = "/update")
  55. public HttpResponseResult update(StudentExamResult examResult){
  56. studentExamResultService.updateStudentExamResult(examResult);
  57. return succeed();
  58. }
  59. @ApiOperation("修改考试状态")
  60. @PostMapping(value = "/api/updateFinishedExam")
  61. public void updateFinishedExam(Long examRegistrationId,Integer finishedExam){
  62. studentExamResultService.updateFinishedExam(examRegistrationId,finishedExam);
  63. }
  64. @ApiOperation("修改SessionId")
  65. @PostMapping(value = "/api/updateSessionId")
  66. public void updateSessionId(Long examRegistrationId,String sessionId){
  67. studentExamResultService.updateSessionId(examRegistrationId,sessionId);
  68. }
  69. @ApiOperation("获取考试结果")
  70. @PostMapping(value = "/api/get")
  71. public StudentExamResultApiDto get(Long id){
  72. return studentExamResultService.getStudentExamResultApiDto(id);
  73. }
  74. @ApiOperation("考试结果统计信息")
  75. @GetMapping(value = "/getStudentExamResultStatisticsInfo")
  76. public HttpResponseResult<StudentExamResultStatisticsDto> getStudentExamResultStatisticsInfo(Integer examId){
  77. SysUser sysUser = sysUserFeignService.queryUserInfo();
  78. Integer organId=null;
  79. if(!sysUser.getIsSuperAdmin()){
  80. Employee employee = employeeService.get(sysUser.getId());
  81. if(Objects.isNull(employee)){
  82. return failed("用户信息异常");
  83. }
  84. organId=employee.getOrganId();
  85. }
  86. return succeed(studentExamResultService.getStudentExamResultStatisticsInfo(organId, examId));
  87. }
  88. @ApiOperation("确认考生")
  89. @PostMapping(value = "/confirmStudent")
  90. public HttpResponseResult confirmStudent(Long examRegistrationId) {
  91. studentExamResultService.confirmStudent(examRegistrationId);
  92. return succeed();
  93. }
  94. /**
  95. * 屏蔽指定用户
  96. * @param roomId
  97. * @return
  98. * @throws Exception
  99. */
  100. @RequestMapping(value = "/shieldUserId", method = RequestMethod.POST)
  101. public Object shieldUserId(Long roomId,Integer shieldFlag)throws Exception {
  102. studentExamResultService.shieldUserId(roomId,shieldFlag);
  103. return succeed();
  104. }
  105. }