|
| 1 | +import { |
| 2 | + Entity, |
| 3 | + PrimaryGeneratedColumn, |
| 4 | + Column, |
| 5 | + ManyToOne, |
| 6 | + CreateDateColumn, |
| 7 | +} from 'typeorm'; |
| 8 | +import { User } from '../users/user.entity'; |
| 9 | + |
| 10 | +export enum MaintenanceType { |
| 11 | + PREVENTIVE = 'PREVENTIVE', |
| 12 | + CORRECTIVE = 'CORRECTIVE', |
| 13 | + SCHEDULED = 'SCHEDULED', |
| 14 | +} |
| 15 | + |
| 16 | +export enum MaintenanceStatus { |
| 17 | + SCHEDULED = 'SCHEDULED', |
| 18 | + IN_PROGRESS = 'IN_PROGRESS', |
| 19 | + COMPLETED = 'COMPLETED', |
| 20 | + CANCELLED = 'CANCELLED', |
| 21 | +} |
| 22 | + |
| 23 | +@Entity('asset_maintenance') |
| 24 | +export class Maintenance { |
| 25 | + @PrimaryGeneratedColumn('uuid') |
| 26 | + id: string; |
| 27 | + |
| 28 | + @Column() |
| 29 | + assetId: string; |
| 30 | + |
| 31 | + @Column({ type: 'enum', enum: MaintenanceType }) |
| 32 | + type: MaintenanceType; |
| 33 | + |
| 34 | + @Column('text') |
| 35 | + description: string; |
| 36 | + |
| 37 | + @Column({ type: 'date' }) |
| 38 | + scheduledDate: Date; |
| 39 | + |
| 40 | + @Column({ type: 'date', nullable: true }) |
| 41 | + completedDate: Date | null; |
| 42 | + |
| 43 | + @Column({ type: 'decimal', precision: 10, scale: 2, nullable: true }) |
| 44 | + cost: number | null; |
| 45 | + |
| 46 | + @ManyToOne(() => User, { eager: true, nullable: true }) |
| 47 | + performedBy: User | null; |
| 48 | + |
| 49 | + @Column({ type: 'text', nullable: true }) |
| 50 | + notes: string | null; |
| 51 | + |
| 52 | + @Column({ type: 'enum', enum: MaintenanceStatus, default: MaintenanceStatus.SCHEDULED }) |
| 53 | + status: MaintenanceStatus; |
| 54 | + |
| 55 | + @CreateDateColumn() |
| 56 | + createdAt: Date; |
| 57 | +} |
0 commit comments