255 lines
7.9 KiB
TypeScript
255 lines
7.9 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Param,
|
|
ParseIntPipe,
|
|
Patch,
|
|
Post,
|
|
} from '@nestjs/common';
|
|
import { ParticipanteEventoService } from './participante_evento.service';
|
|
import { ParticipanteEvento } from './entities/participante_evento.entity';
|
|
import { CreateParticipanteEventoDto } from './dto/create-participante_evento.dto';
|
|
import { UpdateParticipanteEventoDto } from './dto/update.participante_evento.dto';
|
|
import { ApiTags, ApiOperation, ApiParam, ApiResponse } from '@nestjs/swagger';
|
|
|
|
@ApiTags('Participantes-Eventos')
|
|
@Controller('participante-evento')
|
|
export class ParticipanteEventoController {
|
|
constructor(private participanteEventoService: ParticipanteEventoService) {}
|
|
|
|
@ApiOperation({ summary: 'Obtener participantes por evento' })
|
|
@ApiParam({ name: 'id_cuestionario', description: 'ID del evento', type: 'number' })
|
|
@ApiResponse({
|
|
status: 200,
|
|
description: 'Lista de participantes que están registrados en el evento',
|
|
schema: {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
id_participante_evento: { type: 'number' },
|
|
id_participante: { type: 'number' },
|
|
id_evento: { type: 'number' },
|
|
fecha_inscripcion: { type: 'string', format: 'date-time' },
|
|
estatus: { type: 'boolean' },
|
|
fecha_asistencia: {
|
|
type: 'string',
|
|
format: 'date-time',
|
|
nullable: true,
|
|
},
|
|
participante: {
|
|
type: 'object',
|
|
properties: {
|
|
id_participante: { type: 'number' },
|
|
correo: { type: 'string' },
|
|
id_tipo_user: { type: 'number' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
@ApiResponse({ status: 404, description: 'Evento no encontrado' })
|
|
@Get('evento/:id_cuestionario')
|
|
getParticipantesPorEvento(
|
|
@Param('id_cuestionario', ParseIntPipe) id_cuestionario: number,
|
|
) {
|
|
return this.participanteEventoService.getParticipantesPorCuestionario(
|
|
id_cuestionario,
|
|
);
|
|
}
|
|
|
|
@ApiOperation({ summary: 'Obtener eventos por participante' })
|
|
@ApiParam({
|
|
name: 'idParticipante',
|
|
description: 'ID del participante',
|
|
type: 'number',
|
|
})
|
|
@ApiResponse({
|
|
status: 200,
|
|
description: 'Lista de eventos en los que está registrado el participante',
|
|
schema: {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
id_participante_evento: { type: 'number' },
|
|
id_participante: { type: 'number' },
|
|
id_evento: { type: 'number' },
|
|
fecha_inscripcion: { type: 'string', format: 'date-time' },
|
|
estatus: { type: 'boolean' },
|
|
fecha_asistencia: {
|
|
type: 'string',
|
|
format: 'date-time',
|
|
nullable: true,
|
|
},
|
|
evento: {
|
|
type: 'object',
|
|
properties: {
|
|
id_evento: { type: 'number' },
|
|
nombre_evento: { type: 'string' },
|
|
tipo_evento: { type: 'string' },
|
|
fecha_inicio: { type: 'string', format: 'date-time' },
|
|
fecha_fin: { type: 'string', format: 'date-time' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
@ApiResponse({ status: 404, description: 'Participante no encontrado' })
|
|
@Get('participante/:idParticipante')
|
|
getEventosPorParticipante(
|
|
@Param('idParticipante', ParseIntPipe) idParticipante: number,
|
|
) {
|
|
return this.participanteEventoService.getEventosPorParticipante(
|
|
idParticipante,
|
|
);
|
|
}
|
|
|
|
@ApiOperation({
|
|
summary: 'Obtener un registro específico por IDs de participante y evento',
|
|
})
|
|
@ApiParam({
|
|
name: 'idParticipante',
|
|
description: 'ID del participante',
|
|
type: 'number',
|
|
})
|
|
@ApiParam({ name: 'idEvento', description: 'ID del evento', type: 'number' })
|
|
@ApiResponse({
|
|
status: 200,
|
|
description: 'Registro participante-evento obtenido correctamente',
|
|
})
|
|
@ApiResponse({ status: 404, description: 'Registro no encontrado' })
|
|
@Get(':idParticipante/:idEvento')
|
|
getParticipanteEventoEspecifico(
|
|
@Param('idParticipante', ParseIntPipe) idParticipante: number,
|
|
@Param('idEvento', ParseIntPipe) idEvento: number,
|
|
) {
|
|
return this.participanteEventoService.getParticipanteEventoEspecifico(
|
|
idParticipante,
|
|
idEvento,
|
|
);
|
|
}
|
|
|
|
@ApiOperation({ summary: 'Obtener un registro participante-evento por ID' })
|
|
@ApiParam({ name: 'id', description: 'ID del participante', type: 'number' })
|
|
@ApiResponse({
|
|
status: 200,
|
|
description: 'Registro participante-evento obtenido correctamente',
|
|
})
|
|
@ApiResponse({ status: 404, description: 'Registro no encontrado' })
|
|
@Get(':id')
|
|
getParticipanteEvento(@Param('id', ParseIntPipe) id: number) {
|
|
return this.participanteEventoService.getParticipanteEvento(id);
|
|
}
|
|
|
|
@ApiOperation({
|
|
summary: 'Obtener todos los registros de participante-evento',
|
|
})
|
|
@ApiResponse({
|
|
status: 200,
|
|
description:
|
|
'Lista de todos los registros participante-evento con sus relaciones',
|
|
schema: {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
id_participante_evento: { type: 'number' },
|
|
id_participante: { type: 'number' },
|
|
id_evento: { type: 'number' },
|
|
fecha_inscripcion: { type: 'string', format: 'date-time' },
|
|
estatus: { type: 'boolean' },
|
|
fecha_asistencia: {
|
|
type: 'string',
|
|
format: 'date-time',
|
|
nullable: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
@Get()
|
|
getParticipantesEvento(): Promise<ParticipanteEvento[]> {
|
|
return this.participanteEventoService.getParticipantesEvento();
|
|
}
|
|
|
|
@ApiOperation({ summary: 'Registrar un participante en un evento' })
|
|
@ApiResponse({
|
|
status: 201,
|
|
description: 'Participante registrado en el evento correctamente',
|
|
})
|
|
@ApiResponse({
|
|
status: 409,
|
|
description: 'El participante ya está registrado en este evento',
|
|
})
|
|
@Post()
|
|
createParticipanteEvento(
|
|
@Body() newParticipanteEvento: CreateParticipanteEventoDto,
|
|
) {
|
|
return this.participanteEventoService.createParticipanteEvento(
|
|
newParticipanteEvento,
|
|
);
|
|
}
|
|
|
|
@ApiOperation({
|
|
summary: 'Registrar asistencia de un participante a un evento',
|
|
})
|
|
@ApiParam({
|
|
name: 'idParticipante',
|
|
description: 'ID del participante',
|
|
type: 'number',
|
|
})
|
|
@ApiParam({ name: 'idEvento', description: 'ID del evento', type: 'number' })
|
|
@ApiResponse({
|
|
status: 200,
|
|
description: 'Asistencia registrada correctamente',
|
|
})
|
|
@ApiResponse({ status: 404, description: 'Registro no encontrado' })
|
|
@Post('asistencia/:idParticipante/:idEvento')
|
|
registrarAsistencia(
|
|
@Param('idParticipante', ParseIntPipe) idParticipante: number,
|
|
@Param('idEvento', ParseIntPipe) idEvento: number,
|
|
) {
|
|
return this.participanteEventoService.registrarAsistencia(
|
|
idParticipante,
|
|
idEvento,
|
|
);
|
|
}
|
|
|
|
@ApiOperation({ summary: 'Eliminar un registro participante-evento' })
|
|
@ApiParam({ name: 'id', description: 'ID del participante', type: 'number' })
|
|
@ApiResponse({
|
|
status: 200,
|
|
description: 'Registro eliminado correctamente',
|
|
})
|
|
@ApiResponse({ status: 404, description: 'Registro no encontrado' })
|
|
@Delete(':id')
|
|
deleteParticipanteEvento(@Param('id', ParseIntPipe) id: number) {
|
|
return this.participanteEventoService.deleteParticipanteEvento(id);
|
|
}
|
|
|
|
@ApiOperation({ summary: 'Actualizar un registro participante-evento' })
|
|
@ApiParam({ name: 'id', description: 'ID del participante', type: 'number' })
|
|
@ApiResponse({
|
|
status: 200,
|
|
description: 'Registro actualizado correctamente',
|
|
})
|
|
@ApiResponse({ status: 404, description: 'Registro no encontrado' })
|
|
@Patch(':id')
|
|
updateParticipanteEvento(
|
|
@Param('id', ParseIntPipe) id_participante: number,
|
|
id_evento: number,
|
|
@Body() participanteEvento: UpdateParticipanteEventoDto,
|
|
) {
|
|
return this.participanteEventoService.updateParticipanteEvento(
|
|
id_participante,
|
|
id_evento,
|
|
participanteEvento,
|
|
);
|
|
}
|
|
}
|