From 898a1635140ef6a4b9220859f7ca0f9ca253b3d7 Mon Sep 17 00:00:00 2001 From: xXpuma99Xx <51341582+xXpuma99Xx@users.noreply.github.com> Date: Thu, 2 Jun 2022 10:14:12 -0500 Subject: [PATCH] motivo --- src/motivo/dto/motivo.dto.ts | 3 +++ src/motivo/motivo.controller.ts | 22 +++++++++++++++++----- src/motivo/motivo.service.ts | 12 ++++++++---- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/motivo/dto/motivo.dto.ts b/src/motivo/dto/motivo.dto.ts index 5be8fd6..db6d553 100644 --- a/src/motivo/dto/motivo.dto.ts +++ b/src/motivo/dto/motivo.dto.ts @@ -3,4 +3,7 @@ import { IsNumberString } from 'class-validator'; export class MotivoDto { @IsNumberString() id_equipo: string; + + @IsNumberString() + pagina: string; } diff --git a/src/motivo/motivo.controller.ts b/src/motivo/motivo.controller.ts index d7ca263..467b87a 100644 --- a/src/motivo/motivo.controller.ts +++ b/src/motivo/motivo.controller.ts @@ -1,18 +1,30 @@ import { Controller, Get, Query } from '@nestjs/common'; +import { ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger'; import { MotivoService } from './motivo.service'; import { MotivoDto } from './dto/motivo.dto'; -import {ApiTags} from '@nestjs/swagger' @Controller('motivo') -// @ApiTags('motivo') +@ApiTags('motivo') export class MotivoController { constructor(private motivoService: MotivoService) {} @Get() + @ApiOperation({ + description: + 'Endpoint que retorna 25 cambios de status que ha tenido el equipo dependiendo de la página en la que se encuentra el alumno.', + }) + @ApiQuery({ + description: 'Id del equipo.', + name: 'id_equipo', + type: 'string', + }) get(@Query() query: MotivoDto) { - return this.motivoService.findAllIdEquipo(parseInt(query.id_equipo)); + return this.motivoService.findAllByIdEquipo( + parseInt(query.id_equipo), + parseInt(query.pagina), + ); } - @Get('reporte') - reporte() {} + // @Get('reporte') + // reporte() {} } diff --git a/src/motivo/motivo.service.ts b/src/motivo/motivo.service.ts index fb4c2bd..3a5c94e 100644 --- a/src/motivo/motivo.service.ts +++ b/src/motivo/motivo.service.ts @@ -36,9 +36,13 @@ export class MotivoService { ); } - findAllIdEquipo(id_equipo: number) { - return this.equipoService - .findById(id_equipo) - .then((equipo) => this.repository.find({ equipo })); + findAllByIdEquipo(id_equipo: number, pagina: number) { + return this.equipoService.findById(id_equipo).then((equipo) => + this.repository.findAndCount({ + where: { equipo }, + skip: (pagina - 1) * 25, + take: 25, + }), + ); } }