ref #205
This commit is contained in:
parent
f60025b6de
commit
71ebce6f8e
@ -1,6 +1,6 @@
|
|||||||
import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, QueryParam } from 'routing-controllers';
|
import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, QueryParam } from 'routing-controllers';
|
||||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||||
import { getConnectionManager, Repository } from 'typeorm';
|
import { Repository, getConnectionManager } from 'typeorm';
|
||||||
import { StatsClientNotFoundError } from '../errors/StatsClientErrors';
|
import { StatsClientNotFoundError } from '../errors/StatsClientErrors';
|
||||||
import { TrackNotFoundError } from "../errors/TrackErrors";
|
import { TrackNotFoundError } from "../errors/TrackErrors";
|
||||||
import { CreateStatsClient } from '../models/actions/create/CreateStatsClient';
|
import { CreateStatsClient } from '../models/actions/create/CreateStatsClient';
|
||||||
@ -24,9 +24,16 @@ export class StatsClientController {
|
|||||||
@Authorized("STATSCLIENT:GET")
|
@Authorized("STATSCLIENT:GET")
|
||||||
@ResponseSchema(ResponseStatsClient, { isArray: true })
|
@ResponseSchema(ResponseStatsClient, { isArray: true })
|
||||||
@OpenAPI({ description: 'Lists all stats clients. Please remember that the key can only be viewed on creation.' })
|
@OpenAPI({ description: 'Lists all stats clients. Please remember that the key can only be viewed on creation.' })
|
||||||
async getAll() {
|
async getAll(@QueryParam("page", { required: false }) page: number, @QueryParam("page_size", { required: false }) page_size: number = 100) {
|
||||||
let responseClients: ResponseStatsClient[] = new Array<ResponseStatsClient>();
|
let responseClients: ResponseStatsClient[] = new Array<ResponseStatsClient>();
|
||||||
const clients = await this.clientRepository.find();
|
let clients: Array<StatsClient>;
|
||||||
|
|
||||||
|
if (page) {
|
||||||
|
clients = await this.clientRepository.find({ skip: page * page_size, take: page_size });
|
||||||
|
} else {
|
||||||
|
clients = await this.clientRepository.find();
|
||||||
|
}
|
||||||
|
|
||||||
clients.forEach(clients => {
|
clients.forEach(clients => {
|
||||||
responseClients.push(new ResponseStatsClient(clients));
|
responseClients.push(new ResponseStatsClient(clients));
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user