parent
7fbe649dc9
commit
673dea2e57
|
@ -29,7 +29,7 @@ export class RunnerOrganisationController {
|
|||
@OpenAPI({ description: 'Lists all organisations. <br> This includes their address, contact and teams (if existing/associated).' })
|
||||
async getAll() {
|
||||
let responseTeams: ResponseRunnerOrganisation[] = new Array<ResponseRunnerOrganisation>();
|
||||
const runners = await this.runnerOrganisationRepository.find({ relations: ['address', 'contact', 'teams'] });
|
||||
const runners = await this.runnerOrganisationRepository.find({ relations: ['contact', 'teams'] });
|
||||
runners.forEach(runner => {
|
||||
responseTeams.push(new ResponseRunnerOrganisation(runner));
|
||||
});
|
||||
|
@ -43,7 +43,7 @@ export class RunnerOrganisationController {
|
|||
@OnUndefined(RunnerOrganisationNotFoundError)
|
||||
@OpenAPI({ description: 'Lists all information about the organisation whose id got provided.' })
|
||||
async getOne(@Param('id') id: number) {
|
||||
let runnerOrg = await this.runnerOrganisationRepository.findOne({ id: id }, { relations: ['address', 'contact', 'teams'] });
|
||||
let runnerOrg = await this.runnerOrganisationRepository.findOne({ id: id }, { relations: ['contact', 'teams'] });
|
||||
if (!runnerOrg) { throw new RunnerOrganisationNotFoundError(); }
|
||||
return new ResponseRunnerOrganisation(runnerOrg);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ export class RunnerOrganisationController {
|
|||
|
||||
runnerOrganisation = await this.runnerOrganisationRepository.save(runnerOrganisation);
|
||||
|
||||
return new ResponseRunnerOrganisation(await this.runnerOrganisationRepository.findOne(runnerOrganisation, { relations: ['address', 'contact', 'teams'] }));
|
||||
return new ResponseRunnerOrganisation(await this.runnerOrganisationRepository.findOne(runnerOrganisation, { relations: ['contact', 'teams'] }));
|
||||
}
|
||||
|
||||
@Put('/:id')
|
||||
|
@ -84,7 +84,7 @@ export class RunnerOrganisationController {
|
|||
|
||||
await this.runnerOrganisationRepository.save(await updateOrganisation.update(oldRunnerOrganisation));
|
||||
|
||||
return new ResponseRunnerOrganisation(await this.runnerOrganisationRepository.findOne(id, { relations: ['address', 'contact', 'teams'] }));
|
||||
return new ResponseRunnerOrganisation(await this.runnerOrganisationRepository.findOne(id, { relations: ['contact', 'teams'] }));
|
||||
}
|
||||
|
||||
@Delete('/:id')
|
||||
|
@ -98,7 +98,7 @@ export class RunnerOrganisationController {
|
|||
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'] });
|
||||
let runnerOrganisation = await this.runnerOrganisationRepository.findOne(organisation, { relations: ['contact', 'runners', 'teams'] });
|
||||
|
||||
if (!force) {
|
||||
if (runnerOrganisation.teams.length != 0) {
|
||||
|
|
Loading…
Reference in New Issue