generar y enviar qr por correo electronico despues de registrar un formulario
This commit is contained in:
+12
-1
@@ -13,7 +13,7 @@ import { QrService } from './qr.service';
|
||||
import { Qr } from './qr.entity';
|
||||
import { CreateQrDto } from './dto/create-qr.dto';
|
||||
import { UpdateQrDto } from './dto/update.qr.dto';
|
||||
import { ApiOperation, ApiQuery } from '@nestjs/swagger';
|
||||
import { ApiOperation, ApiParam, ApiQuery } from '@nestjs/swagger';
|
||||
|
||||
@Controller('qr')
|
||||
export class QrController {
|
||||
@@ -30,6 +30,17 @@ export class QrController {
|
||||
return this.qrService.generateQRCode(text);
|
||||
}
|
||||
|
||||
@Get('asistencia/:idParticipante/:idEvento')
|
||||
@ApiOperation({ summary: 'Genera un código QR para asistencia con IDs de participante y evento' })
|
||||
@ApiParam({ name: 'idParticipante', description: 'ID del participante' })
|
||||
@ApiParam({ name: 'idEvento', description: 'ID del evento' })
|
||||
async generateAsistenciaQR(
|
||||
@Param('idParticipante', ParseIntPipe) idParticipante: number,
|
||||
@Param('idEvento', ParseIntPipe) idEvento: number
|
||||
): Promise<string> {
|
||||
return this.qrService.generateAsistenciaQR(idParticipante, idEvento);
|
||||
}
|
||||
|
||||
@Get()
|
||||
getQrs(): Promise<Qr[]> {
|
||||
return this.qrService.getQrs();
|
||||
|
||||
@@ -15,6 +15,20 @@ export class QrService {
|
||||
return await QRCode.toDataURL(text);
|
||||
}
|
||||
|
||||
async generateAsistenciaQR(id_participante: number, id_evento: number): Promise<string> {
|
||||
// Crear un objeto JSON que contenga los IDs
|
||||
const qrData = {
|
||||
id_participante,
|
||||
id_evento
|
||||
};
|
||||
|
||||
// Convertir el objeto a una cadena JSON
|
||||
const jsonStr = JSON.stringify(qrData);
|
||||
|
||||
// Generar el código QR con la cadena JSON
|
||||
return await QRCode.toDataURL(jsonStr);
|
||||
}
|
||||
|
||||
async generateBuffer(text: string): Promise<Buffer> {
|
||||
return await QRCode.toBuffer(text); // Devuelve un buffer para adjuntar en email o stream
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user