2023-03-24 15:00:03 -06:00
|
|
|
import {
|
|
|
|
|
Body,
|
|
|
|
|
Controller,
|
2025-08-22 12:14:54 -06:00
|
|
|
Get,
|
2023-03-24 15:00:03 -06:00
|
|
|
HttpException,
|
|
|
|
|
HttpStatus,
|
|
|
|
|
Param,
|
|
|
|
|
ParseIntPipe,
|
|
|
|
|
Post,
|
|
|
|
|
Res,
|
|
|
|
|
UploadedFile,
|
2023-06-26 08:33:18 -06:00
|
|
|
UseGuards,
|
2023-03-24 15:00:03 -06:00
|
|
|
UseInterceptors,
|
|
|
|
|
} from '@nestjs/common';
|
|
|
|
|
import { FileInterceptor } from '@nestjs/platform-express';
|
2023-03-14 15:26:00 -06:00
|
|
|
import { EmailDto } from './dto/emailDto.dto';
|
|
|
|
|
import { EmailService } from './email.service';
|
2023-03-24 15:00:03 -06:00
|
|
|
import { Response } from 'express';
|
|
|
|
|
import * as xlsx from 'xlsx';
|
2023-06-26 08:33:18 -06:00
|
|
|
import { AuthGuard } from '@nestjs/passport';
|
2023-03-14 15:26:00 -06:00
|
|
|
|
|
|
|
|
@Controller('email')
|
|
|
|
|
export class EmailController {
|
2025-08-22 12:14:54 -06:00
|
|
|
constructor(private readonly emailService: EmailService) { }
|
2023-03-14 15:26:00 -06:00
|
|
|
|
2023-06-26 08:33:18 -06:00
|
|
|
@UseGuards(AuthGuard('jwt'))
|
2023-03-14 15:26:00 -06:00
|
|
|
@Post('/evento/:id')
|
|
|
|
|
async sendEmail(
|
|
|
|
|
@Param('id', ParseIntPipe) id: number,
|
|
|
|
|
@Body() emailDto: EmailDto,
|
2023-06-26 08:33:18 -06:00
|
|
|
@Res() res,
|
2023-03-14 15:26:00 -06:00
|
|
|
): Promise<any> {
|
2023-06-26 08:33:18 -06:00
|
|
|
return this.emailService.sendEmail(id, emailDto, res);
|
2023-03-14 15:26:00 -06:00
|
|
|
}
|
2023-03-24 15:00:03 -06:00
|
|
|
|
2023-06-26 08:33:18 -06:00
|
|
|
@UseGuards(AuthGuard('jwt'))
|
|
|
|
|
@Post('constancias/:id')
|
2023-03-24 15:00:03 -06:00
|
|
|
@UseInterceptors(FileInterceptor('file'))
|
2023-06-26 08:33:18 -06:00
|
|
|
async sendConstancias(
|
|
|
|
|
@UploadedFile() file,
|
|
|
|
|
@Param('id', ParseIntPipe) id: number,
|
|
|
|
|
@Res() res,
|
|
|
|
|
) {
|
|
|
|
|
if (!file) {
|
|
|
|
|
throw new HttpException(
|
|
|
|
|
'No se ha cargado ningun archivo',
|
|
|
|
|
HttpStatus.BAD_REQUEST,
|
|
|
|
|
);
|
2023-03-24 15:00:03 -06:00
|
|
|
}
|
2023-06-26 08:33:18 -06:00
|
|
|
return this.emailService.sendConstancias(file, id, res);
|
2023-03-24 15:00:03 -06:00
|
|
|
}
|
2025-08-22 12:14:54 -06:00
|
|
|
|
2025-08-27 12:30:46 -06:00
|
|
|
//@UseGuards(AuthGuard('jwt'))
|
2025-08-22 12:14:54 -06:00
|
|
|
@Get(':id/participantes/xlsx')
|
|
|
|
|
async descargarExcel(
|
|
|
|
|
@Param('id') idEvento: number,
|
|
|
|
|
@Res() res: Response,
|
|
|
|
|
) {
|
2025-08-23 09:57:16 -06:00
|
|
|
console.log('entro en el controller')
|
2025-08-22 12:14:54 -06:00
|
|
|
return this.emailService.getParticipantesExcel(idEvento, res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-03-14 15:26:00 -06:00
|
|
|
}
|