Added the track scan class

ref #11
This commit is contained in:
Nicolai Ort 2020-12-01 18:57:44 +01:00
parent df3715d8d6
commit 8b2d6840a8
1 changed files with 83 additions and 0 deletions

83
src/models/TrackScan.ts Normal file
View File

@ -0,0 +1,83 @@
import { PrimaryGeneratedColumn, Column } from "typeorm";
import {
IsBoolean,
IsDateString,
IsInt,
IsNotEmpty,
IsOptional,
IsPositive,
} from "class-validator";
import { Scan } from "./Scan";
import { Runner } from "./Runner";
import { Track } from "./Track";
import { RunnerCard } from "./RunnerCard";
import { ScanStation } from "./ScanStation";
/**
* Defines the scan interface.
*/
export class TrackScan extends Scan {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsOptional()
@IsInt()
id: number;
/**
* The associated runner.
*/
@Column()
@IsNotEmpty()
//TODO: Relationship
runner: Runner;
/**
* The associated track.
*/
@Column()
@IsNotEmpty()
//TODO: Relationship
track: Track;
/**
* The associated card.
*/
@Column()
@IsNotEmpty()
//TODO: Relationship
card: RunnerCard;
/**
* The scanning station.
*/
@Column()
@IsNotEmpty()
//TODO: Relationship
station: ScanStation;
/**
* The scan's distance in meters.
*/
@IsInt()
@IsPositive()
public get distance(): number {
return this.track.distance;
}
/**
* The scan's creation timestamp.
*/
@Column()
@IsDateString()
@IsNotEmpty()
timestamp: string;
/**
* Is the scan valid (for fraud reasons).
*/
@Column()
@IsBoolean()
valid = true;
}