Implemented the first route of the toResponse normalisationf for all classes
ref #67
This commit is contained in:
parent
a4b0dfe43e
commit
58156e0d61
@ -1,5 +1,6 @@
|
|||||||
import { IsInt, IsOptional } from "class-validator";
|
import { IsInt, IsOptional } from "class-validator";
|
||||||
import { ChildEntity, ManyToOne, OneToMany } from "typeorm";
|
import { ChildEntity, ManyToOne, OneToMany } from "typeorm";
|
||||||
|
import { ResponseRunnerOrganisation } from '../responses/ResponseRunnerOrganisation';
|
||||||
import { Address } from './Address';
|
import { Address } from './Address';
|
||||||
import { IAddressUser } from './IAddressUser';
|
import { IAddressUser } from './IAddressUser';
|
||||||
import { Runner } from './Runner';
|
import { Runner } from './Runner';
|
||||||
@ -54,4 +55,11 @@ export class RunnerOrganisation extends RunnerGroup implements IAddressUser {
|
|||||||
public get distanceDonationAmount(): number {
|
public get distanceDonationAmount(): number {
|
||||||
return this.allRunners.reduce((sum, current) => sum + current.distanceDonationAmount, 0);
|
return this.allRunners.reduce((sum, current) => sum + current.distanceDonationAmount, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns this entity into it's response class.
|
||||||
|
*/
|
||||||
|
public toResponse(): ResponseRunnerOrganisation {
|
||||||
|
return new ResponseRunnerOrganisation(this);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
import { IsNotEmpty } from "class-validator";
|
import { IsNotEmpty } from "class-validator";
|
||||||
import { ChildEntity, ManyToOne } from "typeorm";
|
import { ChildEntity, ManyToOne } from "typeorm";
|
||||||
|
import { ResponseRunnerTeam } from '../responses/ResponseRunnerTeam';
|
||||||
import { RunnerGroup } from "./RunnerGroup";
|
import { RunnerGroup } from "./RunnerGroup";
|
||||||
import { RunnerOrganisation } from "./RunnerOrganisation";
|
import { RunnerOrganisation } from "./RunnerOrganisation";
|
||||||
|
|
||||||
@ -17,4 +18,11 @@ export class RunnerTeam extends RunnerGroup {
|
|||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@ManyToOne(() => RunnerOrganisation, org => org.teams, { nullable: true })
|
@ManyToOne(() => RunnerOrganisation, org => org.teams, { nullable: true })
|
||||||
parentGroup?: RunnerOrganisation;
|
parentGroup?: RunnerOrganisation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns this entity into it's response class.
|
||||||
|
*/
|
||||||
|
public toResponse(): ResponseRunnerTeam {
|
||||||
|
return new ResponseRunnerTeam(this);
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ import {
|
|||||||
IsPositive
|
IsPositive
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
||||||
|
import { ResponseScan } from '../responses/ResponseScan';
|
||||||
import { Runner } from "./Runner";
|
import { Runner } from "./Runner";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,4 +47,11 @@ export abstract class Scan {
|
|||||||
@Column()
|
@Column()
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
valid: boolean = true;
|
valid: boolean = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns this entity into it's response class.
|
||||||
|
*/
|
||||||
|
public toResponse(): ResponseScan {
|
||||||
|
return new ResponseScan(this);
|
||||||
|
}
|
||||||
}
|
}
|
@ -61,4 +61,11 @@ export class ScanStation {
|
|||||||
*/
|
*/
|
||||||
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
|
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
|
||||||
scans: TrackScan[];
|
scans: TrackScan[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns this entity into it's response class.
|
||||||
|
*/
|
||||||
|
public toResponse() {
|
||||||
|
return new Error("NotImplemented");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { IsInt, IsOptional, IsString } from "class-validator";
|
import { IsInt, IsOptional, IsString } from "class-validator";
|
||||||
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { ResponseStatsClient } from '../responses/ResponseStatsClient';
|
||||||
/**
|
/**
|
||||||
* Defines the StatsClient entity.
|
* Defines the StatsClient entity.
|
||||||
* StatsClients can be used to access the protected parts of the stats api (top runners, donators and so on).
|
* StatsClients can be used to access the protected parts of the stats api (top runners, donators and so on).
|
||||||
@ -45,4 +46,11 @@ export class StatsClient {
|
|||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
cleartextkey?: string;
|
cleartextkey?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns this entity into it's response class.
|
||||||
|
*/
|
||||||
|
public toResponse(): ResponseStatsClient {
|
||||||
|
return new ResponseStatsClient(this);
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ import {
|
|||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { ResponseTrack } from '../responses/ResponseTrack';
|
||||||
import { ScanStation } from "./ScanStation";
|
import { ScanStation } from "./ScanStation";
|
||||||
import { TrackScan } from "./TrackScan";
|
import { TrackScan } from "./TrackScan";
|
||||||
|
|
||||||
@ -61,4 +62,11 @@ export class Track {
|
|||||||
*/
|
*/
|
||||||
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
|
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
|
||||||
scans: TrackScan[];
|
scans: TrackScan[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns this entity into it's response class.
|
||||||
|
*/
|
||||||
|
public toResponse(): ResponseTrack {
|
||||||
|
return new ResponseTrack(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
IsPositive
|
IsPositive
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { ChildEntity, Column, ManyToOne } from "typeorm";
|
import { ChildEntity, Column, ManyToOne } from "typeorm";
|
||||||
|
import { ResponseTrackScan } from '../responses/ResponseTrackScan';
|
||||||
import { RunnerCard } from "./RunnerCard";
|
import { RunnerCard } from "./RunnerCard";
|
||||||
import { Scan } from "./Scan";
|
import { Scan } from "./Scan";
|
||||||
import { ScanStation } from "./ScanStation";
|
import { ScanStation } from "./ScanStation";
|
||||||
@ -59,4 +60,11 @@ export class TrackScan extends Scan {
|
|||||||
@IsDateString()
|
@IsDateString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns this entity into it's response class.
|
||||||
|
*/
|
||||||
|
public toResponse(): ResponseTrackScan {
|
||||||
|
return new ResponseTrackScan(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,4 +52,11 @@ export class UserAction {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
changed: string;
|
changed: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns this entity into it's response class.
|
||||||
|
*/
|
||||||
|
public toResponse() {
|
||||||
|
return new Error("NotImplemented");
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user