Commit 91f4abe0 by zhengyunfei
parents 8709b146 f3e9298e
...@@ -66,8 +66,8 @@ public class TestPaperController extends BaseController { ...@@ -66,8 +66,8 @@ public class TestPaperController extends BaseController {
*/ */
@Log(title = "交卷", businessType = BusinessType.INSERT) @Log(title = "交卷", businessType = BusinessType.INSERT)
@PostMapping("/endTest/") @PostMapping("/endTest/")
public R<Void> paperTestEnd(@RequestBody TestPaperAnswerBo bo) { public R<Boolean> paperTestEnd(@RequestBody TestPaperAnswerBo bo) {
return toAjax(testPaperService.paperTestEnd(bo)); return R.ok(testPaperService.paperTestEnd(bo));
} }
/** /**
......
...@@ -149,7 +149,6 @@ public class TestPaperServiceImpl implements ITestPaperService { ...@@ -149,7 +149,6 @@ public class TestPaperServiceImpl implements ITestPaperService {
buffer.setScore(bankTestPaperVo.getRightAnswers().equals(buffer.getAnswer()) ? BigDecimal.valueOf(bankTestPaperVo.getScore()) : BigDecimal.ZERO); buffer.setScore(bankTestPaperVo.getRightAnswers().equals(buffer.getAnswer()) ? BigDecimal.valueOf(bankTestPaperVo.getScore()) : BigDecimal.ZERO);
} }
insertPaperRecords.add(buffer); insertPaperRecords.add(buffer);
RedisUtils.deleteKeys(key);
}); });
if (CollUtil.isNotEmpty(insertPaperRecords)) { if (CollUtil.isNotEmpty(insertPaperRecords)) {
if (!paperRecordDetailService.saveBatch(insertPaperRecords)) { if (!paperRecordDetailService.saveBatch(insertPaperRecords)) {
...@@ -157,9 +156,11 @@ public class TestPaperServiceImpl implements ITestPaperService { ...@@ -157,9 +156,11 @@ public class TestPaperServiceImpl implements ITestPaperService {
} }
// 修改考试记录状态为待批阅 // 修改考试记录状态为待批阅
testPaperRecord.setStatus(1); testPaperRecord.setStatus(1);
if (!paperRecordService.updateByBo(BeanUtil.toBean(testPaperService, DbTestPaperRecordBo.class))) { if (!paperRecordService.updateByBo(BeanUtil.toBean(testPaperRecord, DbTestPaperRecordBo.class))) {
throw new ServiceException("考试记录状态修改失败"); throw new ServiceException("考试记录状态修改失败");
} }
// 清除Redis缓存
RedisUtils.deleteKeys(String.format("%s:record:%d*", TEST_PAPER_ANSWER_KEY, bo.getRecordId()));
return true; return true;
} }
return true; return true;
...@@ -183,7 +184,7 @@ public class TestPaperServiceImpl implements ITestPaperService { ...@@ -183,7 +184,7 @@ public class TestPaperServiceImpl implements ITestPaperService {
// 查询Redis中是否有该题的提交记录 // 查询Redis中是否有该题的提交记录
String key = String.format(TEST_PAPER_ANSWER_KEY_FORMAT, TEST_PAPER_ANSWER_KEY, recordId, question.getId()); String key = String.format(TEST_PAPER_ANSWER_KEY_FORMAT, TEST_PAPER_ANSWER_KEY, recordId, question.getId());
TestPaperAnswerItemBo cacheObject = RedisUtils.getCacheObject(key); TestPaperAnswerItemBo cacheObject = RedisUtils.getCacheObject(key);
if (cacheObject == null || cacheObject.getId() == null || if (cacheObject == null ||
(StringUtils.isEmpty(cacheObject.getAnswer()) && StringUtils.isEmpty(cacheObject.getAnswerPic()))) { (StringUtils.isEmpty(cacheObject.getAnswer()) && StringUtils.isEmpty(cacheObject.getAnswerPic()))) {
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment