2023-03-24 15:00:03 -06:00
|
|
|
import {
|
|
|
|
|
Body,
|
|
|
|
|
Controller,
|
|
|
|
|
HttpException,
|
|
|
|
|
HttpStatus,
|
|
|
|
|
Param,
|
|
|
|
|
ParseIntPipe,
|
|
|
|
|
Post,
|
|
|
|
|
Res,
|
|
|
|
|
UploadedFile,
|
|
|
|
|
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-03-14 15:26:00 -06:00
|
|
|
|
|
|
|
|
@Controller('email')
|
|
|
|
|
export class EmailController {
|
|
|
|
|
constructor(private readonly emailService: EmailService) {}
|
|
|
|
|
|
|
|
|
|
@Post('/evento/:id')
|
|
|
|
|
async sendEmail(
|
|
|
|
|
@Param('id', ParseIntPipe) id: number,
|
|
|
|
|
@Body() emailDto: EmailDto,
|
|
|
|
|
): Promise<any> {
|
|
|
|
|
return this.emailService.sendEmail(id, emailDto);
|
|
|
|
|
}
|
2023-03-24 15:00:03 -06:00
|
|
|
|
|
|
|
|
@Post('constancias')
|
|
|
|
|
@UseInterceptors(FileInterceptor('file'))
|
|
|
|
|
async sendConstancias(@UploadedFile() file, @Body('nombreEvento') nombreEvento: string,) {
|
|
|
|
|
if(!file) {
|
|
|
|
|
throw new HttpException("No se ha cargado ningun archivo", HttpStatus.BAD_REQUEST)
|
|
|
|
|
}
|
|
|
|
|
console.log(file)
|
|
|
|
|
return this.emailService.sendConstancias(file, nombreEvento);
|
|
|
|
|
}
|
2023-03-14 15:26:00 -06:00
|
|
|
}
|