ref #67
This commit is contained in:
parent
9cc50078d1
commit
c591c182b3
@ -5,7 +5,7 @@ import { Runner } from '../entities/Runner';
|
|||||||
import { Scan } from '../entities/Scan';
|
import { Scan } from '../entities/Scan';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This classed is used to create a new Scan entity from a json body (post request).
|
* This class is used to create a new Scan entity from a json body (post request).
|
||||||
*/
|
*/
|
||||||
export abstract class CreateScan {
|
export abstract class CreateScan {
|
||||||
/**
|
/**
|
||||||
@ -46,6 +46,9 @@ export abstract class CreateScan {
|
|||||||
return newScan;
|
return newScan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a runner based on the runner id provided via this.runner.
|
||||||
|
*/
|
||||||
public async getRunner(): Promise<Runner> {
|
public async getRunner(): Promise<Runner> {
|
||||||
const runner = await getConnection().getRepository(Runner).findOne({ id: this.runner });
|
const runner = await getConnection().getRepository(Runner).findOne({ id: this.runner });
|
||||||
if (!runner) {
|
if (!runner) {
|
||||||
|
@ -8,19 +8,18 @@ import { ScanStation } from '../entities/ScanStation';
|
|||||||
import { Track } from '../entities/Track';
|
import { Track } from '../entities/Track';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This classed is used to create a new StatsClient entity from a json body (post request).
|
* This class is used to create a new StatsClient entity from a json body (post request).
|
||||||
*/
|
*/
|
||||||
export class CreateScanStation {
|
export class CreateScanStation {
|
||||||
/**
|
/**
|
||||||
* The new client's description.
|
* The new station's description.
|
||||||
*/
|
*/
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The scan's associated track.
|
* The station's associated track.
|
||||||
* This is used to determine the scan's distance.
|
|
||||||
*/
|
*/
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@IsPositive()
|
@IsPositive()
|
||||||
@ -51,6 +50,10 @@ export class CreateScanStation {
|
|||||||
return newStation;
|
return newStation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get's a track by it's id provided via this.track.
|
||||||
|
* Used to link the new station to a track.
|
||||||
|
*/
|
||||||
public async getTrack(): Promise<Track> {
|
public async getTrack(): Promise<Track> {
|
||||||
const track = await getConnection().getRepository(Track).findOne({ id: this.track });
|
const track = await getConnection().getRepository(Track).findOne({ id: this.track });
|
||||||
if (!track) {
|
if (!track) {
|
||||||
|
@ -5,7 +5,7 @@ import { Runner } from '../entities/Runner';
|
|||||||
import { Scan } from '../entities/Scan';
|
import { Scan } from '../entities/Scan';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This classed is used to create a new Scan entity from a json body (post request).
|
* This class is used to update a Scan entity (via put request)
|
||||||
*/
|
*/
|
||||||
export abstract class UpdateScan {
|
export abstract class UpdateScan {
|
||||||
/**
|
/**
|
||||||
@ -49,6 +49,9 @@ export abstract class UpdateScan {
|
|||||||
return scan;
|
return scan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a runner based on the runner id provided via this.runner.
|
||||||
|
*/
|
||||||
public async getRunner(): Promise<Runner> {
|
public async getRunner(): Promise<Runner> {
|
||||||
const runner = await getConnection().getRepository(Runner).findOne({ id: this.runner });
|
const runner = await getConnection().getRepository(Runner).findOne({ id: this.runner });
|
||||||
if (!runner) {
|
if (!runner) {
|
||||||
|
@ -2,7 +2,7 @@ import { IsBoolean, IsInt, IsOptional, IsString } from 'class-validator';
|
|||||||
import { ScanStation } from '../entities/ScanStation';
|
import { ScanStation } from '../entities/ScanStation';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This classed is used to create a new StatsClient entity from a json body (post request).
|
* This class is used to update a ScanStation entity (via put request)
|
||||||
*/
|
*/
|
||||||
export class UpdateScanStation {
|
export class UpdateScanStation {
|
||||||
/**
|
/**
|
||||||
@ -27,8 +27,8 @@ export class UpdateScanStation {
|
|||||||
enabled?: boolean = true;
|
enabled?: boolean = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts this to a ScanStation entity.
|
* Update a ScanStation entity based on this.
|
||||||
* TODO:
|
* @param station The station that shall be updated.
|
||||||
*/
|
*/
|
||||||
public async updateStation(station: ScanStation): Promise<ScanStation> {
|
public async updateStation(station: ScanStation): Promise<ScanStation> {
|
||||||
station.description = this.description;
|
station.description = this.description;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user