forked from wangziqi/gongxue-base
Task 3: sync RENTAL class_schedule on rental create/update/delete
- ClassroomRentalsService.create/update now upsert a ClassSchedule row with schedule_type='RENTAL' and rental_id set. - ClassroomRentalsService.remove deletes the synced schedule row; update to 'cancelled' also removes it. - SchedulesService.getClassroomOccupancy explicitly returns INTERNAL and RENTAL schedules. - Make classId/teacherId/rentalId nullable in ClassSchedule entity to support rental schedules. - Add unit tests for rental schedule sync and mixed-type occupancy.
This commit is contained in:
@@ -21,11 +21,11 @@ export class ClassSchedule {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({ name: 'class_id', type: 'integer' })
|
||||
classId: number;
|
||||
@Column({ name: 'class_id', type: 'integer', nullable: true })
|
||||
classId: number | null;
|
||||
|
||||
// Forward reference — Class entity
|
||||
@ManyToOne('Class')
|
||||
@ManyToOne('Class', { nullable: true })
|
||||
@JoinColumn({ name: 'class_id' })
|
||||
class: unknown;
|
||||
|
||||
@@ -56,7 +56,7 @@ export class ClassSchedule {
|
||||
subject: string;
|
||||
|
||||
@Column({ name: 'teacher_id', type: 'integer', nullable: true })
|
||||
teacherId: number;
|
||||
teacherId: number | null;
|
||||
|
||||
// Forward reference — User entity
|
||||
@ManyToOne('User', { nullable: true })
|
||||
@@ -67,7 +67,7 @@ export class ClassSchedule {
|
||||
scheduleType: string;
|
||||
|
||||
@Column({ name: 'rental_id', type: 'integer', nullable: true })
|
||||
rentalId: number;
|
||||
rentalId: number | null;
|
||||
|
||||
@Column({ name: 'status', length: 20, default: 'active' })
|
||||
status: string;
|
||||
|
||||
Reference in New Issue
Block a user