【新增】 学生端结束考试,更新缓存的数据

This commit is contained in:
dlaren
2025-09-17 12:20:25 +08:00
parent ef3d589455
commit 341823da34

View File

@@ -21,6 +21,7 @@ import pc.exam.pp.module.exam.dal.dataobject.*;
import pc.exam.pp.module.exam.dal.dataobject.monitor.MonitorDO;
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperFileDO;
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperScoreDO;
import pc.exam.pp.module.exam.dal.mysql.monitor.MonitorMapper;
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperPersonMapper;
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperQuMapper;
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperSessionMapper;
@@ -76,6 +77,8 @@ public class AutoToolsController {
StuPaperFileService stuPaperFileService;
@Resource
IEducationPaperService educationPaperService;
@Resource
private MonitorMapper monitorMapper;
@GetMapping("/getStuScoreInfo")
@Operation(summary = "通过学生ID、试卷ID获取")
@@ -353,6 +356,33 @@ public class AutoToolsController {
return CommonResult.success(true);
}
/**
* 停止考试
*
* @return true
*/
@GetMapping("/stopExamStatus")
public CommonResult<Boolean> stopExamStatus(@RequestParam("taskId") String taskId) {
String userId = null;
userId = String.valueOf(SecurityFrameworkUtils.getLoginUserId());
String key = "userCache:" + taskId + ":" + userId;
MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key), MonitorDO.class);
// 如果考试状态存在,更新考试状态
if (info != null) {
info.setExamStatus("0");
info.setRemainingTime(0L);
info.setPaperNum("");
info.setIp("");
info.setStartTime("");
info.setEndTime("");
info.setInteractiveTime("");
// 更新
stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info));
monitorMapper.updateById(info);
}
return CommonResult.success(true);
}
/**
* 停止考试(更改考试状态,管理员操作)