se creo el servicio para guardar participantes
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
PORT=5089
|
||||
|
||||
DB_HOST=localhost
|
||||
DB_USER=root
|
||||
DB_PASS=password
|
||||
DB_NAME=cedetec_proyectos
|
||||
|
||||
|
||||
SALT_ROUNDS = 10
|
||||
|
||||
KEY =
|
||||
CADUCIDAD_TOKEN = 1800000
|
||||
|
||||
TOKEN_KEY =
|
||||
TOKEN_EXPIRATION = 1800000
|
||||
|
||||
|
||||
EMAIL=
|
||||
EMAIL_PASS=
|
||||
Generated
+1023
-112
File diff suppressed because it is too large
Load Diff
+5
-1
@@ -21,13 +21,17 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^9.0.0",
|
||||
"@nestjs/config": "^2.3.1",
|
||||
"@nestjs/core": "^9.0.0",
|
||||
"@nestjs/platform-express": "^9.0.0",
|
||||
"@nestjs/typeorm": "^9.0.1",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.14.0",
|
||||
"moment": "^2.29.4",
|
||||
"pg": "^8.9.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rxjs": "^7.2.0"
|
||||
"rxjs": "^7.2.0",
|
||||
"typeorm": "^0.3.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^9.0.0",
|
||||
|
||||
+28
-4
@@ -1,11 +1,35 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config'
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { eventsModule } from './events/events.module';
|
||||
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';
|
||||
|
||||
@Module({
|
||||
imports: [eventsModule],
|
||||
controllers: [AppController],
|
||||
imports: [
|
||||
ConfigModule.forRoot({isGlobal: true}),
|
||||
TypeOrmModule.forRoot({
|
||||
type: 'mariadb',
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
username:'root',
|
||||
password: 'password',
|
||||
database: 'cedetec_proyectos',
|
||||
entities: [__dirname + '/**/*.entity{.ts,.js}'],
|
||||
synchronize: true
|
||||
}),
|
||||
EventosModule,
|
||||
ParticipanteModule,
|
||||
EventoParticipanteModule],
|
||||
controllers: [AppController, ParticipanteController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
export class AppModule {
|
||||
static port: number
|
||||
constructor(private readonly configService: ConfigService){
|
||||
AppModule.port = this.configService.get('PORT')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class RegistrarParticipanteDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
nombre: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
apellido_paterno: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
apellido_materno: string;
|
||||
|
||||
@IsEmail()
|
||||
correo: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
carrera: string;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Body, Controller, Post } from '@nestjs/common';
|
||||
import { RegistrarParticipanteDto } from './dto/registrarParticipanteDto.dto';
|
||||
import { EventoParticipanteService } from './evento-participante.service';
|
||||
|
||||
@Controller('evento-participante')
|
||||
export class EventoParticipanteController {
|
||||
constructor(private readonly eventoParticipanteService: EventoParticipanteService){}
|
||||
|
||||
@Post()
|
||||
regitrarParticipante(@Body() datos: RegistrarParticipanteDto){
|
||||
return this.eventoParticipanteService.registrarParticipante(datos)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Participante } from 'src/participante/participante.entity';
|
||||
import { EventoParticipanteController } from './evento-participante.controller';
|
||||
import { EventoParticipanteService } from './evento-participante.service';
|
||||
import { EventoParticipante } from './eventoParticipante.entity';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([EventoParticipante,Participante])],
|
||||
controllers: [EventoParticipanteController],
|
||||
providers: [EventoParticipanteService]
|
||||
})
|
||||
export class EventoParticipanteModule {}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { ConflictException, Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import { RegistrarParticipanteDto } from './dto/registrarParticipanteDto.dto';
|
||||
|
||||
import { Evento } from 'src/eventos/evento.entity';
|
||||
import { EventoParticipante } from './eventoParticipante.entity';
|
||||
import { Participante } from 'src/participante/participante.entity';
|
||||
|
||||
@Injectable()
|
||||
export class EventoParticipanteService {
|
||||
constructor(
|
||||
@InjectRepository(Participante)
|
||||
private participanteRepository: Repository<Participante>,
|
||||
) {}
|
||||
|
||||
participanteExiste(correo: string): Promise<Participante> {
|
||||
return this.participanteRepository.findOne({ where: { correo } });
|
||||
}
|
||||
|
||||
registrarParticipante(registrarParticipanteDto: RegistrarParticipanteDto) {
|
||||
return this.participanteExiste(registrarParticipanteDto.correo).then(
|
||||
(participante) => {
|
||||
if (participante) {
|
||||
throw new ConflictException('Este Usuario ya existe');
|
||||
}
|
||||
return this.participanteRepository.save(
|
||||
this.participanteRepository.create(registrarParticipanteDto)
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Evento } from 'src/eventos/evento.entity';
|
||||
import { Entity, JoinColumn, ManyToOne, PrimaryColumn, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { Participante } from '../../participante/participante.entity';
|
||||
|
||||
@Entity()
|
||||
export class EventoParticipante {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_eventoParticipante: number
|
||||
|
||||
@ManyToOne(() => Evento, (evento) => evento.eventoParticipantes)
|
||||
@JoinColumn({ name: 'id_evento' })
|
||||
evento: Evento;
|
||||
|
||||
@ManyToOne(
|
||||
() => Participante,
|
||||
(participante) => participante.eventosParticipante,
|
||||
)
|
||||
@JoinColumn({ name: 'id_participante' })
|
||||
participante: Participante;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
export class actualizarEventoDto {
|
||||
nombre?: string
|
||||
|
||||
evento_identificador ?: string
|
||||
|
||||
fecha_inicio?: Date
|
||||
|
||||
fecha_fin?: Date
|
||||
|
||||
horario?: string
|
||||
|
||||
requisitos?: string
|
||||
|
||||
modalidad?: string
|
||||
|
||||
lugar?: string
|
||||
|
||||
cuota_inscripcion ?: number
|
||||
|
||||
patrocinador ?: string
|
||||
|
||||
tipo_acreditacion?: string
|
||||
|
||||
fecha_limite_inscripcion?: Date
|
||||
|
||||
tipo_evento?: string
|
||||
|
||||
estado?: boolean
|
||||
|
||||
descripcion?: string
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
export class crearEventoDto {
|
||||
nombre: string
|
||||
|
||||
evento_identificador ?: string
|
||||
|
||||
fecha_inicio: Date
|
||||
|
||||
fecha_fin: Date
|
||||
|
||||
horario: string
|
||||
|
||||
requisitos: string
|
||||
|
||||
modalidad: string
|
||||
|
||||
lugar: string
|
||||
|
||||
cuota_inscripcion ?: number
|
||||
|
||||
patrocinador ?: string
|
||||
|
||||
tipo_acreditacion: string
|
||||
|
||||
fecha_limite_inscripcion: Date
|
||||
|
||||
tipo_evento: string
|
||||
|
||||
estado: boolean
|
||||
|
||||
descripcion: string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { EventoParticipante } from 'src/evento-participante/evento-participante/eventoParticipante.entity';
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
@Entity()
|
||||
export class Evento {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_evento: number;
|
||||
|
||||
@Column({ nullable: false })
|
||||
nombre: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
evento_identificador: string;
|
||||
|
||||
@Column({ nullable: false, type: 'datetime' })
|
||||
fecha_inicio: Date;
|
||||
|
||||
@Column({ nullable: false, type: 'datetime' })
|
||||
fecha_fin: Date;
|
||||
|
||||
@Column({ nullable: false })
|
||||
horario: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
requisitos: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
modalidad: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
lugar: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
cuota_inscripcion: number;
|
||||
|
||||
@Column({ nullable: true })
|
||||
patrocinador: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
tipo_acreditacion: string;
|
||||
|
||||
@Column({ nullable: false, type: 'datetime' })
|
||||
fecha_limite_inscripcion: Date;
|
||||
|
||||
@Column({ nullable: false })
|
||||
tipo_evento: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
estado: boolean;
|
||||
|
||||
@Column({ nullable: false })
|
||||
descripcion: string;
|
||||
|
||||
@OneToMany(
|
||||
() => EventoParticipante,
|
||||
(eventoParticipante) => eventoParticipante.evento,
|
||||
)
|
||||
eventoParticipantes: EventoParticipante[];
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from '@nestjs/common';
|
||||
import { actualizarEventoDto } from './dto/actualizarEvento.dto';
|
||||
import { crearEventoDto } from './dto/crearEvento.dto';
|
||||
import { Evento } from './evento.entity';
|
||||
import { EventosService } from './eventos.service';
|
||||
|
||||
@Controller('eventos')
|
||||
export class EventosController {
|
||||
|
||||
constructor(private readonly eventoService: EventosService){}
|
||||
|
||||
@Get()
|
||||
getEventos(): Promise<Evento[]>{
|
||||
return this.eventoService.getEventos()
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
getEventosPorId(@Param('id', ParseIntPipe)id: number):Promise<Evento>{
|
||||
return this.eventoService.getEventosPorId(id)
|
||||
}
|
||||
|
||||
@Post()
|
||||
postEvento(@Body() nuevoEvento: crearEventoDto): Promise<Evento>{
|
||||
return this.eventoService.postEvento(nuevoEvento)
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
patchEvento(@Param('id', ParseIntPipe)id:number, @Body() actualizacion: actualizarEventoDto){
|
||||
return this.eventoService.updateEvento(id,actualizacion)
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
deleteEvento(@Param('id', ParseIntPipe)id: number){
|
||||
return this.eventoService.deleteEvento(id)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Evento } from './evento.entity';
|
||||
import { EventosController } from './eventos.controller';
|
||||
import { EventosService } from './eventos.service';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([Evento])],
|
||||
controllers:[EventosController],
|
||||
providers:[EventosService]
|
||||
})
|
||||
export class EventosModule {}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { actualizarEventoDto } from './dto/actualizarEvento.dto';
|
||||
import { crearEventoDto } from './dto/crearEvento.dto';
|
||||
import { Evento } from './evento.entity';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class EventosService {
|
||||
constructor(@InjectRepository(Evento) private eventoRepository: Repository<Evento>){}
|
||||
|
||||
getEventos(){
|
||||
return this.eventoRepository.find()
|
||||
}
|
||||
|
||||
getEventosPorId(id: number){
|
||||
return this.eventoRepository.findOne({
|
||||
where:{
|
||||
id_evento: id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
postEvento(evento: crearEventoDto){
|
||||
const nuevoEvento = this.eventoRepository.create(evento)
|
||||
return this.eventoRepository.save(nuevoEvento)
|
||||
}
|
||||
|
||||
updateEvento(id: number, actualizacion: actualizarEventoDto){
|
||||
return this.eventoRepository.update({id_evento: id}, actualizacion)
|
||||
}
|
||||
|
||||
deleteEvento(id:number){
|
||||
return this.eventoRepository.delete({id_evento:id})
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
import { IsString } from "class-validator";
|
||||
import { IsBoolean, IsDate, IsNumber } from "class-validator";
|
||||
|
||||
export class CreateEventDto {
|
||||
@IsNumber()
|
||||
id_event: number
|
||||
|
||||
@IsString()
|
||||
event_name: string
|
||||
|
||||
@IsString()
|
||||
desciption:string
|
||||
|
||||
@IsNumber()
|
||||
limit: number
|
||||
|
||||
@IsDate()
|
||||
start_date:Date
|
||||
|
||||
@IsDate()
|
||||
end_date:Date
|
||||
|
||||
@IsDate()
|
||||
regitration_deadline:Date
|
||||
|
||||
@IsString()
|
||||
start_time:string
|
||||
|
||||
@IsString()
|
||||
end_time:string
|
||||
|
||||
@IsString()
|
||||
requirements: string
|
||||
|
||||
@IsString()
|
||||
modality: string
|
||||
|
||||
@IsString()
|
||||
place: string
|
||||
|
||||
@IsNumber()
|
||||
registration_fee: number
|
||||
|
||||
@IsString()
|
||||
sponsor: string
|
||||
|
||||
@IsString()
|
||||
type_acreditation: string
|
||||
|
||||
@IsString()
|
||||
event_type: string
|
||||
|
||||
@IsBoolean()
|
||||
active: boolean
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity()
|
||||
export class event {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_evento: number
|
||||
|
||||
@Column()
|
||||
evento_identificador: string
|
||||
|
||||
@Column()
|
||||
nombre: string
|
||||
|
||||
@Column()
|
||||
fecha_inicio: Date
|
||||
|
||||
@Column()
|
||||
fecha_fin: Date
|
||||
|
||||
@Column()
|
||||
horario: string
|
||||
|
||||
@Column()
|
||||
requisitos: string
|
||||
|
||||
@Column()
|
||||
modalidad: string
|
||||
|
||||
@Column()
|
||||
lugar: string
|
||||
|
||||
@Column()
|
||||
cuota_inscripcion: number
|
||||
|
||||
@Column()
|
||||
patrocinador: string
|
||||
|
||||
@Column()
|
||||
tipo_acreditacion: string
|
||||
|
||||
@Column()
|
||||
fecha_limite_inscripcion: string
|
||||
|
||||
@Column()
|
||||
tipo_evento: string
|
||||
|
||||
@Column()
|
||||
estado: boolean
|
||||
|
||||
@Column()
|
||||
descripcion: string
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
import { CreateEventDto } from './dto/create-event.dto';
|
||||
import { event } from './event.entity';
|
||||
import { EventsService } from './events.service';
|
||||
|
||||
@Controller('events')
|
||||
export class EventsController {
|
||||
constructor(private readonly eventsServices: EventsService) {}
|
||||
|
||||
@Get()
|
||||
getEvents(): event[] {
|
||||
return this.eventsServices.getEvents();
|
||||
}
|
||||
|
||||
/* @Get(':id')
|
||||
getEvent(@Param() params){
|
||||
return `El evento que estamos llamando es: ${params.id}`
|
||||
} */
|
||||
|
||||
@Get(':id')
|
||||
getEvent(@Param('id') id: string): event {
|
||||
return this.eventsServices.getEvent(parseInt(id));
|
||||
}
|
||||
|
||||
@Post()
|
||||
createEvent(@Body() body: CreateEventDto): string {
|
||||
this.eventsServices.createEvent(body);
|
||||
return 'evento creado con exito';
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
deleteEvent(@Param('id') id: string) {
|
||||
return this.eventsServices.deleteEvent(parseInt(id));
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
updateEvent(@Param('id') id: string, @Body() body) {
|
||||
return `Actualizando el evento: ${id}`;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { EventsController } from "./events.controller";
|
||||
import { EventsService } from "./events.service";
|
||||
|
||||
@Module({
|
||||
controllers: [EventsController],
|
||||
providers: [EventsService],
|
||||
})
|
||||
|
||||
export class eventsModule {}
|
||||
@@ -1,71 +0,0 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { event } from './event.entity';
|
||||
import * as moment from 'moment';
|
||||
import { CreateEventDto } from './dto/create-event.dto';
|
||||
|
||||
@Injectable()
|
||||
export class EventsService {
|
||||
private events: event[] = [
|
||||
{
|
||||
id_event: 1, //id_evento
|
||||
event_name: 'Platica de ejemplo', //nombre
|
||||
desciption: 'Esta platica servira como ejemplo', //descripcion
|
||||
limit: 30, //limite
|
||||
start_date: new Date('2023-02-20'), //fecha_inicio
|
||||
end_date: new Date('2023-02-20'), //fecha_fin
|
||||
regitration_deadline: new Date('2023-02-19'), //fecha_limite_inscripcionme
|
||||
start_time: '13:00', //hora de inicio
|
||||
end_time: '14:00', //hora de fin
|
||||
requirements: 'Sin requerimientos de hardware ni conocimiento',
|
||||
modality: 'mixta', //modalidad
|
||||
place: 'CEDETEC', //lugar
|
||||
registration_fee: 0.0, //cuota_inscripcionl
|
||||
sponsor: 'CIDWA', //patrocinador
|
||||
type_acreditation: 'nose', //tipo_acreditacion
|
||||
event_type: 'Platica', //tipo_evento
|
||||
active: true, //estado
|
||||
}
|
||||
];
|
||||
|
||||
getEvents(): event[]{
|
||||
return this.events
|
||||
}
|
||||
|
||||
getEvent(id: number): event{
|
||||
const eventGetting = this.events.find((item) => item.id_event === id);
|
||||
if(!eventGetting){
|
||||
throw new NotFoundException("Evento no encontrado")
|
||||
}
|
||||
return eventGetting
|
||||
}
|
||||
|
||||
createEvent(body: CreateEventDto){
|
||||
this.events.push({
|
||||
id_event: (Math.floor(Math.random()*20000) + 1 ),
|
||||
event_name: body.event_name,
|
||||
desciption: body.desciption,
|
||||
limit: body.limit,
|
||||
start_date: body.start_date,
|
||||
end_date: body.end_date,
|
||||
regitration_deadline: body.regitration_deadline,
|
||||
start_time: body.start_time,
|
||||
end_time: body.end_time,
|
||||
requirements: body.requirements,
|
||||
modality: body.modality,
|
||||
place: body.place,
|
||||
registration_fee: body.registration_fee,
|
||||
sponsor: body.sponsor,
|
||||
type_acreditation: body.type_acreditation,
|
||||
event_type: body.event_type,
|
||||
active: body.active,
|
||||
})
|
||||
}
|
||||
|
||||
deleteEvent(id: number){
|
||||
const index = this.events.findIndex((event) => event.id_event === id);
|
||||
if(index >= 0){
|
||||
this.events.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -3,6 +3,6 @@ import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
await app.listen(3000);
|
||||
await app.listen(AppModule.port);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Controller, Post } from '@nestjs/common';
|
||||
import { ParticipanteService } from './participante.service';
|
||||
|
||||
@Controller('participante')
|
||||
export class ParticipanteController {}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { EventoParticipante } from 'src/evento-participante/evento-participante/eventoParticipante.entity';
|
||||
|
||||
@Entity()
|
||||
export class Participante {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_participante: number;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 100 })
|
||||
nombre: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
apellido_paterno: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
apellido_materno: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
telefono: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
correo: string;
|
||||
|
||||
@Column({ nullable: true }) //
|
||||
password: string;
|
||||
|
||||
@Column({ nullable: true }) //
|
||||
tipo: string;
|
||||
|
||||
@Column({ nullable: true }) //
|
||||
estado: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
institucion_procedencia: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
carrera: string;
|
||||
|
||||
@OneToMany(
|
||||
() => EventoParticipante,
|
||||
(eventoParticipante) => eventoParticipante.participante,
|
||||
)
|
||||
eventosParticipante: EventoParticipante[];
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ParticipanteController } from './participante.controller';
|
||||
import { Participante } from './participante.entity';
|
||||
import { ParticipanteService } from './participante.service';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([Participante])],
|
||||
controllers:[ParticipanteController],
|
||||
providers: [ParticipanteService]
|
||||
})
|
||||
export class ParticipanteModule {}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { ConflictException, Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { RegistrarParticipanteDto } from '../evento-participante/evento-participante/dto/registrarParticipanteDto.dto';
|
||||
import { Participante } from './participante.entity';
|
||||
|
||||
@Injectable()
|
||||
export class ParticipanteService {
|
||||
constructor(
|
||||
@InjectRepository(Participante)
|
||||
private participanteRepository: Repository<Participante>,
|
||||
) {}
|
||||
|
||||
async participanteExiste(correo: string): Promise<Participante> {
|
||||
/* const participante = await this.participanteRepository.findOne({
|
||||
where: { correo: correo },
|
||||
});
|
||||
return participante !== undefined; */
|
||||
return this.participanteRepository.findOne({ where: { correo } });
|
||||
}
|
||||
|
||||
async registrarParticipante(registrarParticipanteDto: RegistrarParticipanteDto) {
|
||||
return this.participanteExiste(registrarParticipanteDto.correo).then(
|
||||
(participante) => {
|
||||
if (participante) {
|
||||
throw new ConflictException('Este usuario ya está registrado');
|
||||
}
|
||||
return this.participanteRepository.save(
|
||||
this.participanteRepository.create(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user