Commit ee1e563c authored by wujipeng's avatar wujipeng
Browse files

优化项

parent 97d0574e
......@@ -1621,9 +1621,8 @@ public class CourseAdminServiceImpl implements CourseAdminService {
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("课程日期不能早于当前日期");
}
// 允许补录班级培训周期内的历史课程。日期边界仍由 validateCourseDate 校验,
// 因而放开“不得早于今天”不会允许课程超出班级的培训开始、结束日期。
if (courseDate.equals(today)) {
LocalTime now = LocalTime.now(ClassAdminConstants.BUSINESS_ZONE);
boolean started = course.timeRanges.stream()
......
......@@ -161,6 +161,31 @@ class CourseAdminServiceImplTest {
assertEquals("11:00-13:00", captor.getValue().getTimeFrame());
}
@Test
void createBatchShouldAllowHistoricalCourseWithinClassTrainingPeriod() {
LocalDate historicalDate = LocalDate.now(ClassAdminConstants.BUSINESS_ZONE).minusDays(1);
mockWritableClassFor(historicalDate);
when(classSubjectMapper.countAdminActiveTeacher("teacher-1")).thenReturn(1);
when(classSubjectMapper.selectAdminConflictCandidates(any(), eq(1),
eq("teacher-1"), anyList())).thenReturn(Collections.emptyList());
when(classSubjectMapper.insert(any(ClassSubjectEntity.class))).thenReturn(1);
mockEmptyDetail();
CourseAdminSaveDTO item = validCourse();
item.setDate(Date.valueOf(historicalDate));
CourseAdminBatchSaveDTO request = new CourseAdminBatchSaveDTO();
request.setClassId(1);
request.setCourses(Collections.singletonList(item));
// 历史课程用于补录真实教学记录,只要仍处于班级培训周期内就应允许保存。
service.createBatch(request);
ArgumentCaptor<ClassSubjectEntity> captor =
ArgumentCaptor.forClass(ClassSubjectEntity.class);
verify(classSubjectMapper).insert(captor.capture());
assertEquals(Date.valueOf(historicalDate), captor.getValue().getDate());
}
@Test
void createBatchShouldRejectOverlappingCoursesInSameRequest() {
mockWritableClass();
......
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