Moved to a "cleaner" directory structure

ref #11
This commit is contained in:
2020-12-03 20:38:47 +01:00
parent 3a04bb54bd
commit e8727ca922
27 changed files with 145 additions and 145 deletions

View File

@@ -0,0 +1,83 @@
import { PrimaryGeneratedColumn, Column, OneToMany, ManyToOne, Entity, TableInheritance } from "typeorm";
import {
IsEmail,
IsInt,
IsNotEmpty,
IsOptional,
IsPhoneNumber,
IsPositive,
IsString,
} from "class-validator";
import { Address } from "./Address";
import { Donation } from "./Donation";
/**
* Defines the participant interface.
*/
@Entity()
@TableInheritance({ column: { name: "type", type: "varchar" } })
export abstract class Participant {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsOptional()
@IsInt()
id: number;
/**
* The participant's first name.
*/
@Column()
@IsNotEmpty()
@IsString()
firstname: string;
/**
* The participant's middle name.
* Optional
*/
@Column({ nullable: true })
@IsOptional()
@IsString()
middlename?: string;
/**
* The participant's last name.
*/
@Column()
@IsNotEmpty()
@IsString()
lastname: string;
/**
* The participant's address.
* Optional
*/
@ManyToOne(() => Address, address => address.participants, { nullable: true })
address?: Address;
/**
* The participant's phone number.
* Optional
*/
@Column({ nullable: true })
@IsOptional()
@IsPhoneNumber("DE")
phone?: string;
/**
* The participant's email address.
* Optional
*/
@Column({ nullable: true })
@IsOptional()
@IsEmail()
email?: string;
/**
* Used to link the participant as the donor of a donation.
*/
@OneToMany(() => Donation, donation => donation.donor, { nullable: true })
donations: Donation[];
}