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