se agrego endpoint a institucion

This commit is contained in:
xXpuma99Xx
2022-05-10 20:30:44 -05:00
parent a528421e25
commit 8538dc6df4
3 changed files with 15 additions and 3 deletions
@@ -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;
+6 -2
View File
@@ -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);
+4
View File
@@ -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)