diff --git a/src/controllers/RunnerController.ts b/src/controllers/RunnerController.ts index 1d61eba..53b869d 100644 --- a/src/controllers/RunnerController.ts +++ b/src/controllers/RunnerController.ts @@ -1,7 +1,7 @@ import { Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam } from 'routing-controllers'; import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi'; import { getConnectionManager, Repository } from 'typeorm'; -import { EntityFromBody, EntityFromParam } from 'typeorm-routing-controllers-extensions'; +import { EntityFromBody } from 'typeorm-routing-controllers-extensions'; import { RunnerGroupNeededError, RunnerIdsNotMatchingError, RunnerNotFoundError } from '../errors/RunnerErrors'; import { RunnerGroupNotFoundError } from '../errors/RunnerGroupErrors'; import { CreateRunner } from '../models/actions/CreateRunner'; @@ -87,7 +87,8 @@ export class RunnerController { @ResponseSchema(ResponseEmpty, { statusCode: 204 }) @OnUndefined(204) @OpenAPI({ description: 'Delete a specified runner (if it exists).' }) - async remove(@EntityFromParam('id') runner: Runner, @QueryParam("force") force: boolean) { + async remove(@Param("id") id: number, @QueryParam("force") force: boolean) { + let runner = await this.runnerRepository.findOne({ id: id }); if (!runner) { return null; } const responseRunner = await this.runnerRepository.findOne(runner, { relations: ['scans', 'group'] }); diff --git a/src/controllers/RunnerOrganisationController.ts b/src/controllers/RunnerOrganisationController.ts index f9733d5..8471e90 100644 --- a/src/controllers/RunnerOrganisationController.ts +++ b/src/controllers/RunnerOrganisationController.ts @@ -1,7 +1,7 @@ import { Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam } from 'routing-controllers'; import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi'; import { getConnectionManager, Repository } from 'typeorm'; -import { EntityFromBody, EntityFromParam } from 'typeorm-routing-controllers-extensions'; +import { EntityFromBody } from 'typeorm-routing-controllers-extensions'; import { RunnerOrganisationHasRunnersError, RunnerOrganisationHasTeamsError, RunnerOrganisationIdsNotMatchingError, RunnerOrganisationNotFoundError } from '../errors/RunnerOrganisationErrors'; import { CreateRunnerOrganisation } from '../models/actions/CreateRunnerOrganisation'; import { RunnerOrganisation } from '../models/entities/RunnerOrganisation'; @@ -92,7 +92,8 @@ export class RunnerOrganisationController { @ResponseSchema(RunnerOrganisationHasRunnersError, { statusCode: 406 }) @OnUndefined(204) @OpenAPI({ description: 'Delete a specified runnerOrganisation (if it exists).' }) - async remove(@EntityFromParam('id') organisation: RunnerOrganisation, @QueryParam("force") force: boolean) { + async remove(@Param("id") id: number, @QueryParam("force") force: boolean) { + let organisation = await this.runnerOrganisationRepository.findOne({ id: id }); if (!organisation) { return null; } let runnerOrganisation = await this.runnerOrganisationRepository.findOne(organisation, { relations: ['address', 'contact', 'runners', 'teams'] }); @@ -103,7 +104,7 @@ export class RunnerOrganisationController { } const teamController = new RunnerTeamController() for (let team of runnerOrganisation.teams) { - await teamController.remove(team, true); + await teamController.remove(team.id, true); } if (!force) { @@ -113,7 +114,7 @@ export class RunnerOrganisationController { } const runnerController = new RunnerController() for (let runner of runnerOrganisation.runners) { - await runnerController.remove(runner, true); + await runnerController.remove(runner.id, true); } const responseOrganisation = new ResponseRunnerOrganisation(runnerOrganisation); diff --git a/src/controllers/RunnerTeamController.ts b/src/controllers/RunnerTeamController.ts index 4f69c36..2eeae3e 100644 --- a/src/controllers/RunnerTeamController.ts +++ b/src/controllers/RunnerTeamController.ts @@ -1,7 +1,7 @@ import { Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam } from 'routing-controllers'; import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi'; import { getConnectionManager, Repository } from 'typeorm'; -import { EntityFromBody, EntityFromParam } from 'typeorm-routing-controllers-extensions'; +import { EntityFromBody } from 'typeorm-routing-controllers-extensions'; import { RunnerTeamHasRunnersError, RunnerTeamIdsNotMatchingError, RunnerTeamNotFoundError } from '../errors/RunnerTeamErrors'; import { CreateRunnerTeam } from '../models/actions/CreateRunnerTeam'; import { RunnerTeam } from '../models/entities/RunnerTeam'; @@ -91,7 +91,8 @@ export class RunnerTeamController { @ResponseSchema(RunnerTeamHasRunnersError, { statusCode: 406 }) @OnUndefined(204) @OpenAPI({ description: 'Delete a specified runnerTeam (if it exists).' }) - async remove(@EntityFromParam('id') team: RunnerTeam, @QueryParam("force") force: boolean) { + async remove(@Param("id") id: number, @QueryParam("force") force: boolean) { + let team = await this.runnerTeamRepository.findOne({ id: id }); if (!team) { return null; } let runnerTeam = await this.runnerTeamRepository.findOne(team, { relations: ['parentGroup', 'contact', 'runners'] }); @@ -102,7 +103,7 @@ export class RunnerTeamController { } const runnerController = new RunnerController() for (let runner of runnerTeam.runners) { - await runnerController.remove(runner, true); + await runnerController.remove(runner.id, true); } const responseTeam = new ResponseRunnerTeam(runnerTeam); diff --git a/src/controllers/TrackController.ts b/src/controllers/TrackController.ts index d5fa9b6..e17e098 100644 --- a/src/controllers/TrackController.ts +++ b/src/controllers/TrackController.ts @@ -1,7 +1,7 @@ import { Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put } from 'routing-controllers'; import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi'; import { getConnectionManager, Repository } from 'typeorm'; -import { EntityFromBody, EntityFromParam } from 'typeorm-routing-controllers-extensions'; +import { EntityFromBody } from 'typeorm-routing-controllers-extensions'; import { TrackIdsNotMatchingError, TrackNotFoundError } from "../errors/TrackErrors"; import { CreateTrack } from '../models/actions/CreateTrack'; import { Track } from '../models/entities/Track'; @@ -78,7 +78,8 @@ export class TrackController { @ResponseSchema(ResponseEmpty, { statusCode: 204 }) @OnUndefined(204) @OpenAPI({ description: "Delete a specified track (if it exists)." }) - async remove(@EntityFromParam('id') track: Track) { + async remove(@Param("id") id: number) { + let track = await this.trackRepository.findOne({ id: id }); if (!track) { return null; } await this.trackRepository.delete(track); diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index a5b3cdd..f71fd60 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -1,7 +1,7 @@ import { Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put } from 'routing-controllers'; import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi'; import { getConnectionManager, Repository } from 'typeorm'; -import { EntityFromBody, EntityFromParam } from 'typeorm-routing-controllers-extensions'; +import { EntityFromBody } from 'typeorm-routing-controllers-extensions'; import { UserIdsNotMatchingError, UserNotFoundError } from '../errors/UserErrors'; import { UserGroupNotFoundError } from '../errors/UserGroupErrors'; import { CreateUser } from '../models/actions/CreateUser'; @@ -76,7 +76,8 @@ export class UserController { @ResponseSchema(ResponseEmpty, { statusCode: 204 }) @OnUndefined(204) @OpenAPI({ description: 'Delete a specified runner (if it exists).' }) - async remove(@EntityFromParam('id') user: User) { + async remove(@Param("id") id: number) { + let user = await this.userRepository.findOne({ id: id }); if (!user) { return null; } diff --git a/src/controllers/UserGroupController.ts b/src/controllers/UserGroupController.ts index 1d4bc38..a317366 100644 --- a/src/controllers/UserGroupController.ts +++ b/src/controllers/UserGroupController.ts @@ -1,7 +1,7 @@ import { Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put } from 'routing-controllers'; import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi'; import { getConnectionManager, Repository } from 'typeorm'; -import { EntityFromBody, EntityFromParam } from 'typeorm-routing-controllers-extensions'; +import { EntityFromBody } from 'typeorm-routing-controllers-extensions'; import { UserGroupIdsNotMatchingError, UserGroupNotFoundError } from '../errors/UserGroupErrors'; import { CreateUserGroup } from '../models/actions/CreateUserGroup'; import { UserGroup } from '../models/entities/UserGroup'; @@ -75,7 +75,8 @@ export class UserGroupController { @ResponseSchema(ResponseEmpty, { statusCode: 204 }) @OnUndefined(204) @OpenAPI({ description: 'Delete a specified usergroup (if it exists).' }) - async remove(@EntityFromParam('id') group: UserGroup) { + async remove(@Param("id") id: number) { + let group = await this.userGroupsRepository.findOne({ id: id }); if (!group) { return null; }