Handout management
This commit is contained in:
33
api/src/model/entitites/customer.entity.ts
Normal file
33
api/src/model/entitites/customer.entity.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { Key } from './key.entity';
|
||||
import { KeySystem } from './system.entity';
|
||||
import { ICustomer } from '../interface';
|
||||
|
||||
@Entity()
|
||||
export class Customer implements ICustomer {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ nullable: false, unique: false })
|
||||
name: string;
|
||||
|
||||
@OneToMany(() => Key, (key) => key.customer)
|
||||
keys: Key[];
|
||||
|
||||
@ManyToOne(() => KeySystem)
|
||||
system: KeySystem;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn({ name: 'updatet_at' })
|
||||
updatedAt: Date;
|
||||
}
|
||||
@@ -4,3 +4,5 @@ export * from './role.entity';
|
||||
export * from './cylinder.entity';
|
||||
export * from './key.entity';
|
||||
export * from './key_activity.entity';
|
||||
export * from './customer.entity';
|
||||
export * from './key-handout.entity';
|
||||
|
||||
38
api/src/model/entitites/key-handout.entity.ts
Normal file
38
api/src/model/entitites/key-handout.entity.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { Key } from './key.entity';
|
||||
import { Customer } from './customer.entity';
|
||||
|
||||
@Entity()
|
||||
export class KeyHandout {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@ManyToOne(() => Key)
|
||||
key: Key;
|
||||
|
||||
@Column()
|
||||
direction: 'out' | 'return';
|
||||
|
||||
@ManyToOne(() => Customer)
|
||||
customer: Customer;
|
||||
|
||||
@Column()
|
||||
timestamp: Date;
|
||||
|
||||
@CreateDateColumn()
|
||||
created: Date;
|
||||
|
||||
@BeforeInsert()
|
||||
insertTimestamp() {
|
||||
if (this.timestamp == null) {
|
||||
this.timestamp = new Date();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from 'typeorm';
|
||||
import { Cylinder } from './cylinder.entity';
|
||||
import { IKey } from '../interface/key.interface';
|
||||
import { Customer } from './customer.entity';
|
||||
|
||||
@Entity()
|
||||
export class Key implements IKey {
|
||||
@@ -26,6 +27,9 @@ export class Key implements IKey {
|
||||
@ManyToOne(() => Cylinder, (cylinder) => cylinder.keys)
|
||||
cylinder: Cylinder;
|
||||
|
||||
@ManyToOne(() => Customer, (customer) => customer.keys)
|
||||
customer: Customer;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import { User } from './user.entity';
|
||||
import { IKey } from '../interface/key.interface';
|
||||
import { Cylinder } from './cylinder.entity';
|
||||
import { Customer } from './customer.entity';
|
||||
|
||||
@Entity()
|
||||
export class KeyActivity implements IKey {
|
||||
@@ -29,6 +30,9 @@ export class KeyActivity implements IKey {
|
||||
@ManyToOne(() => Cylinder)
|
||||
cylinder: Cylinder;
|
||||
|
||||
@ManyToOne(() => Customer)
|
||||
customer: Customer;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user