2020-12-01 17:16:17 +00:00
|
|
|
import {
|
|
|
|
IsBoolean,
|
2020-12-03 16:26:54 +00:00
|
|
|
IsEAN,
|
2020-12-01 17:16:17 +00:00
|
|
|
IsInt,
|
|
|
|
IsNotEmpty,
|
|
|
|
IsOptional,
|
2020-12-05 09:43:28 +00:00
|
|
|
IsString
|
2020-12-01 17:16:17 +00:00
|
|
|
} from "class-validator";
|
2020-12-05 09:43:28 +00:00
|
|
|
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
2020-12-01 17:16:17 +00:00
|
|
|
import { Runner } from "./Runner";
|
2020-12-02 14:40:25 +00:00
|
|
|
import { TrackScan } from "./TrackScan";
|
2020-12-01 17:16:17 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-21 14:29:32 +00:00
|
|
|
* Defines the RunnerCard entity.
|
|
|
|
* A runnerCard is a physical representation for a runner.
|
|
|
|
* It can be associated with a runner to create scans via the scan station's.
|
2020-12-01 17:16:17 +00:00
|
|
|
*/
|
|
|
|
@Entity()
|
|
|
|
export class RunnerCard {
|
|
|
|
/**
|
|
|
|
* Autogenerated unique id (primary key).
|
|
|
|
*/
|
|
|
|
@PrimaryGeneratedColumn()
|
|
|
|
@IsInt()
|
|
|
|
id: number;
|
|
|
|
|
|
|
|
/**
|
2020-12-21 14:29:32 +00:00
|
|
|
* The card's currently associated runner.
|
|
|
|
* To increase reusability a card can be reassigned.
|
2020-12-01 17:16:17 +00:00
|
|
|
*/
|
|
|
|
@IsOptional()
|
2020-12-02 18:45:02 +00:00
|
|
|
@ManyToOne(() => Runner, runner => runner.cards, { nullable: true })
|
2020-12-01 17:16:17 +00:00
|
|
|
runner: Runner;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The card's code.
|
|
|
|
* This has to be able to being converted to something barcode compatible.
|
2020-12-21 14:29:32 +00:00
|
|
|
* Will get automaticlly generated (not implemented yet).
|
2020-12-01 17:16:17 +00:00
|
|
|
*/
|
|
|
|
@Column()
|
2020-12-03 16:26:54 +00:00
|
|
|
@IsEAN()
|
2020-12-01 17:16:17 +00:00
|
|
|
@IsString()
|
|
|
|
@IsNotEmpty()
|
|
|
|
code: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is the card enabled (for fraud reasons)?
|
2020-12-02 17:05:18 +00:00
|
|
|
* Default: true
|
2020-12-01 17:16:17 +00:00
|
|
|
*/
|
|
|
|
@Column()
|
|
|
|
@IsBoolean()
|
2020-12-02 17:05:18 +00:00
|
|
|
enabled: boolean = true;
|
2020-12-02 14:40:25 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-21 14:29:32 +00:00
|
|
|
* The card's associated scans.
|
|
|
|
* Used to link cards to track scans.
|
2020-12-02 14:40:25 +00:00
|
|
|
*/
|
2020-12-02 18:45:02 +00:00
|
|
|
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
|
2020-12-02 14:40:25 +00:00
|
|
|
scans: TrackScan[];
|
2020-12-01 17:16:17 +00:00
|
|
|
}
|