Subir carpetas con las nuevas tablas

This commit is contained in:
santiago
2025-04-01 15:07:11 -06:00
parent 1520825ad3
commit fbd753d27e
45 changed files with 1452 additions and 0 deletions
@@ -0,0 +1,5 @@
export class CreateParticipanteEventoDto {
id_participante: number
id_evento: number
}
@@ -0,0 +1,6 @@
export class UpdateParticipanteEventoDto {
id_participante?: number
id_evento?: number
fecha_inscripcion?: Date
estatus?: boolean
}
@@ -0,0 +1,36 @@
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from '@nestjs/common';
import { ParticipanteEventoService } from './participante_evento.service';
import { ParticipanteEvento } from './participante_evento.entity';
import { CreateParticipanteEventoDto } from './dto/create-participante_evento.dto';
import { UpdateParticipanteEventoDto } from './dto/update.participante_evento.dto';
@Controller('participante-evento')
export class ParticipanteEventoController {
constructor(private participanteEventoService: ParticipanteEventoService) {}
@Get()
getParticipantesEvento(): Promise<ParticipanteEvento[]> {
return this.participanteEventoService.getParticipantesEvento()
}
@Get(':id')
getParticipanteEvento(@Param('id', ParseIntPipe) id: number) {
return this.participanteEventoService.getParticipanteEvento(id)
}
@Post()
createParticipanteEvento(@Body() newParticipanteEvento: CreateParticipanteEventoDto) {
return this.participanteEventoService.createParticipanteEvento(newParticipanteEvento)
}
@Delete(':id')
deleteParticipanteEvento(@Param('id', ParseIntPipe) id: number) {
return this.participanteEventoService.deleteParticipanteEvento(id)
}
@Patch(':id')
updateParticipanteEvento(@Param('id', ParseIntPipe) id_participante: number, id_evento: number, @Body() participanteEvento: UpdateParticipanteEventoDto) {
return this.participanteEventoService.updateParticipanteEvento(id_participante, id_evento, participanteEvento)
}
}
@@ -0,0 +1,33 @@
import { Evento } from "src/evento/evento.entity";
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
@Entity()
export class ParticipanteEvento {
@PrimaryColumn()
id_participante: number
@PrimaryColumn()
id_evento: number
@Column()
fecha_inscripcion: Date
@Column()
estatus: boolean
/*
@OneToOne(() => Qr, (qr) => qr.participanteEvento)
qr: Qr;
@ManyToOne(() => Participante, (participante) => participante.eventos)
@JoinColumn({ name: "id_participante" })
participante: Participante;
@ManyToOne(() => Evento, (evento) => evento.participantes)
@JoinColumn({ name: "id_evento" })
evento: Evento;
*/
@ManyToOne(() => Evento, (evento) => evento.participantes)
@JoinColumn({ name: "id_evento" })
evento: Evento;
}
@@ -0,0 +1,13 @@
import { Module } from '@nestjs/common';
import { ParticipanteEventoService } from './participante_evento.service';
import { ParticipanteEventoController } from './participante_evento.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ParticipanteEvento } from './participante_evento.entity';
import { Evento } from 'src/evento/evento.entity';
@Module({
imports: [TypeOrmModule.forFeature([ParticipanteEvento]), Evento],
controllers: [ParticipanteEventoController],
providers: [ParticipanteEventoService]
})
export class ParticipanteEventoModule {}
@@ -0,0 +1,77 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { ParticipanteEvento } from './participante_evento.entity';
import { Repository } from 'typeorm';
import { CreateParticipanteEventoDto } from './dto/create-participante_evento.dto';
import { UpdateParticipanteEventoDto } from './dto/update.participante_evento.dto';
@Injectable()
export class ParticipanteEventoService {
constructor(
@InjectRepository(ParticipanteEvento) private participanteEventoRepository: Repository<ParticipanteEvento>
) {}
async createParticipanteEvento(participanteEvento: CreateParticipanteEventoDto) {
const participante_eventoFound = await this.participanteEventoRepository.findOne({
where: {
id_participante: participanteEvento.id_participante,
id_evento: participanteEvento.id_evento
}
})
if (participante_eventoFound) {
return new HttpException('Participante already exists in this event', HttpStatus.CONFLICT)
}
return this.participanteEventoRepository.save(participanteEvento)
}
getParticipantesEvento() {
return this.participanteEventoRepository.find({
relations: ['evento']
})
}
async getParticipanteEvento(id_participante: number) {
const participante_eventoFound = await this.participanteEventoRepository.findOne({
where: {
id_participante
},
relations: ['evento']
})
if (!participante_eventoFound) {
return new HttpException('Participante not found', HttpStatus.NOT_FOUND);
}
return participante_eventoFound
}
async deleteParticipanteEvento(id_participante: number) {
const result = await this.participanteEventoRepository.delete({ id_participante })
if (result.affected === 0) {
return new HttpException('Participante not found', HttpStatus.NOT_FOUND);
}
return result
}
async updateParticipanteEvento(id_participante: number, id_evento: number, participante_evento: UpdateParticipanteEventoDto) {
const participante_eventoFound = await this.participanteEventoRepository.findOne({
where: {
id_participante,
id_evento
}
})
if (!participante_eventoFound) {
return new HttpException('Participante not found', HttpStatus.NOT_FOUND)
}
return this.participanteEventoRepository.save(participante_evento)
}
}