|
| 1 | +import { |
| 2 | + Entity, |
| 3 | + PrimaryGeneratedColumn, |
| 4 | + Column, |
| 5 | + ManyToOne, |
| 6 | + JoinColumn, |
| 7 | + CreateDateColumn, |
| 8 | + UpdateDateColumn, |
| 9 | +} from 'typeorm'; |
| 10 | +import { User } from '../users/user.entity'; |
| 11 | +import { Department } from '../departments/department.entity'; |
| 12 | +import { Category } from '../categories/category.entity'; |
| 13 | +import { AssetStatus, AssetCondition, StellarStatus } from './enums'; |
| 14 | + |
| 15 | +@Entity('assets') |
| 16 | +export class Asset { |
| 17 | + @PrimaryGeneratedColumn('uuid') |
| 18 | + id: string; |
| 19 | + |
| 20 | + @Column({ unique: true }) |
| 21 | + assetId: string; |
| 22 | + |
| 23 | + @Column() |
| 24 | + name: string; |
| 25 | + |
| 26 | + @Column({ nullable: true, type: 'text' }) |
| 27 | + description: string | null; |
| 28 | + |
| 29 | + @ManyToOne(() => Category, { eager: true, nullable: false }) |
| 30 | + @JoinColumn({ name: 'categoryId' }) |
| 31 | + category: Category; |
| 32 | + |
| 33 | + @Column({ nullable: true }) |
| 34 | + serialNumber: string | null; |
| 35 | + |
| 36 | + @Column({ nullable: true, type: 'date' }) |
| 37 | + purchaseDate: Date | null; |
| 38 | + |
| 39 | + @Column({ nullable: true, type: 'decimal', precision: 15, scale: 2 }) |
| 40 | + purchasePrice: number | null; |
| 41 | + |
| 42 | + @Column({ nullable: true, type: 'decimal', precision: 15, scale: 2 }) |
| 43 | + currentValue: number | null; |
| 44 | + |
| 45 | + @Column({ nullable: true, type: 'date' }) |
| 46 | + warrantyExpiration: Date | null; |
| 47 | + |
| 48 | + @Column({ type: 'enum', enum: AssetStatus, default: AssetStatus.ACTIVE }) |
| 49 | + status: AssetStatus; |
| 50 | + |
| 51 | + @Column({ type: 'enum', enum: AssetCondition, default: AssetCondition.NEW }) |
| 52 | + condition: AssetCondition; |
| 53 | + |
| 54 | + @ManyToOne(() => Department, { eager: true, nullable: false }) |
| 55 | + @JoinColumn({ name: 'departmentId' }) |
| 56 | + department: Department; |
| 57 | + |
| 58 | + @Column({ nullable: true }) |
| 59 | + location: string | null; |
| 60 | + |
| 61 | + @ManyToOne(() => User, { eager: true, nullable: true }) |
| 62 | + @JoinColumn({ name: 'assignedToId' }) |
| 63 | + assignedTo: User | null; |
| 64 | + |
| 65 | + @Column({ type: 'simple-array', nullable: true }) |
| 66 | + imageUrls: string[] | null; |
| 67 | + |
| 68 | + @Column({ type: 'jsonb', nullable: true }) |
| 69 | + customFields: Record<string, unknown> | null; |
| 70 | + |
| 71 | + @Column({ type: 'simple-array', nullable: true }) |
| 72 | + tags: string[] | null; |
| 73 | + |
| 74 | + @Column({ nullable: true }) |
| 75 | + manufacturer: string | null; |
| 76 | + |
| 77 | + @Column({ nullable: true }) |
| 78 | + model: string | null; |
| 79 | + |
| 80 | + @Column({ nullable: true }) |
| 81 | + barcode: string | null; |
| 82 | + |
| 83 | + @Column({ nullable: true }) |
| 84 | + qrCode: string | null; |
| 85 | + |
| 86 | + @Column({ nullable: true, type: 'text' }) |
| 87 | + notes: string | null; |
| 88 | + |
| 89 | + @Column({ nullable: true }) |
| 90 | + stellarAssetId: string | null; |
| 91 | + |
| 92 | + @Column({ nullable: true }) |
| 93 | + stellarTxHash: string | null; |
| 94 | + |
| 95 | + @Column({ type: 'enum', enum: StellarStatus, default: StellarStatus.NOT_REGISTERED }) |
| 96 | + stellarStatus: StellarStatus; |
| 97 | + |
| 98 | + @ManyToOne(() => User, { nullable: true }) |
| 99 | + @JoinColumn({ name: 'createdById' }) |
| 100 | + createdBy: User | null; |
| 101 | + |
| 102 | + @ManyToOne(() => User, { nullable: true }) |
| 103 | + @JoinColumn({ name: 'updatedById' }) |
| 104 | + updatedBy: User | null; |
| 105 | + |
| 106 | + @CreateDateColumn() |
| 107 | + createdAt: Date; |
| 108 | + |
| 109 | + @UpdateDateColumn() |
| 110 | + updatedAt: Date; |
| 111 | +} |
0 commit comments