se agrego controller para traer solo eventos disponibles y no todos

This commit is contained in:
JorgeMike
2023-03-20 20:00:10 -06:00
parent 569dbca11f
commit 4d6435ac8a
5 changed files with 28 additions and 25 deletions
+10 -10
View File
@@ -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=password
# DB_NAME=cedetec_proyectos
# DB_PORT=
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
+1 -1
View File
@@ -1,3 +1,4 @@
.env
# compiled output
/dist
/node_modules
@@ -34,4 +35,3 @@ lerna-debug.log*
!.vscode/launch.json
!.vscode/extensions.json
.env
Binary file not shown.
+5
View File
@@ -54,4 +54,9 @@ export class EventosController {
res.download(filePath);
}
@Post('disponibles')
getEventosDisponibles (){
return this.eventoService.getEventosDisponibles()
}
}
+12 -14
View File
@@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { EventoParticipante } from 'src/evento-participante/evento-participante/eventoParticipante.entity';
import { Participante } from 'src/participante/participante.entity';
import { Repository } from 'typeorm';
import { MoreThanOrEqual, Repository } from 'typeorm';
import { actualizarEventoDto } from './dto/actualizarEvento.dto';
import { crearEventoDto } from './dto/crearEvento.dto';
import { Evento } from './evento.entity';
@@ -103,17 +103,6 @@ export class EventosService {
const workbook = new ExcelJS.Workbook();
const worksheet = workbook.addWorksheet('Participantes');
// Definir estilos
const headerStyle = {
font: { bold: true },
alignment: { horizontal: 'center' },
border: { bottom: { style: 'medium' } },
};
const dataStyle = {
alignment: { horizontal: 'left' },
};
// Definir las columnas
worksheet.columns = [
{ header: 'Asistencia', key: 'asistencia', width: 10, style: {alignment: {horizontal: 'center'}}},
@@ -147,9 +136,18 @@ export class EventosService {
// Generar el archivo Excel y guardarlo en el servidor
const fileName = `participantes-${idEvento}.xlsx`;
const filePath = `./${fileName}`;
await workbook.xlsx.writeFile(filePath);
/* await workbook.xlsx.writeFile(filePath);
*/
// Devolver la ruta del archivo para que el cliente pueda descargarlo
return filePath;
}
getEventosDisponibles(){
const hoy = new Date();
return this.eventoRepository.find({
where: {
fecha_fin: MoreThanOrEqual(hoy)
}
})
}
}