parent
e3133e0d5e
commit
a8956223c2
@ -1,5 +1,5 @@
|
|||||||
import { Entity, Column, ManyToOne } from "typeorm";
|
import { Entity, Column, ManyToOne, ChildEntity } from "typeorm";
|
||||||
import { IsInt, IsNotEmpty, IsPositive,} from "class-validator";
|
import { IsInt, IsNotEmpty, IsPositive, } from "class-validator";
|
||||||
import { Donation } from "./Donation";
|
import { Donation } from "./Donation";
|
||||||
import { Runner } from "./Runner";
|
import { Runner } from "./Runner";
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ import { Runner } from "./Runner";
|
|||||||
* Defines a distance based donation.
|
* Defines a distance based donation.
|
||||||
* Here people donate a certain amout per kilometer
|
* Here people donate a certain amout per kilometer
|
||||||
*/
|
*/
|
||||||
@Entity()
|
@ChildEntity()
|
||||||
export class DistanceDonation extends Donation {
|
export class DistanceDonation extends Donation {
|
||||||
/**
|
/**
|
||||||
* The runner associated.
|
* The runner associated.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity } from "typeorm";
|
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity, TableInheritance } from "typeorm";
|
||||||
import {
|
import {
|
||||||
IsInt,
|
IsInt,
|
||||||
IsNotEmpty,
|
IsNotEmpty,
|
||||||
@ -11,6 +11,7 @@ import { Participant } from "./Participant";
|
|||||||
* Defines the donation interface.
|
* Defines the donation interface.
|
||||||
*/
|
*/
|
||||||
@Entity()
|
@Entity()
|
||||||
|
@TableInheritance({ column: { name: "type", type: "varchar" } })
|
||||||
export abstract class Donation {
|
export abstract class Donation {
|
||||||
/**
|
/**
|
||||||
* Autogenerated unique id (primary key).
|
* Autogenerated unique id (primary key).
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { Entity, Column } from "typeorm";
|
import { Entity, Column, ChildEntity } from "typeorm";
|
||||||
import { IsBoolean } from "class-validator";
|
import { IsBoolean } from "class-validator";
|
||||||
import { Participant } from "./Participant";
|
import { Participant } from "./Participant";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a donor.
|
* Defines a donor.
|
||||||
*/
|
*/
|
||||||
@Entity()
|
@ChildEntity()
|
||||||
export class Donor extends Participant {
|
export class Donor extends Participant {
|
||||||
/**
|
/**
|
||||||
* Does this donor need a receipt?.
|
* Does this donor need a receipt?.
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { Entity, Column } from "typeorm";
|
import { Entity, Column, ChildEntity } from "typeorm";
|
||||||
import { IsInt, IsPositive,} from "class-validator";
|
import { IsInt, IsPositive, } from "class-validator";
|
||||||
import { Donation } from "./Donation";
|
import { Donation } from "./Donation";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a fixed donation.
|
* Defines a fixed donation.
|
||||||
*/
|
*/
|
||||||
@Entity()
|
@ChildEntity()
|
||||||
export class FixedDonation extends Donation {
|
export class FixedDonation extends Donation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PrimaryGeneratedColumn, Column, OneToMany, ManyToOne, Entity } from "typeorm";
|
import { PrimaryGeneratedColumn, Column, OneToMany, ManyToOne, Entity, TableInheritance } from "typeorm";
|
||||||
import {
|
import {
|
||||||
IsEmail,
|
IsEmail,
|
||||||
IsInt,
|
IsInt,
|
||||||
@ -15,6 +15,7 @@ import { Donation } from "./Donation";
|
|||||||
* Defines the participant interface.
|
* Defines the participant interface.
|
||||||
*/
|
*/
|
||||||
@Entity()
|
@Entity()
|
||||||
|
@TableInheritance({ column: { name: "type", type: "varchar" } })
|
||||||
export abstract class Participant {
|
export abstract class Participant {
|
||||||
/**
|
/**
|
||||||
* Autogenerated unique id (primary key).
|
* Autogenerated unique id (primary key).
|
||||||
@ -36,7 +37,7 @@ export abstract class Participant {
|
|||||||
* The participant's middle name.
|
* The participant's middle name.
|
||||||
* Optional
|
* Optional
|
||||||
*/
|
*/
|
||||||
@Column({nullable: true})
|
@Column({ nullable: true })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
middlename?: string;
|
middlename?: string;
|
||||||
@ -60,7 +61,7 @@ export abstract class Participant {
|
|||||||
* The participant's phone number.
|
* The participant's phone number.
|
||||||
* Optional
|
* Optional
|
||||||
*/
|
*/
|
||||||
@Column({nullable: true})
|
@Column({ nullable: true })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsPhoneNumber("DE")
|
@IsPhoneNumber("DE")
|
||||||
phone?: string;
|
phone?: string;
|
||||||
@ -69,7 +70,7 @@ export abstract class Participant {
|
|||||||
* The participant's email address.
|
* The participant's email address.
|
||||||
* Optional
|
* Optional
|
||||||
*/
|
*/
|
||||||
@Column({nullable: true})
|
@Column({ nullable: true })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsEmail()
|
@IsEmail()
|
||||||
email?: string;
|
email?: string;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Entity, Column, OneToMany, ManyToOne } from "typeorm";
|
import { Entity, Column, OneToMany, ManyToOne, ChildEntity } from "typeorm";
|
||||||
import { IsInt, IsNotEmpty,} from "class-validator";
|
import { IsInt, IsNotEmpty, } from "class-validator";
|
||||||
import { Participant } from "./Participant";
|
import { Participant } from "./Participant";
|
||||||
import { RunnerGroup } from "./RunnerGroup";
|
import { RunnerGroup } from "./RunnerGroup";
|
||||||
import { DistanceDonation } from "./DistanceDonation";
|
import { DistanceDonation } from "./DistanceDonation";
|
||||||
@ -9,7 +9,7 @@ import { Scan } from "./Scan";
|
|||||||
/**
|
/**
|
||||||
* Defines a runner.
|
* Defines a runner.
|
||||||
*/
|
*/
|
||||||
@Entity()
|
@ChildEntity()
|
||||||
export class Runner extends Participant {
|
export class Runner extends Participant {
|
||||||
/**
|
/**
|
||||||
* The runner's associated group.
|
* The runner's associated group.
|
||||||
@ -37,7 +37,7 @@ export class Runner extends Participant {
|
|||||||
scans: Scan[];
|
scans: Scan[];
|
||||||
|
|
||||||
@IsInt()
|
@IsInt()
|
||||||
public get distance() : number {
|
public get distance(): number {
|
||||||
return this.scans.filter(scan => scan.valid === true).reduce((sum, current) => sum + current.distance, 0);
|
return this.scans.filter(scan => scan.valid === true).reduce((sum, current) => sum + current.distance, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity } from "typeorm";
|
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity, TableInheritance } from "typeorm";
|
||||||
import {
|
import {
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
IsInt,
|
IsInt,
|
||||||
@ -12,6 +12,7 @@ import { Runner } from "./Runner";
|
|||||||
* Defines the scan interface.
|
* Defines the scan interface.
|
||||||
*/
|
*/
|
||||||
@Entity()
|
@Entity()
|
||||||
|
@TableInheritance({ column: { name: "type", type: "varchar" } })
|
||||||
export abstract class Scan {
|
export abstract class Scan {
|
||||||
/**
|
/**
|
||||||
* Autogenerated unique id (primary key).
|
* Autogenerated unique id (primary key).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity } from "typeorm";
|
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity, ChildEntity } from "typeorm";
|
||||||
import {
|
import {
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
IsDateString,
|
IsDateString,
|
||||||
@ -16,7 +16,7 @@ import { ScanStation } from "./ScanStation";
|
|||||||
/**
|
/**
|
||||||
* Defines the scan interface.
|
* Defines the scan interface.
|
||||||
*/
|
*/
|
||||||
@Entity()
|
@ChildEntity()
|
||||||
export class TrackScan extends Scan {
|
export class TrackScan extends Scan {
|
||||||
/**
|
/**
|
||||||
* The associated track.
|
* The associated track.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user