From 14ae95c00ef1b6b037c2a7b948bf718bdffa651e Mon Sep 17 00:00:00 2001 From: miguel Date: Tue, 9 Sep 2025 15:17:59 -0600 Subject: [PATCH] feat: update asistencia registration to use JWT token and modify TypeORM synchronization setting --- src/db/typeorm.config.ts | 2 +- .../participante_evento.controller.ts | 36 +++++++++++-------- .../participante_evento.service.ts | 6 +++- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/db/typeorm.config.ts b/src/db/typeorm.config.ts index c50a53e..950c71e 100644 --- a/src/db/typeorm.config.ts +++ b/src/db/typeorm.config.ts @@ -56,7 +56,7 @@ export const createMainDbConfig = async ( retryDelay: 3000, connectTimeout: 30000, - synchronize: configService.get('SYNCHRONIZE') === 'false', + synchronize: configService.get('SYNCHRONIZE') === 'true', dropSchema: configService.get('DROP_SCHEMA') === 'true', }); diff --git a/src/participante_evento/participante_evento.controller.ts b/src/participante_evento/participante_evento.controller.ts index 8a7681a..df24753 100644 --- a/src/participante_evento/participante_evento.controller.ts +++ b/src/participante_evento/participante_evento.controller.ts @@ -13,7 +13,13 @@ import { ParticipanteEvento } from './entities/participante_evento.entity'; import { CreateParticipanteEventoDto } from './dto/create-participante_evento.dto'; import { UpdateParticipanteEventoDto } from './dto/update.participante_evento.dto'; import { RegistrarAsistenciaQrDto } from './dto/registrar-asistencia-qr.dto'; -import { ApiTags, ApiOperation, ApiParam, ApiResponse } from '@nestjs/swagger'; +import { + ApiTags, + ApiOperation, + ApiParam, + ApiResponse, + ApiBody, +} from '@nestjs/swagger'; @ApiTags('Participantes-Eventos') @Controller('participante-evento') @@ -203,25 +209,27 @@ export class ParticipanteEventoController { @ApiOperation({ summary: 'Registrar asistencia de un participante a un evento', }) - @ApiParam({ - name: 'idParticipante', - description: 'ID del participante', - type: 'number', + @ApiBody({ + description: 'Token JWT generado por el código QR', + schema: { + type: 'object', + properties: { + token: { type: 'string' }, + }, + example: { + token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', + }, + }, }) - @ApiParam({ name: 'idEvento', description: 'ID del evento', type: 'number' }) @ApiResponse({ status: 200, description: 'Asistencia registrada correctamente', }) @ApiResponse({ status: 404, description: 'Registro no encontrado' }) - @Post('asistencia/:idParticipante/:idEvento') - registrarAsistencia( - @Param('idParticipante', ParseIntPipe) idParticipante: number, - @Param('idEvento', ParseIntPipe) idEvento: number, - ) { - return this.participanteEventoService.registrarAsistencia( - idParticipante, - idEvento, + @Post('asistencia') + registrarAsistencia(@Body() body: { token: string }) { + return this.participanteEventoService.registrarAsistenciaConToken( + body.token, ); } diff --git a/src/participante_evento/participante_evento.service.ts b/src/participante_evento/participante_evento.service.ts index 7b570aa..205fce9 100644 --- a/src/participante_evento/participante_evento.service.ts +++ b/src/participante_evento/participante_evento.service.ts @@ -160,7 +160,11 @@ export class ParticipanteEventoService { return this.participanteEventoRepository.save(participante_evento); } - async registrarAsistencia(id_participante: number, id_cuestionario: number) { + async registrarAsistencia( + id_participante: number, + id_cuestionario: number, + token: string, + ) { const participante_eventoFound = await this.participanteEventoRepository.findOne({ where: { -- 2.43.0