forked from wangziqi/gongxue-base
feat: add attendance device SN classroom bindings
This commit is contained in:
52
apps/server/src/entities/attendance-device.entity.ts
Normal file
52
apps/server/src/entities/attendance-device.entity.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { Classroom } from './classroom.entity';
|
||||
|
||||
export enum AttendanceDeviceStatus {
|
||||
ACTIVE = 'active',
|
||||
DISABLED = 'disabled',
|
||||
}
|
||||
|
||||
@Entity('attendance_devices')
|
||||
@Index(['deviceSn'], { unique: true })
|
||||
@Index(['classroomId'])
|
||||
export class AttendanceDevice {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({ name: 'device_sn', type: 'varchar', length: 100 })
|
||||
deviceSn: string;
|
||||
|
||||
@Column({ name: 'device_name', type: 'varchar', length: 100 })
|
||||
deviceName: string;
|
||||
|
||||
@Column({ name: 'classroom_id', type: 'integer' })
|
||||
classroomId: number;
|
||||
|
||||
@ManyToOne(() => Classroom, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'classroom_id' })
|
||||
classroom: Classroom;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, default: AttendanceDeviceStatus.ACTIVE })
|
||||
status: AttendanceDeviceStatus | 'active' | 'disabled';
|
||||
|
||||
@Column({ type: 'varchar', length: 200, nullable: true })
|
||||
location: string | null;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
notes: string | null;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn({ name: 'updated_at' })
|
||||
updatedAt: Date;
|
||||
}
|
||||
@@ -22,6 +22,7 @@ export { ClassTeacher, TeacherRoleType } from './class-teacher.entity';
|
||||
export { ClassSchedule, ScheduleType } from './class-schedule.entity';
|
||||
export { AttendanceRecord } from './attendance-record.entity';
|
||||
export { AttendanceSession } from './attendance-session.entity';
|
||||
export { AttendanceDevice, AttendanceDeviceStatus } from './attendance-device.entity';
|
||||
export { DingAttendanceRaw } from './ding-attendance-raw.entity';
|
||||
export { SyncLog } from './sync-log.entity';
|
||||
export { SyncState } from './sync-state.entity';
|
||||
|
||||
Reference in New Issue
Block a user