Files
formularios_api/src/participante/participante.controller.ts
T

43 lines
1.6 KiB
TypeScript

import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from '@nestjs/common';
import { Participante } from './participante.entity';
import { ParticipanteService } from './participante.service';
import { CreateParticipanteDto } from './dto/create-participante.dto';
import { UpdateParticipanteDto } from './dto/update.participante.dto';
import { ParticipanteApiDocumentation } from './participante.documentation';
@ParticipanteApiDocumentation.ApiController
@Controller('participante')
export class ParticipanteController {
constructor(private participanteService: ParticipanteService) {}
@ParticipanteApiDocumentation.ApiGetAll
@Get()
getParticipantes(): Promise<Participante[]> {
return this.participanteService.getParticipantes();
}
@ParticipanteApiDocumentation.ApiGetOne
@Get(':id')
getParticipante(@Param('id', ParseIntPipe) id: number) {
return this.participanteService.getParticipante(id);
}
@ParticipanteApiDocumentation.ApiCreate
@Post()
createParticipante(@Body() newParticipante: CreateParticipanteDto) {
return this.participanteService.createParticipante(newParticipante);
}
@ParticipanteApiDocumentation.ApiRemove
@Delete(':id')
deleteParticipante(@Param('id', ParseIntPipe) id: number) {
return this.participanteService.deleteParticipante(id);
}
@ParticipanteApiDocumentation.ApiUpdate
@Patch(':id')
updateParticipante(@Param('id', ParseIntPipe) id: number, @Body() participante: UpdateParticipanteDto) {
return this.participanteService.updateParticipante(id, participante);
}
}