瀏覽代碼

陪练课排课生成结束时间

cy 3 年之前
父節點
當前提交
c59b2dc86a

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

@@ -48,7 +48,9 @@ import org.springframework.transaction.annotation.Transactional;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
+import java.time.Instant;
 import java.time.LocalDate;
+import java.time.temporal.ChronoUnit;
 import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
@@ -1113,6 +1115,13 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         Date startTime = adjustVo.getStartTime();
         Date endTime = adjustVo.getEndTime();
         Date now = new Date();
+
+        if(endTime==null){
+            CourseSchedule courseSchedule = baseMapper.selectById(courseId);
+            Integer minutes = Math.toIntExact(ChronoUnit.MINUTES.between(Instant.ofEpochMilli(courseSchedule.getStartTime().getTime()), Instant.ofEpochMilli(courseSchedule.getEndTime().getTime())));
+            endTime = DateUtil.offsetMinute(startTime, minutes);
+        }
+
         //校验时间是否为未来时刻
         if (startTime.before(now) || endTime.before(now)) {
             throw new BizException("排课日期必须大于当前日期");

+ 0 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/CourseAdjustVo.java

@@ -26,7 +26,6 @@ public class CourseAdjustVo implements Serializable {
     private Date startTime;
 
     @ApiModelProperty(value = "下课时间")
-    @NotNull(message = "下课时间")
     private Date endTime;
 
     public Integer getCourseId() {