|
@@ -1100,4 +1100,32 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
public List<Exam> listLatestExam(Integer limit, String userId) {
|
|
|
return examMapper.listLatestExam(limit, userId);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取考试状态
|
|
|
+ *
|
|
|
+ * @param exam
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Integer getExamState(Exam exam) {
|
|
|
+ if (!Objects.isNull(exam.getStartTime())) {
|
|
|
+ if (System.currentTimeMillis() < exam.getStartTime().getTime()) {
|
|
|
+ return ExamState.READY_START;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!Objects.isNull(exam.getEndTime())) {
|
|
|
+ if (System.currentTimeMillis() > exam.getEndTime().getTime()) {
|
|
|
+ return ExamState.OVERDUE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!Objects.isNull(exam.getStartTime()) && !Objects.isNull(exam.getEndTime())) {
|
|
|
+ if (System.currentTimeMillis() > exam.getStartTime().getTime()
|
|
|
+ && System.currentTimeMillis() < exam.getEndTime().getTime()) {
|
|
|
+ return ExamState.ENABLE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|