소스 검색

时间校验

cy 3 년 전
부모
커밋
070d9ea56c
1개의 변경된 파일8개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

+ 8 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -45,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.temporal.TemporalAdjusters;
@@ -1621,6 +1622,9 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 
         //校验上下课时间
         for (int i = 0; i < timeList.size(); i++) {
+            if (timeList.get(i).getStartTime().before(new Date())){
+                throw new BizException("上课时间必须大于当前时间");
+            }
             if (!DateUtil.offsetMinute(timeList.get(i).getStartTime(), singleClssTime).equals(timeList.get(i).getEndTime())) {
                 throw new BizException("第{}节课结束时间计算错误", i + 1);
             }
@@ -1843,6 +1847,10 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         courseTime.setEndTime(endTime);
         List<CourseTimeEntity> timeList = Arrays.asList(courseTime);
 
+        if (startTime.before(new Date())){
+            throw new BizException("上课时间必须大于当前时间");
+        }
+
         CourseSchedule courseSchedule = baseMapper.selectOne(Wrappers.<CourseSchedule>lambdaQuery()
                 .eq(CourseSchedule::getId, courseId)
                 .eq(CourseSchedule::getTeacherId, teacherId)