feat(entities): Added created/updated at to all entities
This commit is contained in:
parent
a4480589a0
commit
728f8a14e9
@ -1,8 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
|
IsInt,
|
||||||
IsNotEmpty,
|
IsNotEmpty,
|
||||||
|
IsPositive,
|
||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, PrimaryColumn } from "typeorm";
|
import { BeforeInsert, BeforeUpdate, Column, Entity, PrimaryColumn } from "typeorm";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the ConfigFlag entity.
|
* Defines the ConfigFlag entity.
|
||||||
@ -24,4 +26,25 @@ export class ConfigFlag {
|
|||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
value: string;
|
value: string;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
IsInt
|
IsInt,
|
||||||
|
IsPositive
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
import { BeforeInsert, BeforeUpdate, Column, Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
||||||
import { ResponseDonation } from '../responses/ResponseDonation';
|
import { ResponseDonation } from '../responses/ResponseDonation';
|
||||||
import { Donor } from './Donor';
|
import { Donor } from './Donor';
|
||||||
|
|
||||||
@ -40,6 +41,27 @@ export abstract class Donation {
|
|||||||
@IsInt()
|
@IsInt()
|
||||||
paidAmount: number;
|
paidAmount: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
|
@ -5,9 +5,11 @@ import {
|
|||||||
IsOptional,
|
IsOptional,
|
||||||
IsPhoneNumber,
|
IsPhoneNumber,
|
||||||
|
|
||||||
|
IsPositive,
|
||||||
|
|
||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
import { BeforeInsert, BeforeUpdate, Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { config } from '../../config';
|
import { config } from '../../config';
|
||||||
import { ResponseGroupContact } from '../responses/ResponseGroupContact';
|
import { ResponseGroupContact } from '../responses/ResponseGroupContact';
|
||||||
import { Address } from "./Address";
|
import { Address } from "./Address";
|
||||||
@ -81,6 +83,27 @@ export class GroupContact {
|
|||||||
@OneToMany(() => RunnerGroup, group => group.contact, { nullable: true })
|
@OneToMany(() => RunnerGroup, group => group.contact, { nullable: true })
|
||||||
groups: RunnerGroup[];
|
groups: RunnerGroup[];
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
IsEnum,
|
IsEnum,
|
||||||
IsInt,
|
IsInt,
|
||||||
IsNotEmpty
|
IsNotEmpty,
|
||||||
|
IsPositive
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
import { BeforeInsert, BeforeUpdate, Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { PermissionAction } from '../enums/PermissionAction';
|
import { PermissionAction } from '../enums/PermissionAction';
|
||||||
import { PermissionTarget } from '../enums/PermissionTargets';
|
import { PermissionTarget } from '../enums/PermissionTargets';
|
||||||
import { ResponsePermission } from '../responses/ResponsePermission';
|
import { ResponsePermission } from '../responses/ResponsePermission';
|
||||||
@ -45,6 +46,27 @@ export class Permission {
|
|||||||
@IsEnum(PermissionAction)
|
@IsEnum(PermissionAction)
|
||||||
action: PermissionAction;
|
action: PermissionAction;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn this into a string for exporting and jwts.
|
* Turn this into a string for exporting and jwts.
|
||||||
* Mainly used to shrink the size of jwts (otherwise the would contain entire objects).
|
* Mainly used to shrink the size of jwts (otherwise the would contain entire objects).
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { IsInt } from 'class-validator';
|
import { IsInt, IsPositive } from 'class-validator';
|
||||||
import { Entity, OneToMany, PrimaryGeneratedColumn, TableInheritance } from 'typeorm';
|
import { BeforeInsert, BeforeUpdate, Column, Entity, OneToMany, PrimaryGeneratedColumn, TableInheritance } from 'typeorm';
|
||||||
import { ResponsePrincipal } from '../responses/ResponsePrincipal';
|
import { ResponsePrincipal } from '../responses/ResponsePrincipal';
|
||||||
import { Permission } from './Permission';
|
import { Permission } from './Permission';
|
||||||
|
|
||||||
@ -23,6 +23,27 @@ export abstract class Principal {
|
|||||||
@OneToMany(() => Permission, permission => permission.principal, { nullable: true })
|
@OneToMany(() => Permission, permission => permission.principal, { nullable: true })
|
||||||
permissions: Permission[];
|
permissions: Permission[];
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
|
@ -3,9 +3,10 @@ import {
|
|||||||
|
|
||||||
IsInt,
|
IsInt,
|
||||||
|
|
||||||
IsOptional
|
IsOptional,
|
||||||
|
IsPositive
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
import { BeforeInsert, BeforeUpdate, Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { RunnerCardIdOutOfRangeError } from '../../errors/RunnerCardErrors';
|
import { RunnerCardIdOutOfRangeError } from '../../errors/RunnerCardErrors';
|
||||||
import { ResponseRunnerCard } from '../responses/ResponseRunnerCard';
|
import { ResponseRunnerCard } from '../responses/ResponseRunnerCard';
|
||||||
import { Runner } from "./Runner";
|
import { Runner } from "./Runner";
|
||||||
@ -48,6 +49,27 @@ export class RunnerCard {
|
|||||||
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
|
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
|
||||||
scans: TrackScan[];
|
scans: TrackScan[];
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a ean-13 compliant string for barcode generation.
|
* Generates a ean-13 compliant string for barcode generation.
|
||||||
*/
|
*/
|
||||||
|
@ -2,9 +2,10 @@ import {
|
|||||||
IsInt,
|
IsInt,
|
||||||
IsNotEmpty,
|
IsNotEmpty,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
|
IsPositive,
|
||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
import { BeforeInsert, BeforeUpdate, Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
||||||
import { ResponseRunnerGroup } from '../responses/ResponseRunnerGroup';
|
import { ResponseRunnerGroup } from '../responses/ResponseRunnerGroup';
|
||||||
import { GroupContact } from "./GroupContact";
|
import { GroupContact } from "./GroupContact";
|
||||||
import { Runner } from "./Runner";
|
import { Runner } from "./Runner";
|
||||||
@ -46,6 +47,27 @@ export abstract class RunnerGroup {
|
|||||||
@OneToMany(() => Runner, runner => runner.group, { nullable: true })
|
@OneToMany(() => Runner, runner => runner.group, { nullable: true })
|
||||||
runners: Runner[];
|
runners: Runner[];
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the total distance ran by this group's runners based on all their valid scans.
|
* Returns the total distance ran by this group's runners based on all their valid scans.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
|
|
||||||
IsPositive
|
IsPositive
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
import { BeforeInsert, BeforeUpdate, Column, Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
||||||
import { ResponseScan } from '../responses/ResponseScan';
|
import { ResponseScan } from '../responses/ResponseScan';
|
||||||
import { Runner } from "./Runner";
|
import { Runner } from "./Runner";
|
||||||
|
|
||||||
@ -40,6 +40,27 @@ export class Scan {
|
|||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
valid: boolean = true;
|
valid: boolean = true;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The scan's distance in meters.
|
* The scan's distance in meters.
|
||||||
* This is the "real" value used by "normal" scans..
|
* This is the "real" value used by "normal" scans..
|
||||||
|
@ -3,9 +3,10 @@ import {
|
|||||||
IsInt,
|
IsInt,
|
||||||
IsNotEmpty,
|
IsNotEmpty,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
|
IsPositive,
|
||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
import { BeforeInsert, BeforeUpdate, Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { ResponseScanStation } from '../responses/ResponseScanStation';
|
import { ResponseScanStation } from '../responses/ResponseScanStation';
|
||||||
import { Track } from "./Track";
|
import { Track } from "./Track";
|
||||||
import { TrackScan } from "./TrackScan";
|
import { TrackScan } from "./TrackScan";
|
||||||
@ -78,6 +79,27 @@ export class ScanStation {
|
|||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
enabled?: boolean = true;
|
enabled?: boolean = true;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { IsInt, IsOptional, IsString } from "class-validator";
|
import { IsInt, IsOptional, IsPositive, IsString } from "class-validator";
|
||||||
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
import { BeforeInsert, BeforeUpdate, Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { ResponseStatsClient } from '../responses/ResponseStatsClient';
|
import { ResponseStatsClient } from '../responses/ResponseStatsClient';
|
||||||
/**
|
/**
|
||||||
* Defines the StatsClient entity.
|
* Defines the StatsClient entity.
|
||||||
@ -47,6 +47,27 @@ export class StatsClient {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
cleartextkey?: string;
|
cleartextkey?: string;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
IsPositive,
|
IsPositive,
|
||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
import { BeforeInsert, BeforeUpdate, Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { ResponseTrack } from '../responses/ResponseTrack';
|
import { ResponseTrack } from '../responses/ResponseTrack';
|
||||||
import { ScanStation } from "./ScanStation";
|
import { ScanStation } from "./ScanStation";
|
||||||
import { TrackScan } from "./TrackScan";
|
import { TrackScan } from "./TrackScan";
|
||||||
@ -63,6 +63,27 @@ export class Track {
|
|||||||
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
|
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
|
||||||
scans: TrackScan[];
|
scans: TrackScan[];
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
|
@ -3,9 +3,10 @@ import {
|
|||||||
IsInt,
|
IsInt,
|
||||||
IsNotEmpty,
|
IsNotEmpty,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
|
IsPositive,
|
||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
import { BeforeInsert, BeforeUpdate, Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { PermissionAction } from '../enums/PermissionAction';
|
import { PermissionAction } from '../enums/PermissionAction';
|
||||||
import { User } from './User';
|
import { User } from './User';
|
||||||
|
|
||||||
@ -53,6 +54,27 @@ export class UserAction {
|
|||||||
@IsString()
|
@IsString()
|
||||||
changed: string;
|
changed: string;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true, readonly: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', nullable: true })
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
updated_at: number;
|
||||||
|
|
||||||
|
@BeforeInsert()
|
||||||
|
public setCreatedAt() {
|
||||||
|
this.created_at = Math.floor(Date.now() / 1000);
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
public setUpdatedAt() {
|
||||||
|
this.updated_at = Math.floor(Date.now() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user