email #6

Manually merged
jalvarado merged 4 commits from email into develop 2023-03-21 20:37:21 +00:00
30 changed files with 1541 additions and 1247 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
+1340 -1064
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -31,6 +31,7 @@
"bcrypt": "^5.1.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"exceljs": "^4.3.0",
"moment": "^2.29.4",
"mysql2": "^3.1.2",
"nodemailer": "^6.9.1",
@@ -45,6 +46,7 @@
"typeorm": "^0.3.12"
},
"devDependencies": {
"@jridgewell/sourcemap-codec": "^1.4.14",
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
+1 -1
View File
@@ -1,2 +1,2 @@
INSERT INTO miembro (nombre, apellido_paterno, apellido_materno, id_tipo_miembro, email, password, descripcion, semestre, cuenta)
VALUES ('Jorge', 'Alvarado', 'Reyes', 1, 'Admin@unam.com', '$2b$10$1ExBjP1J1PET5N4m9Thv7O0l0nNjPsMYQW6.TZveaCFz0OkLh06Dy', 'Estudiante de Ingeniería en Sistemas', '4', 421010301);
VALUES ('Jorge', 'Alvarado', 'Reyes', 1, 'Admin@unam.com', '$2b$10$1ExBjP1J1PET5N4m9Thv7O0l0nNjPsMYQW6.TZveaCFz0OkLh06Dy', 'Estudiante de Ingeniería en Sistemas', '4', 123456789);
-4
View File
@@ -7,14 +7,12 @@ import { EventosModule } from './eventos/eventos.module';
import { ParticipanteController } from './participante/participante.controller';
import { ParticipanteModule } from './participante/participante.module';
import { EventoParticipanteModule } from './evento-participante/evento-participante/evento-participante.module';
import { UsuarioModule } from './usuario/usuario.module';
import { AuthModule } from './auth/auth.module';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { Evento } from './eventos/evento.entity';
import { Participante } from './participante/participante.entity';
import { EventoParticipante } from './evento-participante/evento-participante/eventoParticipante.entity';
import { Usuario } from './usuario/usuario.entity';
import { InscripcionDscModule } from './inscripcion-dsc/inscripcion-dsc.module';
import { InscripcionAreaModule } from './inscripcion-area/inscripcion-area.module';
import { InscripcionStatusService } from './inscripcion-status/inscripcion-status.service';
@@ -68,7 +66,6 @@ import { EmailModule } from './email/email.module';
Evento,
Participante,
EventoParticipante,
Usuario,
/* Agregadas el 29 de febrero */
Miembro,
InscripcionArea,
@@ -94,7 +91,6 @@ import { EmailModule } from './email/email.module';
EventosModule,
ParticipanteModule,
EventoParticipanteModule,
UsuarioModule,
AuthModule,
PassportModule,
JwtModule.register({}),
+2 -4
View File
@@ -1,12 +1,10 @@
import { Body, Controller, Post, Request, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { InjectRepository } from '@nestjs/typeorm';
import { Usuario } from 'src/usuario/usuario.entity';
import { Repository } from 'typeorm';
import { AuthService } from './auth.service';
import { LoginUsuarioDto } from './dto/loginUsuario.dto';
import { LoginMiembroDto } from './dto/loginMiembro.dto';
import { RegistrarMiembroDto } from './dto/registrarMiembro.dto';
import { RegistrarUsuarioDto } from './dto/registrarUsuario.dto';
@Controller('auth')
export class AuthController {
@@ -20,7 +18,7 @@ export class AuthController {
}
@Post('login')
login(@Body() LoginUsuario: LoginUsuarioDto) {
login(@Body() LoginUsuario: LoginMiembroDto) {
return this.authService.login(LoginUsuario);
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ export class LoginMiembroDto {
@IsEmail()
email: string
@MinLength(10)
@MinLength(5)
@MaxLength(15)
password: string
}
-10
View File
@@ -1,10 +0,0 @@
import { IsEmail, MaxLength, MinLength } from "class-validator";
export class LoginUsuarioDto {
@IsEmail()
email: string
@MinLength(10)
@MaxLength(15)
password: string
}
+2 -2
View File
@@ -1,8 +1,8 @@
import { PartialType } from '@nestjs/swagger';
import { IsEmail, IsNotEmpty, MaxLength, MinLength } from 'class-validator';
import { LoginUsuarioDto } from './loginUsuario.dto';
import { LoginMiembroDto } from './loginMiembro.dto';
export class RegistrarMiembroDto extends PartialType(LoginUsuarioDto) {
export class RegistrarMiembroDto extends PartialType(LoginMiembroDto) {
@IsNotEmpty()
nombre: string;
-18
View File
@@ -1,18 +0,0 @@
import { PartialType } from '@nestjs/swagger';
import { IsEmail, IsNotEmpty, MaxLength, MinLength } from 'class-validator';
import { LoginUsuarioDto } from './loginUsuario.dto';
export class RegistrarUsuarioDto extends PartialType(LoginUsuarioDto) {
@IsNotEmpty()
name: string;
@IsNotEmpty()
lastName: string;
@IsEmail()
email: string;
@MinLength(10)
@MaxLength(15)
password: string;
}
+1 -1
View File
@@ -6,7 +6,7 @@ export class Area {
@PrimaryGeneratedColumn()
id_area: number
@Column({length:60, nullable:false})
@Column({length:20, nullable:false})
area: string
@OneToMany(
+1 -1
View File
@@ -6,7 +6,7 @@ export class Carrera {
@PrimaryGeneratedColumn()
id_carrera: number
@Column({ length:70, nullable: false})
@Column({ length:40, nullable: false})
carrera: string
@OneToMany(
+1 -1
View File
@@ -6,7 +6,7 @@ export class TipoMiembro {
@PrimaryGeneratedColumn()
id_tipo_miembro: number
@Column({length:60, nullable:false})
@Column({length:15, nullable:false})
tipo_miembro: string
@OneToMany(
+3 -3
View File
@@ -10,13 +10,13 @@ export class Contacto {
@Column({nullable:false})
email: string
@Column()
@Column({length: 40})
horario: string
@Column({nullable:true})
@Column({length: 75, nullable:true})
facebook: string
@Column({nullable: true})
@Column({length: 60, nullable: true})
linkedin: string
@ManyToOne(
+1 -1
View File
@@ -10,7 +10,7 @@ export class Equipo{
@Column({length:50, nullable:true})
nombre: string
@Column({length:250})
@Column({length:100})
descripcion:string
@OneToMany(
@@ -17,6 +17,11 @@ export class RegistrarParticipanteDto {
@IsNotEmpty()
carrera: string;
@IsString()
@IsNotEmpty()
institucion_procedencia: string;
@IsEmail()
email: string;
}
+3 -3
View File
@@ -1,9 +1,9 @@
export class actualizarEventoDto {
nombre?: string;
tipo_evento?: string;
organizadores?: string[];
proyecto?: string[];
modalidad?: string[];
organizadores?: string;
proyecto?: string;
modalidad?: string;
lugar?: string;
requisitos?: string;
cuota_inscripcion?: number;
+4 -4
View File
@@ -1,16 +1,16 @@
export class crearEventoDto {
nombre: string;
tipo_evento: string;
organizadores: string[];
proyecto: string[];
modalidad: string[];
organizadores: string;
proyecto: string;
modalidad: string;
lugar: string;
cupo: number;
requisitos: string;
cuota_inscripcion: number;
patrocinador: string;
tipo_acreditacion: string;
descripcion: string;
objetivo: string;
fecha_inicio: Date;
fecha_fin: Date;
fecha_limite_inscripcion: Date;
+16 -19
View File
@@ -14,41 +14,41 @@ export class Evento {
@PrimaryGeneratedColumn()
id_evento: number;
@Column({ nullable: false })
@Column({length: 70, nullable: false })
nombre: string;
@Column({ nullable: false })
@Column({length: 15, nullable: false })
tipo_evento: string;
@Column("simple-array", {nullable: false})
organizadores: string[]
@Column({length: 100,nullable: false})
organizadores: string
@Column("simple-array", {nullable: false})
proyecto: string[]
@Column({length:30 ,nullable: true})
proyecto: string
@Column("simple-array", {nullable: false})
modalidad: string[]
@Column({length: 40,nullable: false})
modalidad: string
@Column({ nullable: false })
@Column({length: 60,nullable: false })
lugar: string;
@Column({nullable: false})
cupo: number;
@Column({ nullable: false })
@Column({length: 60, nullable: false })
requisitos: string;
@Column({ nullable: true })
@Column({type:'decimal', precision: 7, scale: 2, nullable: true })
cuota_inscripcion: number;
@Column({ nullable: true })
@Column({length: 50, nullable: true })
patrocinador: string;
@Column({ nullable: true })
@Column({length: 40, nullable: true })
tipo_acreditacion: string;
@Column({nullable: false})
descripcion: string
@Column({length: 200 ,nullable: false})
objetivo: string
@Column({ nullable: false, type: 'datetime' })
fecha_inicio: Date;
@@ -59,10 +59,7 @@ export class Evento {
@Column({ nullable: false, type: 'datetime' })
fecha_limite_inscripcion: Date;
@Column({ nullable: true })
evento_identificador: string;
@Column({ nullable: true })
@Column({length:40 ,nullable: true })
horario: string;
@Column({ nullable: true })
+13 -1
View File
@@ -1,4 +1,5 @@
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from '@nestjs/common';
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post, Res } from '@nestjs/common';
import { Response } from 'express';
import { InjectRepository } from '@nestjs/typeorm';
import { EventoParticipante } from 'src/evento-participante/evento-participante/eventoParticipante.entity';
import { Repository } from 'typeorm';
@@ -46,4 +47,15 @@ export class EventosController {
async getParticipnates(@Param('id', ParseIntPipe)id:number){
return this.eventoService.getParticipantes(id)
}
@Get(':id/exportExcel')
async exportarExcel (@Param('id', ParseIntPipe)id:number ,@Res() res: Response){
this.eventoService.exportarParticipantes(id, res)
}
@Post('disponibles')
getEventosDisponibles (){
return this.eventoService.getEventosDisponibles()
}
}
+109 -9
View File
@@ -2,10 +2,12 @@ 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';
import * as ExcelJS from 'exceljs';
import { Response } from 'express';
@Injectable()
export class EventosService {
@@ -13,7 +15,8 @@ export class EventosService {
@InjectRepository(Evento) private eventoRepository: Repository<Evento>,
@InjectRepository(EventoParticipante)
private eventoParticipanteRepository: Repository<EventoParticipante>,
@InjectRepository(Participante) private participanteRepository:Repository<Participante>
@InjectRepository(Participante)
private participanteRepository: Repository<Participante>,
) {}
getEventos() {
@@ -77,13 +80,110 @@ export class EventosService {
async getParticipantes(idEvento: number) {
const participantes = await this.participanteRepository
.createQueryBuilder('participante')
.innerJoin('participante.eventosParticipante', 'eventoParticipante')
.innerJoin('eventoParticipante.evento', 'evento')
.where('evento.id_evento = :idEvento', { idEvento })
.select(['participante.nombre','participante.apellido_paterno','participante.carrera', 'participante.email'])
.getMany();
.createQueryBuilder('participante')
.innerJoin('participante.eventosParticipante', 'eventoParticipante')
.innerJoin('eventoParticipante.evento', 'evento')
.where('evento.id_evento = :idEvento', { idEvento })
.select([
'participante.nombre',
'participante.apellido_paterno',
'participante.apellido_materno',
'participante.carrera',
'participante.email',
'participante.institucion_procedencia',
])
.getMany();
return participantes;
}
return participantes;
async exportarParticipantes(idEvento: number, res: Response): Promise<void> {
const participantes: Participante[] = await this.getParticipantes(idEvento);
/*console.log(participantes);*/
// Crear el workbook y la worksheet
const workbook = new ExcelJS.Workbook();
const worksheet = workbook.addWorksheet('Participantes');
// Definir las columnas
worksheet.columns = [
{
header: 'Asistencia',
key: 'asistencia',
width: 10,
style: { alignment: { horizontal: 'center' } },
},
{
header: 'Nombre',
key: 'nombre',
width: 20,
style: { alignment: { horizontal: 'center' } },
},
{
header: 'Apellido Paterno',
key: 'apellido_paterno',
width: 20,
style: { alignment: { horizontal: 'center' } },
},
{
header: 'Apellido Materno',
key: 'apellido_materno',
width: 20,
style: { alignment: { horizontal: 'center' } },
},
{
header: 'Carrera',
key: 'carrera',
width: 20,
style: { alignment: { horizontal: 'center' } },
},
{
header: 'Email',
key: 'email',
width: 35,
style: { alignment: { horizontal: 'center' } },
},
{
header: 'Institución Procedencia',
key: 'institucion_procedencia',
width: 30,
style: { alignment: { horizontal: 'center' } },
},
];
// Agregar los datos a la worksheet
participantes.forEach((participante) => {
worksheet.addRow({
asistencia: '',
nombre: participante.nombre,
apellido_paterno: participante.apellido_paterno,
apellido_materno: participante.apellido_materno,
carrera: participante.carrera,
email: participante.email,
institucion_procedencia: participante.institucion_procedencia,
});
});
console.log(workbook.description);
// Generar el archivo Excel y guardarlo en el servidor
const fileName = `participantes-${idEvento}.xlsx`;
// Configurar la respuesta HTTP para descargar el archivo
res.setHeader(
'Content-Type',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
);
res.setHeader('Content-Disposition', `attachment; filename="${fileName}"`);
// Escribir el archivo Excel en la respuesta HTTP
const buffer = await workbook.xlsx.writeBuffer();
res.send(buffer);
}
getEventosDisponibles() {
const hoy = new Date();
return this.eventoRepository.find({
where: {
fecha_fin: MoreThanOrEqual(hoy),
},
});
}
}
+6 -6
View File
@@ -19,26 +19,26 @@ export class Miembro {
@PrimaryGeneratedColumn()
id_miembro: number;
@Column({ nullable: false, length: 50 })
@Column({ nullable: false, length: 40 })
nombre: string;
@Column({ nullable: false, length: 50 })
@Column({ nullable: false, length: 30 })
apellido_paterno: string;
@Column({ nullable: false, length: 50 })
@Column({ nullable: false, length: 30 })
apellido_materno: string;
@Column({ nullable: false })
id_tipo_miembro: number;
@Column({ nullable: false })
@Column({length: 40, nullable: false })
@IsEmail()
email: string;
@Column({ nullable: false })
@Column({length: 180, nullable: false })
password: string;
@Column({ length: 260, nullable:true})
@Column({ length: 200, nullable:true})
descripcion: string;
@Column({nullable: true})
+6 -2
View File
@@ -1,4 +1,4 @@
import { Controller, Get, Param, ParseIntPipe, UseGuards } from '@nestjs/common';
import { Controller, Delete, Get, Param, ParseIntPipe, UseGuards } from '@nestjs/common';
import { JwtAuthGuard } from 'src/auth/jwt-auth.guard';
import { Miembro } from './entity/miembro.entity';
import { MiembroService } from './miembro.service';
@@ -8,7 +8,6 @@ export class MiembroController {
constructor(private readonly miembroService: MiembroService){}
@UseGuards(JwtAuthGuard)
@Get()
getUsuarios(): Promise<Miembro[]>{
return this.miembroService.getUsuarios()
@@ -18,4 +17,9 @@ export class MiembroController {
getMiembros(@Param('tipo', ParseIntPipe)tipo: number): Promise<Miembro[]>{
return this.miembroService.getMiembros(tipo)
}
@Delete(':id')
deleteMiembro(@Param('id', ParseIntPipe)id: number){
return this.miembroService.deleteMiembro(id)
}
}
+4
View File
@@ -28,4 +28,8 @@ export class MiembroService {
}
})
}
deleteMiembro(id: number){
return this.miembroRepository.delete({id_miembro: id})
}
}
+9 -12
View File
@@ -6,34 +6,31 @@ export class Participante {
@PrimaryGeneratedColumn()
id_participante: number;
@Column({ type: String, nullable: false, length: 100 })
@Column({ type: String, nullable: false, length: 40 })
nombre: string;
@Column({ nullable: false })
@Column({ nullable: false, length: 30 })
apellido_paterno: string;
@Column({ nullable: false })
@Column({ nullable: false, length: 30 })
apellido_materno: string;
@Column({ nullable: true })
@Column({ nullable: true, length: 12 })
telefono: string;
@Column({ nullable: false })
@Column({ nullable: false, length: 40 })
email: string;
@Column({ nullable: true }) //
@Column({ nullable: true, length: 180}) //
password: string;
@Column({ nullable: true }) //
@Column({length:20, nullable: true }) //
tipo: string;
@Column({ nullable: true }) //
estado: string;
@Column({ nullable: true })
@Column({ nullable: true, length: 50})
institucion_procedencia: string;
@Column({ nullable: true })
@Column({ nullable: true, length:50})
carrera: string;
@OneToMany(
-16
View File
@@ -1,16 +0,0 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
@Entity()
export class Usuario {
@PrimaryGeneratedColumn()
id_usuario: number;
@Column({ nullable: false })
nombre: string;
@Column({ nullable: false })
password: string;
@Column({nullable:false})
email:string
}
-12
View File
@@ -1,12 +0,0 @@
import { Module } from '@nestjs/common';
import { UsuarioService } from './usuario.service';
import { UsuarioController } from './usuarios.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Usuario } from './usuario.entity';
@Module({
imports:[TypeOrmModule.forFeature([Usuario])],
providers: [UsuarioService],
controllers: [UsuarioController]
})
export class UsuarioModule {}
-23
View File
@@ -1,23 +0,0 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Usuario } from './usuario.entity';
@Injectable()
export class UsuarioService {
constructor(
@InjectRepository(Usuario) private usuarioRepository: Repository<Usuario>,
) {}
getUsuarios(){
return this.usuarioRepository.find()
}
getUsuario(email: string) {
return this.usuarioRepository.findOne({
where: {
email,
},
});
}
}
-18
View File
@@ -1,18 +0,0 @@
import { Controller, Get, UseGuards } from '@nestjs/common';
import { ApiBearerAuth } from '@nestjs/swagger';
import { JwtAuthGuard } from 'src/auth/jwt-auth.guard';
import { Usuario } from './usuario.entity';
import { UsuarioService } from './usuario.service';
@ApiBearerAuth()
@Controller('usuarios')
export class UsuarioController {
constructor(private readonly usuarioService: UsuarioService){}
@UseGuards(JwtAuthGuard)
@Get()
getUsuarios(): Promise<Usuario[]>{
return this.usuarioService.getUsuarios()
}
}