institucion programa input output dto
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { IsString } from 'class-validator';
|
||||
|
||||
export class ProgramaCreateDto {
|
||||
export class CreateProgramaDto {
|
||||
@IsString()
|
||||
programa: string;
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { IsBoolean, IsInt } from 'class-validator';
|
||||
|
||||
export class ProgramaUpdateDto {
|
||||
export class UpdateProgramaDto {
|
||||
@IsInt()
|
||||
id_institucion_programa: number;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { ProgramaOutputDto } from './programa.dto';
|
||||
|
||||
export class InstitucionProgramaMinOutputDto {
|
||||
@Expose()
|
||||
id_institucion_programa;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ProgramaOutputDto)
|
||||
programa;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { ProgramaOutputDto } from './programa.dto';
|
||||
|
||||
export class InstitucionProgramaOutputDto {
|
||||
@Expose()
|
||||
id_institucion_programa;
|
||||
|
||||
@Expose()
|
||||
mostrar;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ProgramaOutputDto)
|
||||
programa;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Expose } from 'class-transformer';
|
||||
|
||||
export class ProgramaOutputDto {
|
||||
@Expose()
|
||||
id_programa;
|
||||
|
||||
@Expose()
|
||||
programa;
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||
import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
||||
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
import { InstitucionProgramaService } from './institucion-programa.service';
|
||||
import { IdInstitucionDto } from 'src/dto/id-institucion.dto';
|
||||
import { ProgramaCreateDto } from '../institucion-programa/dto/programa-create.dto';
|
||||
import { ProgramaUpdateDto } from '../institucion-programa/dto/programa-update.dto';
|
||||
import { CreateProgramaDto } from './dto/input/create.dto';
|
||||
import { UpdateProgramaDto } from './dto/input/update.dto';
|
||||
import { InstitucionProgramaOutputDto } from './dto/output/institucion-programa.dto';
|
||||
import { InstitucionProgramaMinOutputDto } from './dto/output/institucion-programa-min.dto';
|
||||
import { ProgramaOutputDto } from './dto/output/programa.dto';
|
||||
|
||||
@Controller('institucion-programa')
|
||||
@ApiTags('institucion-programa')
|
||||
@@ -16,16 +20,18 @@ export class InstitucionProgramaController {
|
||||
description: 'Es obligatorio mandar la varible programa.',
|
||||
examples: { ejemplo: { value: { programa: '' } } },
|
||||
})
|
||||
create(@Body() body: ProgramaCreateDto) {
|
||||
create(@Body() body: CreateProgramaDto) {
|
||||
return this.institucionProgramaService.create(body.programa);
|
||||
}
|
||||
|
||||
@Serealize(ProgramaOutputDto)
|
||||
@Get()
|
||||
@ApiOperation({ description: 'Endpoint que retorna todos los programas.' })
|
||||
get() {
|
||||
return this.institucionProgramaService.findAllProgramas();
|
||||
}
|
||||
|
||||
@Serealize(InstitucionProgramaOutputDto)
|
||||
@Get('programas')
|
||||
@ApiOperation({
|
||||
description: 'Endpoint que retorna todos los programas de una institución.',
|
||||
@@ -41,6 +47,7 @@ export class InstitucionProgramaController {
|
||||
);
|
||||
}
|
||||
|
||||
@Serealize(InstitucionProgramaMinOutputDto)
|
||||
@Get('programas-mostrar')
|
||||
@ApiOperation({
|
||||
description:
|
||||
@@ -68,7 +75,7 @@ export class InstitucionProgramaController {
|
||||
ejemplo: { value: { id_institucion_programa: 130, mostrar: true } },
|
||||
},
|
||||
})
|
||||
update(@Body() body: ProgramaUpdateDto) {
|
||||
update(@Body() body: UpdateProgramaDto) {
|
||||
return this.institucionProgramaService.update(body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Not, Repository } from 'typeorm';
|
||||
import { InstitucionPrograma } from './entity/institucion-programa.entity';
|
||||
import { Programa } from './entity/programa.entity';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
@@ -76,7 +76,10 @@ export class InstitucionProgramaService {
|
||||
return this.institucionService
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.institucionProgramaRepository.find({ institucion }),
|
||||
this.institucionProgramaRepository.find({
|
||||
institucion,
|
||||
programa: { id_programa: Not(1) },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -84,7 +87,11 @@ export class InstitucionProgramaService {
|
||||
return this.institucionService
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.institucionProgramaRepository.find({ institucion, mostrar: true }),
|
||||
this.institucionProgramaRepository.find({
|
||||
institucion,
|
||||
mostrar: true,
|
||||
programa: { id_programa: Not(1) },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user