Quellcode durchsuchen

Merge remote-tracking branch 'origin/sit-three-categories' into sit-three-categories

panzhilin vor 3 Monaten
Ursprung
Commit
a24b9fcd4b

+ 16 - 0
alien-store/src/main/java/shop/alien/store/service/impl/BarPerformanceServiceImpl.java

@@ -97,6 +97,14 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
                 if (barPerformance.getSingleEndDatetime() == null) {
                     throw new IllegalArgumentException("单次演出必须填写结束时间");
                 }
+                // 验证开始时间必须是今天或以后
+                if (barPerformance.getSingleStartDatetime().before(todayStart)) {
+                    throw new IllegalArgumentException("开始时间必须是今天或以后");
+                }
+                // 确保开始时间早于结束时间
+                if (barPerformance.getSingleStartDatetime().after(barPerformance.getSingleEndDatetime())) {
+                    throw new IllegalArgumentException("开始时间不能晚于结束时间");
+                }
                 // 单次演出不需要周天数据,清除周天字段(设置为空字符串,确保数据库插入时包含该字段)
                 barPerformance.setPerformanceWeek("");
                 break;
@@ -122,6 +130,10 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
                 if (barPerformance.getSingleEndDatetime() == null) {
                     throw new IllegalArgumentException("每天定时演出必须填写结束时间");
                 }
+                // 验证时间逻辑:开始时间必须早于结束时间(只比较时间部分,忽略日期部分)
+                if (!isTimeBefore(barPerformance.getSingleStartDatetime(), barPerformance.getSingleEndDatetime())) {
+                    throw new IllegalArgumentException("开始时间必须早于结束时间");
+                }
                 // 每天定时不需要周天数据,清除周天字段(设置为空字符串,确保数据库插入时包含该字段)
                 barPerformance.setPerformanceWeek("");
                 break;
@@ -151,6 +163,10 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
                 if (barPerformance.getSingleEndDatetime() == null) {
                     throw new IllegalArgumentException("每周定时演出必须填写结束时间");
                 }
+                // 验证时间逻辑:开始时间必须早于结束时间(只比较时间部分,忽略日期部分)
+                if (!isTimeBefore(barPerformance.getSingleStartDatetime(), barPerformance.getSingleEndDatetime())) {
+                    throw new IllegalArgumentException("开始时间必须早于结束时间");
+                }
                 break;
             default:
                 throw new IllegalArgumentException("演出频次类型无效");