parent
3d2c93b5ac
commit
82644a2ff4
@ -1,7 +1,8 @@
|
|||||||
import { JsonController } from 'routing-controllers';
|
import { Authorized, Get, JsonController } from 'routing-controllers';
|
||||||
import { OpenAPI } from 'routing-controllers-openapi';
|
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||||
import { getConnectionManager, Repository } from 'typeorm';
|
import { getConnectionManager, Repository } from 'typeorm';
|
||||||
import { ScanStation } from '../models/entities/ScanStation';
|
import { ScanStation } from '../models/entities/ScanStation';
|
||||||
|
import { ResponseScanStation } from '../models/responses/ResponseScanStation';
|
||||||
|
|
||||||
@JsonController('/stations')
|
@JsonController('/stations')
|
||||||
@OpenAPI({ security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] })
|
@OpenAPI({ security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] })
|
||||||
@ -15,19 +16,18 @@ export class ScanStationController {
|
|||||||
this.stationRepository = getConnectionManager().get().getRepository(ScanStation);
|
this.stationRepository = getConnectionManager().get().getRepository(ScanStation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Get()
|
@Get()
|
||||||
// @Authorized("SCAN:GET")
|
@Authorized("STATION:GET")
|
||||||
// @ResponseSchema(ResponseScan, { isArray: true })
|
@ResponseSchema(ResponseScanStation, { isArray: true })
|
||||||
// @ResponseSchema(ResponseTrackScan, { isArray: true })
|
@OpenAPI({ description: 'Lists all scans (normal or track) from all runners. <br> This includes the runner\'s group and distance ran.' })
|
||||||
// @OpenAPI({ description: 'Lists all scans (normal or track) from all runners. <br> This includes the runner\'s group and distance ran.' })
|
async getAll() {
|
||||||
// async getAll() {
|
let responseStations: ResponseScanStation[] = new Array<ResponseScanStation>();
|
||||||
// let responseScans: ResponseScan[] = new Array<ResponseScan>();
|
const stations = await this.stationRepository.find({ relations: ['track'] });
|
||||||
// const scans = await this.scanRepository.find({ relations: ['runner'] });
|
stations.forEach(station => {
|
||||||
// scans.forEach(scan => {
|
responseStations.push(station.toResponse());
|
||||||
// responseScans.push(scan.toResponse());
|
});
|
||||||
// });
|
return responseStations;
|
||||||
// return responseScans;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// @Get('/:id')
|
// @Get('/:id')
|
||||||
// @Authorized("SCAN:GET")
|
// @Authorized("SCAN:GET")
|
||||||
|
@ -5,6 +5,7 @@ import {
|
|||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { ResponseScanStation } from '../responses/ResponseScanStation';
|
||||||
import { Track } from "./Track";
|
import { Track } from "./Track";
|
||||||
import { TrackScan } from "./TrackScan";
|
import { TrackScan } from "./TrackScan";
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ export class ScanStation {
|
|||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
public toResponse() {
|
public toResponse(): ResponseScanStation {
|
||||||
return new Error("NotImplemented");
|
return new ResponseScanStation(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user