parent
86a21dbfa4
commit
538622aa18
|
@ -1,6 +1,6 @@
|
|||
import { Authorized, BadRequestError, 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 { Repository, getConnectionManager } from 'typeorm';
|
||||
import { RunnerOrganizationHasRunnersError, RunnerOrganizationHasTeamsError, RunnerOrganizationIdsNotMatchingError, RunnerOrganizationNotFoundError } from '../errors/RunnerOrganizationErrors';
|
||||
import { CreateRunnerOrganization } from '../models/actions/create/CreateRunnerOrganization';
|
||||
import { UpdateRunnerOrganization } from '../models/actions/update/UpdateRunnerOrganization';
|
||||
|
@ -29,13 +29,20 @@ export class RunnerOrganizationController {
|
|||
@Authorized("ORGANIZATION:GET")
|
||||
@ResponseSchema(ResponseRunnerOrganization, { isArray: true })
|
||||
@OpenAPI({ description: 'Lists all organizations. <br> This includes their address, contact and teams (if existing/associated).' })
|
||||
async getAll() {
|
||||
let responseTeams: ResponseRunnerOrganization[] = new Array<ResponseRunnerOrganization>();
|
||||
const runners = await this.runnerOrganizationRepository.find({ relations: ['contact', 'teams'] });
|
||||
runners.forEach(runner => {
|
||||
responseTeams.push(new ResponseRunnerOrganization(runner));
|
||||
async getAll(@QueryParam("page", { required: false }) page: number, @QueryParam("page_size", { required: false }) page_size: number = 100) {
|
||||
let responseOrgs: ResponseRunnerOrganization[] = new Array<ResponseRunnerOrganization>();
|
||||
let orgs: Array<RunnerOrganization>;
|
||||
|
||||
if (page) {
|
||||
orgs = await this.runnerOrganizationRepository.find({ relations: ['contact', 'teams'], skip: page * page_size, take: page_size });
|
||||
} else {
|
||||
orgs = await this.runnerOrganizationRepository.find({ relations: ['contact', 'teams'] });
|
||||
}
|
||||
|
||||
orgs.forEach(org => {
|
||||
responseOrgs.push(new ResponseRunnerOrganization(org));
|
||||
});
|
||||
return responseTeams;
|
||||
return responseOrgs;
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
|
|
Loading…
Reference in New Issue