feat(participants): Added created/updated at
This commit is contained in:
parent
0ad9eeb52f
commit
a4480589a0
@ -5,9 +5,11 @@ import {
|
||||
IsOptional,
|
||||
IsPhoneNumber,
|
||||
|
||||
IsPositive,
|
||||
|
||||
IsString
|
||||
} from "class-validator";
|
||||
import { Column, Entity, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
||||
import { BeforeInsert, BeforeUpdate, Column, Entity, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
||||
import { config } from '../../config';
|
||||
import { ResponseParticipant } from '../responses/ResponseParticipant';
|
||||
import { Address } from "./Address";
|
||||
@ -83,6 +85,27 @@ export abstract class Participant {
|
||||
@IsString()
|
||||
created_via?: 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.
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { IsInt, IsObject, IsOptional, IsString } from "class-validator";
|
||||
import { IsInt, IsObject, IsOptional, IsPositive, IsString } from "class-validator";
|
||||
import { Address } from '../entities/Address';
|
||||
import { Participant } from '../entities/Participant';
|
||||
import { ResponseObjectType } from '../enums/ResponseObjectType';
|
||||
@ -63,6 +63,14 @@ export abstract class ResponseParticipant implements IResponse {
|
||||
@IsObject()
|
||||
address?: Address;
|
||||
|
||||
@IsInt()
|
||||
@IsPositive()
|
||||
created_at: number;
|
||||
|
||||
@IsInt()
|
||||
@IsPositive()
|
||||
updated_at: number;
|
||||
|
||||
/**
|
||||
* Creates a ResponseParticipant object from a participant.
|
||||
* @param participant The participant the response shall be build for.
|
||||
@ -76,5 +84,7 @@ export abstract class ResponseParticipant implements IResponse {
|
||||
this.phone = participant.phone;
|
||||
this.email = participant.email;
|
||||
this.address = participant.address;
|
||||
this.created_at = participant.created_at;
|
||||
this.updated_at = participant.updated_at;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user