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()
|
@IsBoolean()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
activo: boolean;
|
activo?: boolean;
|
||||||
|
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Body, Controller, Get, Put, Query } from '@nestjs/common';
|
import { Body, Controller, Get, Put, Query } from '@nestjs/common';
|
||||||
|
import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
||||||
import { InstitucionService } from './institucion.service';
|
import { InstitucionService } from './institucion.service';
|
||||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||||
import { InstitucionUpdateDto } from './dto/institucion-update.dto';
|
import { InstitucionUpdateDto } from './dto/institucion-update.dto';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
|
||||||
|
|
||||||
@Controller('institucion')
|
@Controller('institucion')
|
||||||
@ApiTags('institucion')
|
@ApiTags('institucion')
|
||||||
@ -10,21 +10,54 @@ export class InstitucionController {
|
|||||||
constructor(private institucionService: InstitucionService) {}
|
constructor(private institucionService: InstitucionService) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
|
@ApiOperation({
|
||||||
|
description: 'Endpoint que retorna todas las instituciones.',
|
||||||
|
})
|
||||||
get() {
|
get() {
|
||||||
return this.institucionService.findAll();
|
return this.institucionService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('institucion')
|
@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) {
|
institucion(@Query() query: IdInstitucionDto) {
|
||||||
return this.institucionService.findById(parseInt(query.id_institucion));
|
return this.institucionService.findById(parseInt(query.id_institucion));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('activas')
|
@Get('activas')
|
||||||
|
@ApiOperation({
|
||||||
|
description: 'Endpoint que retorna todas las instituciones activas.',
|
||||||
|
})
|
||||||
activas() {
|
activas() {
|
||||||
return this.institucionService.findByAllActivo();
|
return this.institucionService.findAllActivos();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put()
|
@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) {
|
update(@Body() body: InstitucionUpdateDto) {
|
||||||
return this.institucionService.update(body);
|
return this.institucionService.update(body);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ export class InstitucionService {
|
|||||||
return this.repository.find();
|
return this.repository.find();
|
||||||
}
|
}
|
||||||
|
|
||||||
findByAllActivo() {
|
findAllActivos() {
|
||||||
return this.repository.find({ activo: true });
|
return this.repository.find({ activo: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ export class InstitucionService {
|
|||||||
return this.repository.save(institucion);
|
return this.repository.save(institucion);
|
||||||
})
|
})
|
||||||
.then((_) => ({
|
.then((_) => ({
|
||||||
message: 'Se actualió correctamente la institucion.',
|
message: 'Se actualizó correctamente la institucion.',
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user