Dashboard
This commit is contained in:
28
api/src/model/entitites/activity.entity.ts
Normal file
28
api/src/model/entitites/activity.entity.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { User } from './user.entity';
|
||||
import { KeySystem } from './system.entity';
|
||||
|
||||
@Entity()
|
||||
export class Activity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@ManyToOne(() => User)
|
||||
user: User;
|
||||
|
||||
@ManyToOne(() => KeySystem)
|
||||
system: KeySystem;
|
||||
|
||||
@Column({ type: 'text'})
|
||||
message: string;
|
||||
}
|
||||
@@ -6,3 +6,4 @@ export * from './key.entity';
|
||||
export * from './key_activity.entity';
|
||||
export * from './customer.entity';
|
||||
export * from './key-handout.entity';
|
||||
export * from './activity.entity';
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from 'typeorm';
|
||||
import { Key } from './key.entity';
|
||||
import { Customer } from './customer.entity';
|
||||
import { User } from './user.entity';
|
||||
|
||||
@Entity()
|
||||
export class KeyHandout {
|
||||
@@ -29,6 +30,9 @@ export class KeyHandout {
|
||||
@CreateDateColumn()
|
||||
created: Date;
|
||||
|
||||
@ManyToOne(() => User)
|
||||
user: User;
|
||||
|
||||
@BeforeInsert()
|
||||
insertTimestamp() {
|
||||
if (this.timestamp == null) {
|
||||
|
||||
@@ -6,12 +6,14 @@ import {
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { Cylinder } from './cylinder.entity';
|
||||
import { IKey } from '../interface/key.interface';
|
||||
import { Customer } from './customer.entity';
|
||||
import { KeyHandout } from './key-handout.entity';
|
||||
|
||||
@Entity()
|
||||
export class Key implements IKey {
|
||||
@@ -45,4 +47,7 @@ export class Key implements IKey {
|
||||
|
||||
@DeleteDateColumn()
|
||||
deletedAt: Date;
|
||||
|
||||
@OneToMany(() => KeyHandout, (handout) => handout.key)
|
||||
handouts: KeyHandout[];
|
||||
}
|
||||
|
||||
10
api/src/model/repositories/activity.repository.ts
Normal file
10
api/src/model/repositories/activity.repository.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Repository, DataSource } from 'typeorm';
|
||||
import { Activity } from '../entitites';
|
||||
|
||||
@Injectable()
|
||||
export class ActivityRepository extends Repository<Activity> {
|
||||
constructor(dataSource: DataSource) {
|
||||
super(Activity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
@@ -6,3 +6,4 @@ export * from './cylinder.repository';
|
||||
export * from './key.repository';
|
||||
export * from './key_activity.repository';
|
||||
export * from './customer.repository';
|
||||
export * from './activity.repository';
|
||||
|
||||
Reference in New Issue
Block a user