import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, Index } from 'typeorm';

@Entity('feie_printer_mt')
@Index(['tenantId'])
@Index(['tenantId', 'printerSn'], { unique: true })
@Index(['tenantId', 'printerStatus'])
export class FeiePrinterMt {
  @PrimaryGeneratedColumn({ unsigned: true })
  id!: number;

  @Column({ name: 'tenant_id', type: 'int', unsigned: true, comment: '租户ID' })
  tenantId!: number;

  @Column({ name: 'printer_sn', type: 'varchar', length: 50, comment: '打印机序列号' })
  printerSn!: string;

  @Column({ name: 'printer_key', type: 'varchar', length: 100, comment: '打印机密钥' })
  printerKey!: string;

  @Column({ name: 'printer_name', type: 'varchar', length: 100, nullable: true, comment: '打印机名称' })
  printerName!: string | null;

  @Column({ name: 'printer_type', type: 'varchar', length: 20, default: '58mm', comment: '打印机类型: 58mm, 80mm' })
  printerType!: string;

  @Column({ name: 'printer_status', type: 'varchar', length: 20, default: 'ACTIVE', comment: '打印机状态: ACTIVE, INACTIVE, ERROR' })
  printerStatus!: string;

  @Column({ name: 'is_default', type: 'smallint', default: 0, comment: '是否默认打印机(0:否,1:是)' })
  isDefault!: number;

  @CreateDateColumn({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  createdAt!: Date;

  @UpdateDateColumn({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP', onUpdate: 'CURRENT_TIMESTAMP' })
  updatedAt!: Date;
}