forked from wangziqi/gongxue-base
- 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>
77 lines
2.0 KiB
TypeScript
77 lines
2.0 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
ManyToOne,
|
|
JoinColumn,
|
|
Index,
|
|
} from 'typeorm';
|
|
import { Student } from './student.entity';
|
|
import { Class } from './class.entity';
|
|
import { ClassSchedule } from './class-schedule.entity';
|
|
import { AttendanceSession } from './attendance-session.entity';
|
|
|
|
@Entity('attendance_records')
|
|
@Index(['classId', 'attendanceDate'])
|
|
@Index(['studentId', 'attendanceDate'])
|
|
@Index(['attendanceSessionId', 'studentId'], { unique: true })
|
|
export class AttendanceRecord {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@Column({ name: 'student_id', type: 'integer' })
|
|
studentId: number;
|
|
|
|
@ManyToOne(() => Student, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'student_id' })
|
|
student: Student;
|
|
|
|
@Column({ name: 'class_id', type: 'integer', nullable: true })
|
|
classId: number;
|
|
|
|
@ManyToOne(() => Class, { onDelete: 'SET NULL', nullable: true })
|
|
@JoinColumn({ name: 'class_id' })
|
|
class: Class;
|
|
|
|
@Column({ name: 'schedule_id', type: 'integer', nullable: true })
|
|
scheduleId: number | null;
|
|
|
|
@ManyToOne(() => ClassSchedule, { onDelete: 'SET NULL', nullable: true })
|
|
@JoinColumn({ name: 'schedule_id' })
|
|
schedule: ClassSchedule | null;
|
|
|
|
@Column({ name: 'attendance_session_id', type: 'integer', nullable: true })
|
|
attendanceSessionId: number | null;
|
|
|
|
@ManyToOne(() => AttendanceSession, (session) => session.records, {
|
|
onDelete: 'SET NULL',
|
|
nullable: true,
|
|
})
|
|
@JoinColumn({ name: 'attendance_session_id' })
|
|
attendanceSession: AttendanceSession | null;
|
|
|
|
@Column({ name: 'attendance_date', type: 'date' })
|
|
attendanceDate: string;
|
|
|
|
@Column({ length: 20 })
|
|
session: string;
|
|
|
|
@Column({ length: 20 })
|
|
status: string;
|
|
|
|
@Column({ type: 'varchar', length: 200, nullable: true })
|
|
remark: string | null;
|
|
|
|
@Column({ name: 'source', length: 20, default: 'manual' })
|
|
source: string;
|
|
|
|
@CreateDateColumn({ name: 'created_at' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at' })
|
|
updatedAt: Date;
|
|
|
|
}
|