-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocation.entity.ts
More file actions
64 lines (54 loc) · 1.52 KB
/
location.entity.ts
File metadata and controls
64 lines (54 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import {
Column,
Entity,
OneToMany,
PrimaryGeneratedColumn,
Tree,
TreeChildren,
TreeParent,
} from 'typeorm';
import { DeviceEntity } from '../../inventory/device/device.entity';
import { ConsumableLocationEntity } from '../../inventory/consumable/consumable-location.entity';
export enum LocationType {
NONE = 0, // Keine Angabe
LOCATION = 1, // Standort
BUILDING = 2, // Gebäude
BUILDING_PART = 3, // Gebäudeteil
GARAGE = 4, // Garage
VEHICLE = 100, // Fahrzeug
CONTAINER = 101, // Container
TRAILER = 102, // Anhänger
DEVICE_COMPARTMENT = 103, // Gerätefach
CREW_ROOM = 104, // Mannschaftsraum/Fahrerraum
ROOM = 200, // Raum
SHELF = 201, // Regal
SHELF_COMPARTMENT = 202, // Regalfach
DRAWER = 203, // Schublade
}
@Entity()
@Tree('closure-table')
export class LocationEntity {
@PrimaryGeneratedColumn('increment', { type: 'int' })
id: number;
@Column({ type: 'varchar', length: 100 })
name: string;
@Column({ type: 'text', nullable: true })
description?: string;
@Column({
type: 'enum',
enum: LocationType,
default: LocationType.NONE,
})
type: LocationType;
// TODO optional Kooridnaten
@TreeChildren()
children: LocationEntity[];
@Column({ type: 'int', nullable: true })
parentId?: number;
@TreeParent({ onDelete: 'SET NULL' })
parent?: LocationEntity | null;
@OneToMany(() => DeviceEntity, (x) => x.location)
devices: DeviceEntity[];
@OneToMany(() => ConsumableLocationEntity, (x) => x.location)
consumableLocations: ConsumableLocationEntity[];
}