Added card creation

#17
This commit is contained in:
2021-01-09 11:48:13 +01:00
parent a5bfe4e3d5
commit 36ecae7e6e
4 changed files with 72 additions and 29 deletions

View File

@@ -1,10 +1,9 @@
import {
IsBoolean,
IsEAN,
IsInt,
IsNotEmpty,
IsOptional,
IsString
IsOptional
} from "class-validator";
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { ResponseRunnerCard } from '../responses/ResponseRunnerCard';
@@ -33,17 +32,6 @@ export class RunnerCard {
@ManyToOne(() => Runner, runner => runner.cards, { nullable: true })
runner: Runner;
/**
* The card's code.
* This has to be able to being converted to something barcode compatible.
* Will get automaticlly generated (not implemented yet).
*/
@Column()
@IsEAN()
@IsString()
@IsNotEmpty()
code: string;
/**
* Is the card enabled (for fraud reasons)?
* Default: true
@@ -59,6 +47,14 @@ export class RunnerCard {
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
scans: TrackScan[];
/**
* Generates a ean-13 compliant string for barcode generation.
*/
public get code(): string {
//TODO: Implement the real deal
return '0000000000000'
}
/**
* Turns this entity into it's response class.
*/