fix: review blockers — entity registration, session enum, conflict date-range, @Type decorators
This commit is contained in:
@@ -38,7 +38,7 @@ export class SchedulesService {
|
||||
}
|
||||
|
||||
async create(dto: CreateScheduleDto) {
|
||||
await this.checkConflict(dto.classroomId, dto.weekDay, dto.startTime, dto.endTime);
|
||||
await this.checkConflict(dto.classroomId, dto.weekDay, dto.startTime, dto.endTime, dto.startDate, dto.endDate);
|
||||
|
||||
const schedule = this.scheduleRepo.create(dto);
|
||||
const saved = await this.scheduleRepo.save(schedule);
|
||||
@@ -54,8 +54,10 @@ export class SchedulesService {
|
||||
const weekDay = dto.weekDay ?? existing.weekDay;
|
||||
const startTime = dto.startTime ?? existing.startTime;
|
||||
const endTime = dto.endTime ?? existing.endTime;
|
||||
const startDate = dto.startDate ?? existing.startDate;
|
||||
const endDate = dto.endDate ?? existing.endDate;
|
||||
|
||||
await this.checkConflict(classroomId, weekDay, startTime, endTime, id);
|
||||
await this.checkConflict(classroomId, weekDay, startTime, endTime, startDate, endDate, id);
|
||||
|
||||
await this.scheduleRepo.update(id, dto as Record<string, unknown>);
|
||||
return this.findOne(id);
|
||||
@@ -73,6 +75,8 @@ export class SchedulesService {
|
||||
weekDay: number,
|
||||
startTime: string,
|
||||
endTime: string,
|
||||
startDate: string,
|
||||
endDate: string,
|
||||
excludeId?: number,
|
||||
) {
|
||||
const qb = this.scheduleRepo
|
||||
@@ -81,7 +85,9 @@ export class SchedulesService {
|
||||
.andWhere('cs.weekDay = :weekDay', { weekDay })
|
||||
.andWhere('cs.status = :status', { status: 'active' })
|
||||
.andWhere('cs.startTime < :endTime', { endTime })
|
||||
.andWhere('cs.endTime > :startTime', { startTime });
|
||||
.andWhere('cs.endTime > :startTime', { startTime })
|
||||
.andWhere('cs.startDate <= :endDate', { endDate })
|
||||
.andWhere('cs.endDate >= :startDate', { startDate });
|
||||
|
||||
if (excludeId) qb.andWhere('cs.id != :excludeId', { excludeId });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user