56 lines
1.1 KiB
TypeScript
56 lines
1.1 KiB
TypeScript
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany } from "typeorm";
|
|
import {
|
|
IsBoolean,
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString,
|
|
} from "class-validator";
|
|
import { Runner } from "./Runner";
|
|
import { TrackScan } from "./TrackScan";
|
|
|
|
/**
|
|
* Defines a card that can be scanned via a scanner station.
|
|
*/
|
|
@Entity()
|
|
export class RunnerCard {
|
|
/**
|
|
* Autogenerated unique id (primary key).
|
|
*/
|
|
@PrimaryGeneratedColumn()
|
|
@IsOptional()
|
|
@IsInt()
|
|
id: number;
|
|
|
|
/**
|
|
* The runner that is currently associated with this card.
|
|
*/
|
|
@IsOptional()
|
|
@ManyToOne(() => Runner, runner => runner.cards)
|
|
runner: Runner;
|
|
|
|
/**
|
|
* The card's code.
|
|
* This has to be able to being converted to something barcode compatible.
|
|
* Probably gonna be autogenerated.
|
|
*/
|
|
@Column()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
//TODO: Generate this
|
|
code: string;
|
|
|
|
/**
|
|
* Is the card enabled (for fraud reasons)?
|
|
*/
|
|
@Column()
|
|
@IsBoolean()
|
|
enabled = true;
|
|
|
|
/**
|
|
* Used to link cards to a track scans.
|
|
*/
|
|
@OneToMany(() => TrackScan, scan => scan.track)
|
|
scans: TrackScan[];
|
|
}
|