diff --git a/src/institucion-carrera/dto/output/institucion-carrera.dto.ts b/src/institucion-carrera/dto/output/institucion-carrera.dto.ts index 0369aea..92bb740 100644 --- a/src/institucion-carrera/dto/output/institucion-carrera.dto.ts +++ b/src/institucion-carrera/dto/output/institucion-carrera.dto.ts @@ -6,9 +6,6 @@ export class InstitucionCarreaOutputDto { @Expose() id_institucion_carrera; - @Expose() - clave_alt; - @Expose() @Type(() => CarreaOutputDto) carrera; diff --git a/src/institucion-carrera/institucion-carrera.service.ts b/src/institucion-carrera/institucion-carrera.service.ts index 5880c80..b80172b 100644 --- a/src/institucion-carrera/institucion-carrera.service.ts +++ b/src/institucion-carrera/institucion-carrera.service.ts @@ -1,46 +1,30 @@ import { Injectable, NotFoundException } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; -import { Repository } from 'typeorm'; +import { Not, Repository } from 'typeorm'; import { Carrera } from '../institucion-carrera/entity/carrera.entity'; import { Institucion } from '../institucion/entity/institucion.entity'; import { InstitucionCarrera } from './entity/institucion-carrera.entity'; -import { InstitucionService } from '../institucion/institucion.service'; import { Nivel } from './entity/nivel.entity'; +import { InstitucionService } from '../institucion/institucion.service'; @Injectable() export class InstitucionCarreraService { constructor( + @InjectRepository(Carrera) private carreraRepository: Repository, @InjectRepository(InstitucionCarrera) private institucionCarreraRepository: Repository, - @InjectRepository(Carrera) private carreraRepository: Repository, @InjectRepository(Carrera) private nivelRepository: Repository, private institucionService: InstitucionService, ) {} - findAllCarreras() { - return this.carreraRepository.find(); - } - - findCarreraByIdCarrera(id_carrera: number) { - return this.carreraRepository.findOne({ id_carrera }).then((carrera) => { - if (!carrera) throw new NotFoundException('No existe esta carrera.'); - return carrera; - }); - } - - findCarreraByCarrera(carrera: string, validarNoExiste = true) { - return this.carreraRepository.findOne({ carrera }).then((carrera) => { - if (validarNoExiste && !carrera) - throw new NotFoundException('No existe esta carrera.'); - return carrera; - }); - } - findAllByIdInstitucion(id_institucion: number) { return this.institucionService .findById(id_institucion) .then((institucion) => - this.institucionCarreraRepository.find({ institucion }), + this.institucionCarreraRepository.find({ + carrera: { id_carrera: Not(1) }, + institucion, + }), ); } @@ -49,7 +33,7 @@ export class InstitucionCarreraService { .findOne({ id_institucion_carrera }) .then((institucionCarrera) => { if (!institucionCarrera) - throw new NotFoundException('No existe esta institución carrera.'); + throw new NotFoundException('No existe este id institución carrera.'); return institucionCarrera; }); } @@ -69,4 +53,19 @@ export class InstitucionCarreraService { return this.institucionCarreraRepository.findOne({ carrera, institucion }); } + + findCarreraByIdCarrera(id_carrera: number) { + return this.carreraRepository.findOne({ id_carrera }).then((carrera) => { + if (!carrera) throw new NotFoundException('No existe esta carrera.'); + return carrera; + }); + } + + findCarreraByCarrera(carrera: string, validarNoExiste = true) { + return this.carreraRepository.findOne({ carrera }).then((carrera) => { + if (validarNoExiste && !carrera) + throw new NotFoundException('No existe esta carrera.'); + return carrera; + }); + } } diff --git a/src/institucion-dia/institucion-dia.service.ts b/src/institucion-dia/institucion-dia.service.ts index a632d45..c1154a2 100644 --- a/src/institucion-dia/institucion-dia.service.ts +++ b/src/institucion-dia/institucion-dia.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@nestjs/common'; +import { Injectable, NotFoundException } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { Institucion } from '../institucion/entity/institucion.entity'; @@ -23,7 +23,7 @@ export class InstitucionDiaService { .findOne({ id_institucion_dia }) .then((institucionDia) => { if (!institucionDia) - throw new Error('No existe este id día institución.'); + throw new NotFoundException('No existe este id institución día.'); return institucionDia; }); }