Commit 0f48de00 authored by wujipeng's avatar wujipeng
Browse files

Merge remote-tracking branch 'origin/dev-v1.0' into dev-v1.0

parents 64e183dc 35b7dc2f
......@@ -135,6 +135,10 @@ public class ClassAdminServiceImpl implements ClassAdminService {
if (existing == null) {
throw new BusinessException("班级不存在或已删除");
}
String status = resolveClassStatus(existing.getStartDate(), existing.getEndDate(), businessToday());
if (!ClassAdminConstants.STATUS_UPCOMING.equals(status)) {
throw new BusinessException("只有待开课班级可以编辑");
}
int actualCount = classMapper.countAdminStudents(classId);
validateSaveRequest(request, classId, actualCount);
......
......@@ -158,6 +158,7 @@ public class CourseAdminServiceImpl implements CourseAdminService {
try {
PreparedCourse prepared = prepareCourse(
item, request.getClassId(), managedClass, batchType);
validateNewCourseDate(prepared, managedClass);
requireWritablePeriod(prepared.period);
LocalDate courseDate = toLocalDate(prepared.entity.getDate());
......@@ -752,6 +753,23 @@ public class CourseAdminServiceImpl implements CourseAdminService {
}
}
private void validateNewCourseDate(PreparedCourse course, ClassEntity managedClass) {
validateCourseDate(course.entity.getDate(), managedClass);
LocalDate courseDate = toLocalDate(course.entity.getDate());
LocalDate today = LocalDate.now(ClassAdminConstants.BUSINESS_ZONE);
if (courseDate.isBefore(today)) {
throw new BusinessException("课程日期不能早于当前日期");
}
if (courseDate.equals(today)) {
LocalTime now = LocalTime.now(ClassAdminConstants.BUSINESS_ZONE);
boolean started = course.timeRanges.stream()
.anyMatch(range -> !range.start.isAfter(now));
if (started) {
throw new BusinessException("课程开始时间不能早于当前时间");
}
}
}
private void validateQueryDateRange(Date startDate, Date endDate) {
if (startDate != null && endDate != null
&& toLocalDate(startDate).isAfter(toLocalDate(endDate))) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment