Files
gongxue-base/apps/server/src/entities/attendance-session.entity.ts
wangziqi cc4f4dae4e fix: audit remediation — SSE user scoping, FK transactional safety, UI error handling
- H4: scoped SSE import progress to exact userId match; non-HTTP events excluded from all subscribers
- H2: moved PRAGMA foreign_key_check inside SQLite transaction before COMMIT; violations rollback preserving old tables
- M1: removed dead axios-style error branch from extractErrorMessage (interceptor already unwraps)
- M2: split handleSave try/catch — save errors vs reload errors shown distinctly
- M3: added provider field validation before AI config test request
- Added SSE scoping regression tests (import service + controller)
- Added FK check failure rollback test (database-migrations.spec)
- Updated controller spec expectations for userId parameter

Co-authored-by: Code Review <branch-review>
2026-07-12 22:59:03 +08:00

63 lines
1.6 KiB
TypeScript

import {
Column,
CreateDateColumn,
Entity,
Index,
JoinColumn,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { ClassSchedule } from './class-schedule.entity';
import { Class } from './class.entity';
import { AttendanceRecord } from './attendance-record.entity';
@Entity('attendance_sessions')
@Index(['scheduleId', 'lessonDate'], { unique: true })
export class AttendanceSession {
@PrimaryGeneratedColumn()
id: number;
@Column({ name: 'schedule_id', type: 'integer' })
scheduleId: number;
@ManyToOne(() => ClassSchedule, { onDelete: 'RESTRICT' })
@JoinColumn({ name: 'schedule_id' })
schedule: ClassSchedule;
@Column({ name: 'class_id', type: 'integer' })
classId: number;
@ManyToOne(() => Class, { onDelete: 'RESTRICT' })
@JoinColumn({ name: 'class_id' })
class: Class;
@Column({ name: 'lesson_date', type: 'date' })
lessonDate: string;
@Column({ length: 20, default: 'in_progress' })
status: string;
@Column({ name: 'started_by', type: 'integer', nullable: true })
startedBy: number | null;
@Column({ name: 'started_at', type: 'datetime', nullable: true })
startedAt: Date | null;
@Column({ name: 'completed_by', type: 'integer', nullable: true })
completedBy: number | null;
@Column({ name: 'completed_at', type: 'datetime', nullable: true })
completedAt: Date | null;
@OneToMany(() => AttendanceRecord, (record) => record.attendanceSession)
records: AttendanceRecord[];
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date;
}