Merge branch 'email' of https://repositorio.acatlan.unam.mx/CIDWA/cedetec_api_nest into email
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
PORT=5089
|
||||
|
||||
DB_HOST=132.248.180.82
|
||||
DB_USER=user_cedetec
|
||||
DB_PASSWORD=c3t3d3c
|
||||
DB_NAME=Betelgeuse_Cedetec_Prueba
|
||||
DB_PORT=
|
||||
# DB_HOST=132.248.180.82
|
||||
# DB_USER=user_cedetec
|
||||
# DB_PASSWORD=c3t3d3c
|
||||
# DB_NAME=Betelgeuse_Cedetec_Prueba
|
||||
# DB_PORT=
|
||||
|
||||
# DB_HOST=localhost
|
||||
# DB_USER=root
|
||||
# DB_PASSWORD=Dosmiluno2001
|
||||
# DB_NAME=cedetec_proyectos
|
||||
# DB_PORT=3306
|
||||
DB_HOST=localhost
|
||||
DB_USER=root
|
||||
DB_PASSWORD=Dosmiluno2001
|
||||
DB_NAME=cedetec_proyectos
|
||||
DB_PORT=3306
|
||||
|
||||
DB_HOST_DSC = 132.248.180.82
|
||||
DB_USER_DSC = sites_user
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 58 KiB |
@@ -53,6 +53,10 @@ import { join } from 'path';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ServeStaticModule.forRoot({
|
||||
rootPath: join(__dirname, '..', 'public'),
|
||||
exclude: ['/api*'], // Excluir la ruta "/api" de servir archivos estáticos
|
||||
}),
|
||||
ConfigModule.forRoot({
|
||||
envFilePath: '.env',
|
||||
isGlobal: true,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
@@ -26,13 +27,40 @@ export class CarouselController {
|
||||
storage: diskStorage({
|
||||
destination: './public',
|
||||
filename: function (req, file, cb) {
|
||||
cb(null, file.originalname);
|
||||
const directory = './public';
|
||||
const filePath = `${directory}/${file.originalname}`;
|
||||
if (fs.existsSync(filePath)) {
|
||||
cb(
|
||||
new BadRequestException(
|
||||
`Ya existe un archivo con el nombre: '${file.originalname}'. Si está seguro de que no es el mismo, cambie el nombre del archivo.`,
|
||||
),
|
||||
null,
|
||||
);
|
||||
} else {
|
||||
cb(null, file.originalname);
|
||||
}
|
||||
},
|
||||
}),
|
||||
fileFilter: function (req, file, cb) {
|
||||
const filetypes = /jpeg|jpg|webp|png/;
|
||||
const extname = filetypes.test(
|
||||
path.extname(file.originalname).toLowerCase(),
|
||||
);
|
||||
const mimetype = filetypes.test(file.mimetype);
|
||||
if (mimetype && extname) {
|
||||
return cb(null, true);
|
||||
}
|
||||
cb(
|
||||
new BadRequestException(
|
||||
'Lo sentimos, para mejorar la calidad de las imagenes en el carousel solo se aceptan imagenes con terminación: .jpeg .jpg .png .webp',
|
||||
),
|
||||
false,
|
||||
);
|
||||
},
|
||||
}),
|
||||
)
|
||||
async addImage(@UploadedFile() file) {
|
||||
return {msg: 'Imagen guardada con exito :)'}
|
||||
return { msg: 'Imagen guardada con exito :)' };
|
||||
}
|
||||
|
||||
@Delete('/imagenes/:nombreArchivo')
|
||||
@@ -48,12 +76,16 @@ export class CarouselController {
|
||||
@Get('/imagenes')
|
||||
async getImages(@Res() res: Response) {
|
||||
// Leer el directorio 'public' para obtener el nombre de todos los archivos
|
||||
|
||||
const fileNames = await fs.promises.readdir('./public');
|
||||
// Generar la URL para cada archivo y agregarla a un arreglo
|
||||
const baseUrl = 'http://localhost:5089'; // reemplaza con la URL de tu servidor
|
||||
const imageUrls = fileNames.map(
|
||||
(fileName) => `${baseUrl}/public/${fileName}`,
|
||||
|
||||
// Filtrar solo las imágenes con las terminaciones "jpg", "webp" y "png"
|
||||
const imageNames = fileNames.filter((fileName) =>
|
||||
['.jpg', '.webp', '.png'].includes(path.extname(fileName)),
|
||||
);
|
||||
|
||||
const imageUrls = imageNames.map((imageName) => `public/${imageName}`);
|
||||
// Devolver el arreglo de URLs como respuesta
|
||||
return res.json(imageUrls);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ import { Injectable } from '@nestjs/common';
|
||||
export class CarouselService {
|
||||
|
||||
uploadImage(file){
|
||||
console.log(file)
|
||||
/* console.log(file) */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export class EmailController {
|
||||
if(!file) {
|
||||
throw new HttpException("No se ha cargado ningun archivo", HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
console.log(file)
|
||||
/* console.log(file) */
|
||||
return this.emailService.sendConstancias(file, nombreEvento);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ export class EmailService {
|
||||
}
|
||||
|
||||
async sendConstancias(file, nombreEvento) {
|
||||
console.log(file)
|
||||
/* console.log(file) */
|
||||
const workbook = xlsx.read(file.buffer);
|
||||
const worksheet = workbook.Sheets[workbook.SheetNames[0]];
|
||||
const data = xlsx.utils.sheet_to_json(worksheet);
|
||||
@@ -68,22 +68,6 @@ export class EmailService {
|
||||
const page = pdfDoc.addPage();
|
||||
page.setSize(792, 612);
|
||||
|
||||
page.drawRectangle({
|
||||
x: 0,
|
||||
y: page.getHeight() - 60,
|
||||
width: page.getWidth(),
|
||||
height: 60,
|
||||
color: rgb(0 / 255, 61 / 255, 121 / 255),
|
||||
});
|
||||
|
||||
page.drawRectangle({
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: page.getWidth(),
|
||||
height: 60,
|
||||
color: rgb(213 / 255, 159 / 255, 15 / 255),
|
||||
});
|
||||
|
||||
const font = await pdfDoc.embedFont(StandardFonts.HelveticaBold);
|
||||
const fontSize = 30;
|
||||
const text = 'Constancia de asistencia';
|
||||
@@ -126,8 +110,8 @@ export class EmailService {
|
||||
const url = URL.createObjectURL(blob); */
|
||||
this.transporter.sendMail({
|
||||
to: row.Email,
|
||||
subject: 'Constancia de asistencia',
|
||||
text: 'Hola',
|
||||
subject: `Constancia de asistencia a "${nombreEvento}"`,
|
||||
text: `¡Un saludo ${row.Nombre}! Aquí está tu constancia de asistencia por el evento "${nombreEvento}". Agradecemos tu asistencia y constancia, esperamos seguir viéndote en eventos futuros.`,
|
||||
attachments: [attachment],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,12 +46,25 @@ export class EventoParticipanteService {
|
||||
id_evento: number,
|
||||
registrarParticipanteDto: RegistrarParticipanteDto,
|
||||
) {
|
||||
/* console.log(id_evento);
|
||||
console.log(registrarParticipanteDto); */
|
||||
return this.participanteExiste(registrarParticipanteDto.email).then(
|
||||
(res) => {
|
||||
if (res) {
|
||||
this.registrarEnEvento(id_evento, res);
|
||||
|
||||
res.nombre = registrarParticipanteDto.nombre;
|
||||
res.apellido_paterno = registrarParticipanteDto.apellido_paterno;
|
||||
res.apellido_materno = registrarParticipanteDto.apellido_materno;
|
||||
res.carrera = registrarParticipanteDto.carrera;
|
||||
res.institucion_procedencia =
|
||||
registrarParticipanteDto.institucion_procedencia;
|
||||
|
||||
//si el correo ya existe en la base de datos solo se le cambia el nombre, apellidos, carrera e institucion
|
||||
|
||||
return this.participanteRepository
|
||||
.save(res)
|
||||
.then((participanteActualizado) => {
|
||||
this.registrarEnEvento(id_evento, participanteActualizado);
|
||||
return participanteActualizado;
|
||||
});
|
||||
} else {
|
||||
this.participanteRepository
|
||||
.save(this.participanteRepository.create(registrarParticipanteDto))
|
||||
|
||||
@@ -162,7 +162,7 @@ export class EventosService {
|
||||
});
|
||||
});
|
||||
|
||||
console.log(workbook.description);
|
||||
/* console.log(workbook.description); */
|
||||
|
||||
// Generar el archivo Excel y guardarlo en el servidor
|
||||
const fileName = `participantes-${idEvento}.xlsx`;
|
||||
@@ -190,7 +190,7 @@ export class EventosService {
|
||||
geteventosDisponiblesMasDosDias(){
|
||||
const hoy = new Date();
|
||||
return this.eventoRepository.createQueryBuilder("evento")
|
||||
.where(`DATE_ADD(evento.fecha_fin, INTERVAL 2 DAY) >= :hoy`, { hoy })
|
||||
.where(`DATE_ADD(evento.fecha_fin, INTERVAL 3 DAY) >= :hoy`, { hoy })
|
||||
.andWhere('fecha_fin <= :hoy', {hoy})
|
||||
.getMany();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user