mejra código carrera programa

This commit is contained in:
2022-06-13 05:47:21 -05:00
parent b5cc15b3d4
commit f29488f744
4 changed files with 8 additions and 9 deletions
@@ -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')
@@ -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))
@@ -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,