From 8538dc6df443c0bb0c3630c30caacd2488dd23cd Mon Sep 17 00:00:00 2001 From: xXpuma99Xx <51341582+xXpuma99Xx@users.noreply.github.com> Date: Tue, 10 May 2022 20:30:44 -0500 Subject: [PATCH] se agrego endpoint a institucion --- src/institucion/dto/institucion-update.dto.ts | 6 +++++- src/institucion/institucion.controller.ts | 8 ++++++-- src/institucion/institucion.service.ts | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/institucion/dto/institucion-update.dto.ts b/src/institucion/dto/institucion-update.dto.ts index a87c8cc..fdc2d2e 100644 --- a/src/institucion/dto/institucion-update.dto.ts +++ b/src/institucion/dto/institucion-update.dto.ts @@ -1,9 +1,13 @@ -import { IsNumber, IsOptional, IsInt } from 'class-validator'; +import { IsNumber, IsOptional, IsInt, IsBoolean } from 'class-validator'; export class InstitucionUpdateDto { @IsInt() id_institucion: number; + @IsBoolean() + @IsOptional() + activo: boolean; + @IsNumber() @IsOptional() dias_multa_retraso?: number; diff --git a/src/institucion/institucion.controller.ts b/src/institucion/institucion.controller.ts index d2c7978..594ffd7 100644 --- a/src/institucion/institucion.controller.ts +++ b/src/institucion/institucion.controller.ts @@ -2,8 +2,7 @@ import { Body, Controller, Get, Put, Query } from '@nestjs/common'; import { InstitucionService } from './institucion.service'; import { IdInstitucionDto } from '../dto/id-institucion.dto'; import { InstitucionUpdateDto } from './dto/institucion-update.dto'; -import {ApiTags} from '@nestjs/swagger' - +import { ApiTags } from '@nestjs/swagger'; @Controller('institucion') @ApiTags('institucion') @@ -20,6 +19,11 @@ export class InstitucionController { return this.institucionService.findById(parseInt(query.id_institucion)); } + @Get('instituciones-activo') + institucionesActivo() { + return this.institucionService.findByAllActivo(); + } + @Put() update(@Body() body: InstitucionUpdateDto) { return this.institucionService.update(body); diff --git a/src/institucion/institucion.service.ts b/src/institucion/institucion.service.ts index 8ffd932..f1a400e 100644 --- a/src/institucion/institucion.service.ts +++ b/src/institucion/institucion.service.ts @@ -13,6 +13,10 @@ export class InstitucionService { return this.repository.find(); } + findByAllActivo() { + return this.repository.find({ activo: true }); + } + findById(id_institucion: number) { return this.repository.findOne({ id_institucion }).then((institucion) => { if (!institucion)