2022-05-02 20:29:13 +00:00
|
|
|
import {
|
|
|
|
Body,
|
|
|
|
Controller,
|
|
|
|
Get,
|
|
|
|
Post,
|
|
|
|
Put,
|
|
|
|
Query,
|
|
|
|
UseGuards,
|
|
|
|
} from '@nestjs/common';
|
|
|
|
import { AuthGuard } from '@nestjs/passport';
|
2022-05-31 18:26:21 +00:00
|
|
|
import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
2022-04-05 01:02:54 +00:00
|
|
|
import { ModuloService } from './modulo.service';
|
2022-04-06 20:27:23 +00:00
|
|
|
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
2022-04-18 21:55:19 +00:00
|
|
|
import { ModuloCreateDto } from './dto/modulo-create.dto';
|
2022-04-16 18:05:27 +00:00
|
|
|
import { ModuloUpdateDto } from './dto/modulo-update.dto';
|
2022-04-18 03:01:41 +00:00
|
|
|
// import { Serealize } from '../interceptors/serialize.interceptor';
|
2022-05-01 02:18:19 +00:00
|
|
|
|
2022-03-30 04:03:19 +00:00
|
|
|
@Controller('modulo')
|
2022-05-31 18:26:21 +00:00
|
|
|
@ApiTags('modulo')
|
2022-04-05 01:02:54 +00:00
|
|
|
export class ModuloController {
|
|
|
|
constructor(private moduloService: ModuloService) {}
|
|
|
|
|
2022-04-16 19:37:17 +00:00
|
|
|
@Post()
|
2022-05-09 19:49:38 +00:00
|
|
|
// @UseGuards(AuthGuard('jwt'))
|
2022-05-31 18:26:21 +00:00
|
|
|
@ApiOperation({ description: 'Endpoint que crea un módulo.' })
|
|
|
|
@ApiBody({
|
|
|
|
description: 'Ambas variables son obligatorias.',
|
|
|
|
examples: { ejemplo: { value: { id_institucion: 200, modulo: '' } } },
|
|
|
|
})
|
2022-04-18 21:55:19 +00:00
|
|
|
create(@Body() body: ModuloCreateDto) {
|
2022-04-16 19:37:17 +00:00
|
|
|
return this.moduloService.create(body.id_institucion, body.modulo);
|
|
|
|
}
|
|
|
|
|
2022-06-01 16:06:46 +00:00
|
|
|
@Get()
|
2022-05-31 18:26:21 +00:00
|
|
|
@ApiOperation({
|
|
|
|
description: 'Endpoint que retorna todos los módulos de una institución.',
|
|
|
|
})
|
|
|
|
@ApiQuery({
|
|
|
|
description: 'Id de la institución.',
|
|
|
|
name: 'id_institucion',
|
|
|
|
type: 'string',
|
|
|
|
})
|
2022-04-16 19:37:17 +00:00
|
|
|
modulos(@Query() query: IdInstitucionDto) {
|
2022-04-16 16:21:52 +00:00
|
|
|
return this.moduloService.findAllByIdInstitucion(
|
2022-05-02 19:40:17 +00:00
|
|
|
parseInt(query.id_institucion),
|
2022-04-16 16:21:52 +00:00
|
|
|
);
|
2022-04-06 20:27:23 +00:00
|
|
|
}
|
|
|
|
|
2022-04-16 18:05:27 +00:00
|
|
|
@Put()
|
2022-05-09 19:49:38 +00:00
|
|
|
// @UseGuards(AuthGuard('jwt'))
|
2022-05-31 18:26:21 +00:00
|
|
|
@ApiOperation({
|
|
|
|
description: 'Endpoint que actualiza la información de un módulo.',
|
|
|
|
})
|
|
|
|
@ApiBody({
|
|
|
|
description: 'Todas las variables a excepción de id_modulo son opcionales.',
|
|
|
|
examples: {
|
|
|
|
ejemplo: { value: { id_modulo: 1, activo: true, modulo: '' } },
|
|
|
|
},
|
|
|
|
})
|
2022-04-16 18:05:27 +00:00
|
|
|
update(@Body() body: ModuloUpdateDto) {
|
|
|
|
return this.moduloService.update(body);
|
|
|
|
}
|
2022-04-05 01:02:54 +00:00
|
|
|
}
|