documentación institucion
This commit is contained in:
parent
68cd6e16c3
commit
8ea1b09139
3127
package-lock.json
generated
3127
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@ export class InstitucionUpdateDto {
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
activo: boolean;
|
||||
activo?: boolean;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Body, Controller, Get, Put, Query } from '@nestjs/common';
|
||||
import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
||||
import { InstitucionService } from './institucion.service';
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import { InstitucionUpdateDto } from './dto/institucion-update.dto';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@Controller('institucion')
|
||||
@ApiTags('institucion')
|
||||
@ -10,21 +10,54 @@ export class InstitucionController {
|
||||
constructor(private institucionService: InstitucionService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({
|
||||
description: 'Endpoint que retorna todas las instituciones.',
|
||||
})
|
||||
get() {
|
||||
return this.institucionService.findAll();
|
||||
}
|
||||
|
||||
@Get('institucion')
|
||||
@ApiOperation({
|
||||
description: 'Endpoint que retorna la información de una institución.',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'id_institucion',
|
||||
type: 'string',
|
||||
description: 'Id de la institución.',
|
||||
})
|
||||
institucion(@Query() query: IdInstitucionDto) {
|
||||
return this.institucionService.findById(parseInt(query.id_institucion));
|
||||
}
|
||||
|
||||
@Get('activas')
|
||||
@ApiOperation({
|
||||
description: 'Endpoint que retorna todas las instituciones activas.',
|
||||
})
|
||||
activas() {
|
||||
return this.institucionService.findByAllActivo();
|
||||
return this.institucionService.findAllActivos();
|
||||
}
|
||||
|
||||
@Put()
|
||||
@ApiOperation({
|
||||
description: 'Endpoint que actualiza la información de una institución.',
|
||||
})
|
||||
@ApiBody({
|
||||
description:
|
||||
'Todas las variables a excepción de id_institucion son opcionales.',
|
||||
examples: {
|
||||
ejemplo: {
|
||||
value: {
|
||||
id_institucion: 200,
|
||||
activo: true,
|
||||
dias_multa_retraso: 7,
|
||||
dias_multa_retrtiempo_entregaaso: 7,
|
||||
tiempo_prestamo: 7,
|
||||
tiempo_recoger: 7,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
update(@Body() body: InstitucionUpdateDto) {
|
||||
return this.institucionService.update(body);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ export class InstitucionService {
|
||||
return this.repository.find();
|
||||
}
|
||||
|
||||
findByAllActivo() {
|
||||
findAllActivos() {
|
||||
return this.repository.find({ activo: true });
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ export class InstitucionService {
|
||||
return this.repository.save(institucion);
|
||||
})
|
||||
.then((_) => ({
|
||||
message: 'Se actualió correctamente la institucion.',
|
||||
message: 'Se actualizó correctamente la institucion.',
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user