76 lines
1.2 KiB
TypeScript
76 lines
1.2 KiB
TypeScript
import { PrimaryGeneratedColumn, Column, ManyToOne } 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 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;
|
|
}
|