Fixed the cirvular import BS

ref #11
This commit is contained in:
2020-12-02 17:40:03 +01:00
parent 5bf978d32d
commit ac0ce799f9
8 changed files with 92 additions and 16 deletions

View File

@@ -1,12 +1,86 @@
import { Entity, OneToMany } from "typeorm";
import { Participant } from "./Participant";
import { PrimaryGeneratedColumn, Column, OneToMany, ManyToOne, Entity } from "typeorm";
import {
IsEmail,
IsInt,
IsNotEmpty,
IsOptional,
IsPhoneNumber,
IsString,
} from "class-validator";
import { Address } from "./Address";
import { Donation } from "./Donation";
import { RunnerGroup } from "./RunnerGroup";
/**
* Defines a group's contact.
*/
@Entity()
export class GroupContact extends Participant{
export class GroupContact {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsOptional()
@IsInt()
id: number;
/**
* The contact's first name.
*/
@Column()
@IsNotEmpty()
@IsString()
firstname: string;
/**
* The contact's middle name.
* Optional
*/
@Column()
@IsOptional()
@IsString()
middlename?: string;
/**
* The contact's last name.
*/
@Column()
@IsOptional()
@IsString()
lastname: string;
/**
* The contact's address.
* Optional
*/
@IsOptional()
@ManyToOne(() => Address, address => address.participants)
address?: Address;
/**
* The contact's phone number.
* Optional
*/
@Column()
@IsOptional()
@IsPhoneNumber("DE")
phone?: string;
/**
* The contact's email address.
* Optional
*/
@Column()
@IsOptional()
@IsEmail()
email?: string;
/**
* Used to link the contact as the donor of a donation.
*/
@OneToMany(() => Donation, donation => donation.donor)
donations: Donation[];
/**
* Used to link runners to donations.
*/