P2-12 Teacher Management: - Add profile JSON field (subjects, joinedAt, qualifications) to User entity - Add GET/PUT /rbac/users/:id/profile endpoints with UpdateProfileDto - Add GET /rbac/teacher-workspace endpoint returning assignedClasses, todaySchedules, and myStudents - Create /teacher-workspace page with tabs (My Classes, Today's Schedule, My Students) - Add route with PermissionRoute and menu item in MainLayout P2-13 Student Archive Multi-class: - Add GET /students/:id/compare-classes endpoint returning side-by-side enrollment data with per-class attendance statistics - Students module now includes ClassStudent and AttendanceRecord entities - No 2-enrollment cap existed in the codebase; student enrollments already return all records via class-student table
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
ManyToMany,
|
|
JoinTable,
|
|
} from 'typeorm';
|
|
import { Role } from './role.entity';
|
|
|
|
@Entity('users')
|
|
export class User {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@Column({ length: 50, unique: true })
|
|
username: string;
|
|
|
|
@Column({ name: 'password_hash', length: 255 })
|
|
passwordHash: string;
|
|
|
|
// 移除: @Column({ type: 'varchar', length: 20, default: 'operator' })
|
|
// role: string;
|
|
|
|
@Column({ length: 50, nullable: true })
|
|
name: string;
|
|
|
|
// 移除: @Column({ name: 'allowed_menus', type: 'text', nullable: true })
|
|
// allowedMenus: string;
|
|
|
|
@Column({ name: 'is_active', default: true })
|
|
isActive: boolean;
|
|
|
|
@Column({ name: 'last_login_at', type: 'datetime', nullable: true })
|
|
lastLoginAt: Date;
|
|
|
|
@CreateDateColumn({ name: 'created_at' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at' })
|
|
updatedAt: Date;
|
|
|
|
@Column({ name: 'profile', type: 'simple-json', nullable: true })
|
|
profile: { subjects?: string[]; joinedAt?: string; qualifications?: string };
|
|
|
|
@ManyToMany(() => Role, (role) => role.users)
|
|
@JoinTable({
|
|
name: 'user_roles',
|
|
joinColumn: { name: 'user_id', referencedColumnName: 'id' },
|
|
inverseJoinColumn: { name: 'role_id', referencedColumnName: 'id' },
|
|
})
|
|
roles: Role[];
|
|
}
|