carrera-programa input output dto

This commit is contained in:
xXpuma99Xx
2022-06-13 23:28:47 -05:00
parent cfecb31d5d
commit a1be0e5907
13 changed files with 51 additions and 19 deletions
@@ -1,9 +1,11 @@
import { Body, Controller, Delete, Get, Post, Query } from '@nestjs/common';
import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
import { Serealize } from '../interceptors/serialize.interceptor';
import { CarreraProgramaService } from './carrera-programa.service';
import { IdInstitucionDto } from '../dto/id-institucion.dto';
import { CarreraProgramaCreateDto } from './dto/carrera-programa-create.dto';
import { CarreraProgramaDeleteDto } from './dto/carrera-programa-delete.dto';
import { CreateCarreraProgramaDto } from './dto/input/create.dto';
import { DeleteCarreraProgramaDto } from './dto/input/delete.dto';
import { CarreraProgramaOutputDto } from './dto/output/carrera-programa.dto';
@Controller('carrera-programa')
@ApiTags('carrera-programa')
@@ -21,7 +23,7 @@ export class CarreraProgramaController {
ejemplo: { value: { id_institucion_carrera: 36, id_programa: 1 } },
},
})
create(@Body() body: CarreraProgramaCreateDto) {
create(@Body() body: CreateCarreraProgramaDto) {
return this.carreraProgramaService.create(
body.id_institucion_carrera,
body.id_programa,
@@ -37,10 +39,11 @@ export class CarreraProgramaController {
description: 'Es obligatorio mandar la variable id_carrera_programa.',
examples: { ejemplo: { value: { id_carrera_programa: 1 } } },
})
delete(@Body() body: CarreraProgramaDeleteDto) {
delete(@Body() body: DeleteCarreraProgramaDto) {
return this.carreraProgramaService.delete(body.id_carrera_programa);
}
@Serealize(CarreraProgramaOutputDto)
@Get()
@ApiOperation({
description:
@@ -69,7 +69,7 @@ export class CarreraProgramaService {
},
},
where: {
carrera: { institucion },
institucionCarrera: { institucion },
},
}),
);
@@ -1,6 +1,6 @@
import { IsInt } from 'class-validator';
export class CarreraProgramaCreateDto {
export class CreateCarreraProgramaDto {
@IsInt()
id_institucion_carrera: number;
@@ -1,6 +1,6 @@
import { IsInt } from 'class-validator';
export class CarreraProgramaDeleteDto {
export class DeleteCarreraProgramaDto {
@IsInt()
id_carrera_programa: number;
}
@@ -0,0 +1,16 @@
import { Expose, Type } from 'class-transformer';
import { ProgramaOutputDto } from '../../../institucion-programa/dto/output/programa.dto';
import { InstitucionCarreaOutputDto } from '../../../institucion-carrera/dto/output/institucion-carrera.dto';
export class CarreraProgramaOutputDto {
@Expose()
id_carrera_programa;
@Expose()
@Type(() => InstitucionCarreaOutputDto)
institucionCarrera;
@Expose()
@Type(() => ProgramaOutputDto)
programa;
}