motivo
This commit is contained in:
@@ -3,4 +3,7 @@ import { IsNumberString } from 'class-validator';
|
||||
export class MotivoDto {
|
||||
@IsNumberString()
|
||||
id_equipo: string;
|
||||
|
||||
@IsNumberString()
|
||||
pagina: string;
|
||||
}
|
||||
|
||||
@@ -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() {}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user