65 lines
1.4 KiB
TypeScript
65 lines
1.4 KiB
TypeScript
import {
|
|
IsBoolean,
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString
|
|
} from "class-validator";
|
|
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
|
import { Track } from "./Track";
|
|
import { TrackScan } from "./TrackScan";
|
|
|
|
/**
|
|
* Defines the ScanStation entity.
|
|
* ScanStations get used to create TrackScans for runners based on a scan of their runnerCard.
|
|
*/
|
|
@Entity()
|
|
export class ScanStation {
|
|
/**
|
|
* Autogenerated unique id (primary key).
|
|
*/
|
|
@PrimaryGeneratedColumn()
|
|
@IsInt()
|
|
id: number;
|
|
|
|
/**
|
|
* The station's description.
|
|
* Mostly for better UX when traceing back stuff.
|
|
*/
|
|
@Column({ nullable: true })
|
|
@IsOptional()
|
|
@IsString()
|
|
description?: string;
|
|
|
|
/**
|
|
* The track this station is associated with.
|
|
* All scans created by this station will also be associated with this track.
|
|
*/
|
|
@IsNotEmpty()
|
|
@ManyToOne(() => Track, track => track.stations, { nullable: false })
|
|
track: Track;
|
|
|
|
/**
|
|
* The station's api key.
|
|
* This is used to authorize a station against the api (not implemented yet).
|
|
*/
|
|
@Column()
|
|
@IsNotEmpty()
|
|
@IsString()
|
|
key: string;
|
|
|
|
/**
|
|
* Is the station enabled (for fraud and setup reasons)?
|
|
* Default: true
|
|
*/
|
|
@Column()
|
|
@IsBoolean()
|
|
enabled: boolean = true;
|
|
|
|
/**
|
|
* Used to link track scans to a scan station.
|
|
*/
|
|
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
|
|
scans: TrackScan[];
|
|
}
|