2022-05-31 15:07:57 -05:00
|
|
|
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
|
|
|
|
import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
2022-05-31 14:26:57 -05:00
|
|
|
import { InstitucionProgramaService } from './institucion-programa.service';
|
2022-05-31 15:07:57 -05:00
|
|
|
import { IdInstitucionDto } from 'src/dto/id-institucion.dto';
|
2022-05-31 14:26:57 -05:00
|
|
|
import { ProgramaCreateDto } from '../institucion-programa/dto/programa-create.dto';
|
2022-05-09 16:49:41 -05:00
|
|
|
|
|
|
|
|
@Controller('institucion-programa')
|
2022-05-31 14:26:57 -05:00
|
|
|
@ApiTags('institucion-programa')
|
|
|
|
|
export class InstitucionProgramaController {
|
|
|
|
|
constructor(private institucionProgramaService: InstitucionProgramaService) {}
|
|
|
|
|
|
|
|
|
|
@Post()
|
|
|
|
|
@ApiOperation({ description: 'Endpoint que crea un programa nuevo.' })
|
|
|
|
|
@ApiBody({
|
|
|
|
|
description: 'Es obligatorio mandar la varible programa.',
|
|
|
|
|
examples: { ejemplo: { value: { programa: '' } } },
|
|
|
|
|
})
|
|
|
|
|
create(@Body() body: ProgramaCreateDto) {
|
|
|
|
|
return this.institucionProgramaService.create(body.programa);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get()
|
|
|
|
|
@ApiOperation({ description: 'Endpoint que retorna todos los programas.' })
|
|
|
|
|
get() {
|
2022-05-31 15:07:57 -05:00
|
|
|
return this.institucionProgramaService.findAllProgramas();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get('programas')
|
|
|
|
|
@ApiOperation({
|
|
|
|
|
description: 'Endpoint que retorna todos los programas de una institución.',
|
|
|
|
|
})
|
|
|
|
|
@ApiQuery({
|
|
|
|
|
description: 'Id de la institución.',
|
|
|
|
|
name: 'id_institucion',
|
|
|
|
|
type: 'string',
|
|
|
|
|
})
|
|
|
|
|
programas(@Query() query: IdInstitucionDto) {
|
|
|
|
|
return this.institucionProgramaService.findAllByIdInstitucion(
|
|
|
|
|
parseInt(query.id_institucion),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get('programas-mostrar')
|
|
|
|
|
@ApiOperation({
|
|
|
|
|
description:
|
|
|
|
|
'Endpoint que retorna todos los programas de una institución que tengan el campo mostrar en true.',
|
|
|
|
|
})
|
|
|
|
|
@ApiQuery({
|
|
|
|
|
description: 'Id de la institución.',
|
|
|
|
|
name: 'id_institucion',
|
|
|
|
|
type: 'string',
|
|
|
|
|
})
|
|
|
|
|
programasMostrar(@Query() query: IdInstitucionDto) {
|
|
|
|
|
return this.institucionProgramaService.findAllByIdInstitucionMostrar(
|
|
|
|
|
parseInt(query.id_institucion),
|
|
|
|
|
);
|
2022-05-31 14:26:57 -05:00
|
|
|
}
|
|
|
|
|
}
|