db corregida
This commit is contained in:
@@ -4,12 +4,14 @@ import { CarreraProgramaController } from './carrera-programa.controller';
|
||||
import { CarreraProgramaService } from './carrera-programa.service';
|
||||
import { CarreraPrograma } from './entity/carrera-programa.entity';
|
||||
import { CarreraModule } from '../carrera/carrera.module';
|
||||
import { InstitucionCarreraModule } from '../institucion-carrera/institucion-carrera.module';
|
||||
import { ProgramaModule } from '../programa/programa.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([CarreraPrograma]),
|
||||
CarreraModule,
|
||||
InstitucionCarreraModule,
|
||||
TypeOrmModule.forFeature([CarreraPrograma]),
|
||||
ProgramaModule,
|
||||
],
|
||||
controllers: [CarreraProgramaController],
|
||||
|
||||
@@ -7,6 +7,7 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { CarreraPrograma } from './entity/carrera-programa.entity';
|
||||
import { CarreraService } from '../carrera/carrera.service';
|
||||
import { InstitucionCarreraService } from '../institucion-carrera/institucion-carrera.service';
|
||||
import { ProgramaService } from '../programa/programa.service';
|
||||
|
||||
@Injectable()
|
||||
@@ -15,11 +16,14 @@ export class CarreraProgramaService {
|
||||
@InjectRepository(CarreraPrograma)
|
||||
private repository: Repository<CarreraPrograma>,
|
||||
private carreraService: CarreraService,
|
||||
private institucionCarreraService: InstitucionCarreraService,
|
||||
private programaService: ProgramaService,
|
||||
) {}
|
||||
|
||||
async create(id_carrera: number, id_programa: number) {
|
||||
const carrera = await this.carreraService.findById(id_carrera);
|
||||
async create(id_institucion_carrera: number, id_programa: number) {
|
||||
const carrera = await this.institucionCarreraService.findById(
|
||||
id_institucion_carrera,
|
||||
);
|
||||
const programa = await this.programaService.findById(id_programa);
|
||||
const nuevoCarreraPrograma = this.repository.create({
|
||||
carrera,
|
||||
@@ -54,9 +58,8 @@ export class CarreraProgramaService {
|
||||
|
||||
//No estoy seguro de que esto este bien :)
|
||||
delete(id_carrera_programa: number) {
|
||||
this.findById(id_carrera_programa)
|
||||
.then(() => {
|
||||
return this.repository.delete(id_carrera_programa)
|
||||
})
|
||||
this.findById(id_carrera_programa).then(() => {
|
||||
return this.repository.delete(id_carrera_programa);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Entity, PrimaryGeneratedColumn, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { Carrera } from '../../carrera/entity/carrera.entity';
|
||||
import { InstitucionCarrera } from '../../institucion-carrera/entity/institucion-carrera.entity';
|
||||
import { Programa } from '../../programa/entity/programa.entity';
|
||||
|
||||
@Entity()
|
||||
@@ -7,9 +7,12 @@ export class CarreraPrograma {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_carrera_programa: number;
|
||||
|
||||
@ManyToOne(() => Carrera, (carrera) => carrera.carreraProgramas)
|
||||
@JoinColumn({ name: 'id_carrera' })
|
||||
carrera: Carrera;
|
||||
@ManyToOne(
|
||||
() => InstitucionCarrera,
|
||||
(institucionCarrera) => institucionCarrera.programas,
|
||||
)
|
||||
@JoinColumn({ name: 'id_institucion_carrera' })
|
||||
carrera: InstitucionCarrera;
|
||||
|
||||
@ManyToOne(() => Programa, (programa) => programa.carrerasPrograma)
|
||||
@JoinColumn({ name: 'id_programa' })
|
||||
|
||||
Reference in New Issue
Block a user