parent
b9c0a32862
commit
2628f69651
|
@ -1,7 +1,9 @@
|
|||
import { Authorized, Get, JsonController, OnUndefined, Param } from 'routing-controllers';
|
||||
import { Authorized, Body, Get, JsonController, OnUndefined, Param, Post } from 'routing-controllers';
|
||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||
import { getConnectionManager, Repository } from 'typeorm';
|
||||
import { ScanStationNotFoundError } from '../errors/ScanStationErrors';
|
||||
import { TrackNotFoundError } from '../errors/TrackErrors';
|
||||
import { CreateScanStation } from '../models/actions/CreateScanStation';
|
||||
import { ScanStation } from '../models/entities/ScanStation';
|
||||
import { ResponseScanStation } from '../models/responses/ResponseScanStation';
|
||||
|
||||
|
@ -42,15 +44,18 @@ export class ScanStationController {
|
|||
return scan.toResponse();
|
||||
}
|
||||
|
||||
// @Post()
|
||||
// @Authorized("SCAN:CREATE")
|
||||
// @ResponseSchema(ResponseScan)
|
||||
// @OpenAPI({ description: 'Create a new runner. <br> Please remeber to provide the runner\'s group\'s id.' })
|
||||
// async post(@Body({ validate: true }) createScan: CreateScan) {
|
||||
// let scan = await createScan.toScan();
|
||||
// scan = await this.scanRepository.save(scan);
|
||||
// return (await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner'] })).toResponse();
|
||||
// }
|
||||
@Post()
|
||||
@Authorized("STATION:CREATE")
|
||||
@ResponseSchema(ResponseScanStation)
|
||||
@ResponseSchema(TrackNotFoundError, { statusCode: 404 })
|
||||
@OpenAPI({ description: 'Create a new runner. <br> Please remeber to provide the runner\'s group\'s id.' })
|
||||
async post(@Body({ validate: true }) createStation: CreateScanStation) {
|
||||
let newStation = await createStation.toEntity();
|
||||
const station = await this.stationRepository.save(newStation);
|
||||
let responseStation = (await this.stationRepository.findOne({ id: station.id }, { relations: ['track'] })).toResponse();
|
||||
responseStation.key = newStation.cleartextkey;
|
||||
return responseStation;
|
||||
}
|
||||
|
||||
// @Put('/:id')
|
||||
// @Authorized("SCAN:UPDATE")
|
||||
|
|
|
@ -10,7 +10,7 @@ import { Track } from '../entities/Track';
|
|||
/**
|
||||
* This classed is used to create a new StatsClient entity from a json body (post request).
|
||||
*/
|
||||
export class CreateStatsClient {
|
||||
export class CreateScanStation {
|
||||
/**
|
||||
* The new client's description.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue