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