Merge pull request 'feat: update asistencia registration to use JWT token and modify TypeORM synchronization setting' (#35) from events-division into develop

Reviewed-on: #35
This commit was merged in pull request #35.
This commit is contained in:
2025-09-09 15:19:00 -06:00
3 changed files with 28 additions and 16 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ export const createMainDbConfig = async (
retryDelay: 3000,
connectTimeout: 30000,
synchronize: configService.get<string>('SYNCHRONIZE') === 'false',
synchronize: configService.get<string>('SYNCHRONIZE') === 'true',
dropSchema: configService.get<string>('DROP_SCHEMA') === 'true',
});
@@ -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,
);
}
@@ -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: {