From f29488f744381cbf437804c4f59887fa6d862d94 Mon Sep 17 00:00:00 2001 From: lemuel Date: Mon, 13 Jun 2022 05:47:21 -0500 Subject: [PATCH] =?UTF-8?q?mejra=20c=C3=B3digo=20carrera=20programa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/carrera-programa/carrera-programa.controller.ts | 2 +- src/carrera-programa/carrera-programa.service.ts | 11 +++++------ .../entity/carrera-programa.entity.ts | 2 +- .../entity/institucion-carrera.entity.ts | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/carrera-programa/carrera-programa.controller.ts b/src/carrera-programa/carrera-programa.controller.ts index 86a7535..8c2161c 100644 --- a/src/carrera-programa/carrera-programa.controller.ts +++ b/src/carrera-programa/carrera-programa.controller.ts @@ -1,9 +1,9 @@ import { Body, Controller, Delete, Get, Post, Query } from '@nestjs/common'; import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger'; 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 { IdInstitucionDto } from '../dto/id-institucion.dto'; @Controller('carrera-programa') @ApiTags('carrera-programa') diff --git a/src/carrera-programa/carrera-programa.service.ts b/src/carrera-programa/carrera-programa.service.ts index 7d991fd..fe39ab9 100644 --- a/src/carrera-programa/carrera-programa.service.ts +++ b/src/carrera-programa/carrera-programa.service.ts @@ -21,7 +21,7 @@ export class CarreraProgramaService { ) {} async create(id_institucion_carrera: number, id_programa: number) { - const carrera = await this.institucionCarreraService.findById( + const institucionCarrera = await this.institucionCarreraService.findById( id_institucion_carrera, ); const programa = await this.institucionProgramaService.findProgramaById( @@ -29,15 +29,15 @@ export class CarreraProgramaService { ); return this.repository - .findOne({ carrera, programa }) + .findOne({ institucionCarrera, programa }) .then((existeCarretaPrograma) => { if (existeCarretaPrograma) throw new ConflictException( - 'Ya existe una carrera programa con este nombre, intente con uno diferente.', + 'Ya existe una relación entre esta carrera y este programa, intente con uno diferente.', ); return this.repository.save( this.repository.create({ - carrera, + institucionCarrera, programa, }), ); @@ -63,7 +63,7 @@ export class CarreraProgramaService { join: { alias: 'cp', innerJoinAndSelect: { - ic: 'cp.carrera', + ic: 'cp.institucionCarrera', c: 'ic.carrera', i: 'ic.institucion', }, @@ -75,7 +75,6 @@ export class CarreraProgramaService { ); } - //No estoy seguro de que esto este bien :) delete(id_carrera_programa: number) { return this.findById(id_carrera_programa) .then((carreraPrograma) => this.repository.delete(carreraPrograma)) diff --git a/src/carrera-programa/entity/carrera-programa.entity.ts b/src/carrera-programa/entity/carrera-programa.entity.ts index 5c5a87a..8dd109d 100644 --- a/src/carrera-programa/entity/carrera-programa.entity.ts +++ b/src/carrera-programa/entity/carrera-programa.entity.ts @@ -13,7 +13,7 @@ export class CarreraPrograma { { eager: true }, ) @JoinColumn({ name: 'id_institucion_carrera' }) - carrera: InstitucionCarrera; + institucionCarrera: InstitucionCarrera; @ManyToOne(() => Programa, (programa) => programa.carrerasPrograma, { eager: true, diff --git a/src/institucion-carrera/entity/institucion-carrera.entity.ts b/src/institucion-carrera/entity/institucion-carrera.entity.ts index 668ee33..df1134d 100644 --- a/src/institucion-carrera/entity/institucion-carrera.entity.ts +++ b/src/institucion-carrera/entity/institucion-carrera.entity.ts @@ -31,7 +31,7 @@ export class InstitucionCarrera { @OneToMany( () => CarreraPrograma, - (carreraPrograma) => carreraPrograma.carrera, + (carreraPrograma) => carreraPrograma.institucionCarrera, ) programas: CarreraPrograma[];