Went back to using id's for deletion (for cleaner query params)
ref #13 #17
This commit is contained in:
parent
a068c4d318
commit
df5b8ac141
|
@ -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'] });
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue