From b005f8a8669cdea0f1738172d7c13da57a1237e2 Mon Sep 17 00:00:00 2001
From: luohairen <3399054449@qq.com>
Date: 星期二, 29 十月 2024 17:06:23 +0800
Subject: [PATCH] 增加了重置密码的功能
---
src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java | 95 ++++++++++++++++++++++++++++++++++++-----------
1 files changed, 73 insertions(+), 22 deletions(-)
diff --git a/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
index 6b4790c..c68c3e0 100644
--- a/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
+++ b/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
@@ -3,9 +3,11 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.jxkg.base.Result;
import com.ycl.jxkg.base.SystemCode;
@@ -30,6 +32,7 @@
import com.ycl.jxkg.enums.ExamPaperTypeEnum;
import com.ycl.jxkg.enums.QuestionTypeEnum;
import com.ycl.jxkg.enums.WebsocketCommendEnum;
+import com.ycl.jxkg.enums.general.ClassesStatusEnum;
import com.ycl.jxkg.enums.general.ExamStatusEnum;
import com.ycl.jxkg.enums.general.ExamSubmitTempStatusEnum;
import com.ycl.jxkg.mapper.*;
@@ -114,7 +117,7 @@
throw new RuntimeException("鍙兘淇敼杩樻湭寮�濮嬬殑鑰冭瘯");
}
BeanUtils.copyProperties(form, entity);
- entity.setStatus(ExamStatusEnum.getStatusByTime(form.getStartTime(), form.getEndTime(), null));
+ entity.setStatus(ExamStatusEnum.getStatusByTime(form.getStartTime(), form.getEndTime(), new Date()));
// 濡傛灉淇敼鎴愬姛鍙戦�乵q娑堟伅
if (baseMapper.updateById(entity) > 0) {
this.sendMQ(entity, entity.getUpdateVersion());
@@ -211,6 +214,7 @@
item.setExamPaperId(null);
}
});
+ //
return Result.ok().data(page.getRecords()).total(page.getTotal());
}
@@ -250,10 +254,10 @@
.eq(ExamSubmitTemp::getUserId, webContext.getCurrentUser().getId())
.one();
if (Objects.nonNull(hasJoin)) {
- //TODO锛氬紑鍙戠幆澧冨厛鍏抽棴
-// if(ExamSubmitTempStatusEnum.finish.equals(hasJoin.getStatus())){
-// throw new RuntimeException("鎮ㄥ凡鎻愪氦璇曞嵎锛岃鍕块噸澶嶄綔绛�");
-// }
+ // 鍏佽鎻愪氦鍚庣户缁綔绛�
+ if(ExamSubmitTempStatusEnum.finish.equals(hasJoin.getStatus())){
+ throw new RuntimeException("鎮ㄥ凡鎻愪氦璇曞嵎锛岃鍕块噸澶嶄綔绛�");
+ }
StartExamVO startExamVO = new StartExamVO();
startExamVO.setExamName(exam.getExamName());
startExamVO.setId(hasJoin.getExamId());
@@ -378,7 +382,6 @@
doQuestionVO.setQuestionType(item.getQuestionType());
//澧炲姞棰樼洰鍒嗘暟
doQuestionVO.setQuestionScore(question.getScore());
-
// 棰樼洰鍓湰
QuestionAnswerCopyVO copy = new QuestionAnswerCopyVO();
copy.setId(question.getId());
@@ -511,7 +514,6 @@
ExamSubmitTemp one = new LambdaQueryChainWrapper<>(examSubmitTempMapper)
.eq(ExamSubmitTemp::getExamId, submitData.getId())
.eq(ExamSubmitTemp::getUserId, webContext.getCurrentUser().getId())
- .eq(ExamSubmitTemp::getDeleted, 0)
.one();
if (Objects.nonNull(one)) {
@@ -568,8 +570,15 @@
studentExamInfoVO.setStatus(examSubmitTemp.getStatus());
studentExamInfoVO.setDoTime(examSubmitTemp.getDoTime());
} else {
- studentExamInfoVO.setMarkPaperStatus(ExamSubmitTempStatusEnum.temp);
+ //涓嶅瓨鍦ㄨ�冭瘯璁板綍
studentExamInfoVO.setStatus(ExamSubmitTempStatusEnum.temp);
+ //鏍规嵁Score琛ㄥ垽鏂�
+ ExamPaperScore paperScore = examPaperScoreMapper.getByExamIdUserId(exam.getId(), userId);
+ if(paperScore==null) {
+ studentExamInfoVO.setMarkPaperStatus(ExamSubmitTempStatusEnum.temp);
+ }else {
+ studentExamInfoVO.setMarkPaperStatus(ExamSubmitTempStatusEnum.finish);
+ }
studentExamInfoVO.setDoTime(0);
}
}
@@ -590,11 +599,11 @@
@Override
public Result getMarkPaperInfo(Integer examId, Integer userId) {
+ User student = userMapper.getUserById(userId);
//濡傛灉宸茬粡闃呰繃鍗蜂簡锛屾煡鎴愮哗琛�
- Result<ExamPaperMarkVO> paperMarkVO1 = checkHasJudge(examId, userId);
+ Result<ExamPaperMarkVO> paperMarkVO1 = checkHasJudge(examId, student);
if (paperMarkVO1 != null) return paperMarkVO1;
- User student = userMapper.getUserById(userId);
ExamVO exam = examMapper.getById(examId);
//瀛︾敓绛旈琛�
ExamSubmitTemp userExam = new LambdaQueryChainWrapper<>(examSubmitTempMapper)
@@ -624,23 +633,26 @@
for (PaperFixQuestionVO titleItem : titleItems) {
for (DoQuestionVO doQuestionVO : titleItem.getQuestionList()) {
Integer questionId = doQuestionVO.getId();
- Optional<QuestionAnswerCopyVO> first = answerList.stream().filter(answer -> questionId.equals(answer.getId())).findFirst();
- if (first.isPresent()) {
- QuestionAnswerCopyVO answerCopyVO = first.get();
- doQuestionVO.setQuestionAnswer(answerCopyVO.getCorrect());
- doQuestionVO.setAnalyze(answerCopyVO.getAnalyze());
- doQuestionVO.setDifficult(answerCopyVO.getDifficult());
+ if(questionId!=null) {
+ Optional<QuestionAnswerCopyVO> first = answerList.stream().filter(answer -> questionId.equals(answer.getId())).findFirst();
+ if (first.isPresent()) {
+ QuestionAnswerCopyVO answerCopyVO = first.get();
+ doQuestionVO.setQuestionAnswer(answerCopyVO.getCorrect());
+ doQuestionVO.setAnalyze(answerCopyVO.getAnalyze());
+ doQuestionVO.setDifficult(answerCopyVO.getDifficult());
+ }
}
}
}
}
//妫�鏌ユ槸鍚﹂槄鍗�
- private Result<ExamPaperMarkVO> checkHasJudge(Integer examId, Integer userId) {
- ExamPaperScore examPaperScore = examPaperScoreMapper.getByExamIdUserId(examId, userId);
+ private Result<ExamPaperMarkVO> checkHasJudge(Integer examId, User student) {
+ ExamPaperScore examPaperScore = examPaperScoreMapper.getByExamIdUserId(examId, student.getId());
if (examPaperScore != null) {
ExamPaperMarkVO paperMarkVO = new ExamPaperMarkVO();
BeanUtils.copyProperties(examPaperScore, paperMarkVO);
+ paperMarkVO.setUserName(student.getRealName());
paperMarkVO.setTotalScore(examPaperScore.getTotalScore() + "");
paperMarkVO.setScore(examPaperScore.getScore() + "");
if (!StringUtils.isEmpty(examPaperScore.getPaperContent())) {
@@ -834,7 +846,7 @@
paperMarkVO.setTitleItems(JSON.parseArray(userExam.getExamSubmit(), PaperFixQuestionVO.class));
} else {
//缂鸿�冿紝瀛︾敓娌℃湁鍋氶淇℃伅
- paperMarkVO.setExamId(exam.getExamPaperId());
+ paperMarkVO.setExamId(exam.getId());
paperMarkVO.setUserId(student.getId());
paperMarkVO.setScore(BigDecimal.ZERO + "");
paperMarkVO.setDoTime(0);
@@ -907,7 +919,9 @@
@Override
public Result monitorList(ExamQuery query) {
IPage<ExamSubmitTempVO> page = PageUtil.getPage(query, ExamSubmitTempVO.class);
- return Result.ok((examSubmitTempMapper.monitorList(page, query)));
+ IPage<ExamSubmitTempVO> vo = examSubmitTempMapper.monitorList(page, query);
+
+ return Result.ok(vo);
}
@Override
@@ -921,7 +935,7 @@
form.setAddTimeM(sed);
websocket.setData(form);
// 鍙戦�亀ebsocket娑堟伅
- websocketServer.sendOneMessage(form.getUserId(), JSON.toJSONString(form));
+ websocketServer.sendOneMessage(form.getUserId(), JSON.toJSONString(websocket));
return Result.ok("鎿嶄綔鎴愬姛");
}
@@ -934,7 +948,44 @@
websocket.setCommend(WebsocketCommendEnum.FORCE_SUBMIT.getCommand());
websocket.setData(form);
// 鍙戦�亀ebsocket娑堟伅
- websocketServer.sendOneMessage(form.getUserId(), JSON.toJSONString(form));
+ websocketServer.sendOneMessage(form.getUserId(), JSON.toJSONString(websocket));
return Result.ok("鎿嶄綔鎴愬姛");
}
+
+ /**
+ * 浣滃簾
+ *
+ * @param id
+ * @return {@link Result }
+ * @author
+ */
+ @Override
+ public Result cancel(Integer id) {
+ new LambdaUpdateChainWrapper<>(examMapper)
+ .eq(Exam::getId, id)
+ .set(Exam::getStatus, ExamStatusEnum.CANCEL)
+ .update();
+ return Result.ok("浣滃簾鎴愬姛");
+ }
+
+ @Override
+ public Result recover(Integer id) {
+ // 鍏堟煡璇㈠綋鍓嶈�冭瘯璁板綍鐨勮缁嗕俊鎭�
+ Exam examInfo = new LambdaQueryChainWrapper<>(examMapper)
+ .eq(Exam::getId, id)
+ .one();
+ // 纭畾鎭㈠鍚庡綋鍓嶈�冭瘯璁板綍鐨勭姸鎬�
+ Date currentTime = new Date();
+ Date startTime = examInfo.getStartTime();
+ Date endTime = examInfo.getEndTime();
+ ExamStatusEnum statusByTime = ExamStatusEnum.getStatusByTime(startTime, endTime, currentTime);
+ examInfo.setStatus(statusByTime);
+ // 淇敼褰撳墠鐨勮�冭瘯鐘舵��
+ new LambdaUpdateChainWrapper<>(examMapper)
+ .eq(Exam::getId, id)
+ .set(Exam::getStatus, examInfo.getStatus())
+ .update();
+ // 杩樺師鐝骇鐨勮�冭瘯淇℃伅
+ return Result.ok("鑰冭瘯璁板綍宸茬粡鎭㈠姝e父");
+ }
}
--
Gitblit v1.8.0