import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, Index } from 'typeorm'; export enum AdminRole { SUPER_ADMIN = 'super_admin', OPERATOR = 'operator', VIEWER = 'viewer', } @Entity('admin_users') export class AdminUser { @PrimaryGeneratedColumn({ type: 'bigint', comment: '用户ID' }) id: number; @Column({ type: 'varchar', length: 50, unique: true, comment: '用户名' }) @Index() username: string; @Column({ type: 'char', length: 60, comment: '密码哈希(bcrypt)' }) passwordHash: string; @Column({ type: 'enum', enum: AdminRole, default: AdminRole.VIEWER, comment: '角色:super_admin-超级管理员, operator-操作员, viewer-查看者', }) role: AdminRole; @CreateDateColumn({ type: 'datetime', comment: '创建时间' }) createdAt: Date; @UpdateDateColumn({ type: 'datetime', comment: '更新时间' }) updatedAt: Date; }