| @@ -16,7 +16,6 @@ import { ResponseScan } from '../models/responses/ResponseScan'; | |||||||
| import { ResponseTrackScan } from '../models/responses/ResponseTrackScan'; | import { ResponseTrackScan } from '../models/responses/ResponseTrackScan'; | ||||||
|  |  | ||||||
| @JsonController('/scans') | @JsonController('/scans') | ||||||
| @OpenAPI({ security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] }) |  | ||||||
| export class ScanController { | export class ScanController { | ||||||
| 	private scanRepository: Repository<Scan>; | 	private scanRepository: Repository<Scan>; | ||||||
| 	private trackScanRepository: Repository<TrackScan>; | 	private trackScanRepository: Repository<TrackScan>; | ||||||
| @@ -33,7 +32,7 @@ export class ScanController { | |||||||
| 	@Authorized("SCAN:GET") | 	@Authorized("SCAN:GET") | ||||||
| 	@ResponseSchema(ResponseScan, { isArray: true }) | 	@ResponseSchema(ResponseScan, { isArray: true }) | ||||||
| 	@ResponseSchema(ResponseTrackScan, { isArray: true }) | 	@ResponseSchema(ResponseTrackScan, { isArray: true }) | ||||||
| 	@OpenAPI({ description: 'Lists all scans (normal or track) from all runners. <br> This includes the scan\'s runner\'s distance ran.' }) | 	@OpenAPI({ description: 'Lists all scans (normal or track) from all runners. <br> This includes the scan\'s runner\'s distance ran.', security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] }) | ||||||
| 	async getAll() { | 	async getAll() { | ||||||
| 		let responseScans: ResponseScan[] = new Array<ResponseScan>(); | 		let responseScans: ResponseScan[] = new Array<ResponseScan>(); | ||||||
| 		const scans = await this.scanRepository.find({ relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] }); | 		const scans = await this.scanRepository.find({ relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] }); | ||||||
| @@ -49,7 +48,7 @@ export class ScanController { | |||||||
| 	@ResponseSchema(ResponseTrackScan) | 	@ResponseSchema(ResponseTrackScan) | ||||||
| 	@ResponseSchema(ScanNotFoundError, { statusCode: 404 }) | 	@ResponseSchema(ScanNotFoundError, { statusCode: 404 }) | ||||||
| 	@OnUndefined(ScanNotFoundError) | 	@OnUndefined(ScanNotFoundError) | ||||||
| 	@OpenAPI({ description: 'Lists all information about the scan whose id got provided. This includes the scan\'s runner\'s distance ran.' }) | 	@OpenAPI({ description: 'Lists all information about the scan whose id got provided. This includes the scan\'s runner\'s distance ran.', security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] }) | ||||||
| 	async getOne(@Param('id') id: number) { | 	async getOne(@Param('id') id: number) { | ||||||
| 		let scan = await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] }) | 		let scan = await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] }) | ||||||
| 		if (!scan) { throw new ScanNotFoundError(); } | 		if (!scan) { throw new ScanNotFoundError(); } | ||||||
| @@ -87,7 +86,7 @@ export class ScanController { | |||||||
| 	@ResponseSchema(ScanNotFoundError, { statusCode: 404 }) | 	@ResponseSchema(ScanNotFoundError, { statusCode: 404 }) | ||||||
| 	@ResponseSchema(RunnerNotFoundError, { statusCode: 404 }) | 	@ResponseSchema(RunnerNotFoundError, { statusCode: 404 }) | ||||||
| 	@ResponseSchema(ScanIdsNotMatchingError, { statusCode: 406 }) | 	@ResponseSchema(ScanIdsNotMatchingError, { statusCode: 406 }) | ||||||
| 	@OpenAPI({ description: "Update the scan (not track scan use /scans/trackscans/:id instead) whose id you provided. <br> Please remember that ids can't be changed and distances must be positive." }) | 	@OpenAPI({ description: "Update the scan (not track scan use /scans/trackscans/:id instead) whose id you provided. <br> Please remember that ids can't be changed and distances must be positive.", security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] }) | ||||||
| 	async put(@Param('id') id: number, @Body({ validate: true }) scan: UpdateScan) { | 	async put(@Param('id') id: number, @Body({ validate: true }) scan: UpdateScan) { | ||||||
| 		let oldScan = await this.scanRepository.findOne({ id: id }); | 		let oldScan = await this.scanRepository.findOne({ id: id }); | ||||||
|  |  | ||||||
| @@ -110,7 +109,7 @@ export class ScanController { | |||||||
| 	@ResponseSchema(RunnerNotFoundError, { statusCode: 404 }) | 	@ResponseSchema(RunnerNotFoundError, { statusCode: 404 }) | ||||||
| 	@ResponseSchema(ScanStationNotFoundError, { statusCode: 404 }) | 	@ResponseSchema(ScanStationNotFoundError, { statusCode: 404 }) | ||||||
| 	@ResponseSchema(ScanIdsNotMatchingError, { statusCode: 406 }) | 	@ResponseSchema(ScanIdsNotMatchingError, { statusCode: 406 }) | ||||||
| 	@OpenAPI({ description: 'Update the track scan (not "normal" scan use /scans/trackscans/:id instead) whose id you provided. <br> Please remember that only the validity, runner and track can be changed.' }) | 	@OpenAPI({ description: 'Update the track scan (not "normal" scan use /scans/trackscans/:id instead) whose id you provided. <br> Please remember that only the validity, runner and track can be changed.', security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] }) | ||||||
| 	async putTrackScan(@Param('id') id: number, @Body({ validate: true }) scan: UpdateTrackScan) { | 	async putTrackScan(@Param('id') id: number, @Body({ validate: true }) scan: UpdateTrackScan) { | ||||||
| 		let oldScan = await this.trackScanRepository.findOne({ id: id }); | 		let oldScan = await this.trackScanRepository.findOne({ id: id }); | ||||||
|  |  | ||||||
| @@ -131,7 +130,7 @@ export class ScanController { | |||||||
| 	@ResponseSchema(ResponseScan) | 	@ResponseSchema(ResponseScan) | ||||||
| 	@ResponseSchema(ResponseEmpty, { statusCode: 204 }) | 	@ResponseSchema(ResponseEmpty, { statusCode: 204 }) | ||||||
| 	@OnUndefined(204) | 	@OnUndefined(204) | ||||||
| 	@OpenAPI({ description: 'Delete the scan whose id you provided. <br> If no scan with this id exists it will just return 204(no content).' }) | 	@OpenAPI({ description: 'Delete the scan whose id you provided. <br> If no scan with this id exists it will just return 204(no content).', security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] }) | ||||||
| 	async remove(@Param("id") id: number, @QueryParam("force") force: boolean) { | 	async remove(@Param("id") id: number, @QueryParam("force") force: boolean) { | ||||||
| 		let scan = await this.scanRepository.findOne({ id: id }); | 		let scan = await this.scanRepository.findOne({ id: id }); | ||||||
| 		if (!scan) { return null; } | 		if (!scan) { return null; } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user