diff --git a/src/app.module.ts b/src/app.module.ts index e9cecce..a97948b 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -27,7 +27,7 @@ import { TipoEntradaModule } from './tipo-entrada/tipo-entrada.module'; import { EquipoTipoEntradaModule } from './equipo-tipo-entrada/equipo-tipo-entrada.module'; import { CarreraProgramaModule } from './carrera-programa/carrera-programa.module'; -import { Carrera } from './carrera/carrera.entity'; +import { Carrera } from './carrera/entity/carrera.entity'; import { CarreraPrograma } from './carrera-programa/carrera-programa.entity'; import { Carrito } from './carrito/entity/carrito.entity'; import { Dia } from './dia/dia.entity'; diff --git a/src/carrera-programa/carrera-programa.controller.ts b/src/carrera-programa/carrera-programa.controller.ts index cdea81c..8cc05f2 100644 --- a/src/carrera-programa/carrera-programa.controller.ts +++ b/src/carrera-programa/carrera-programa.controller.ts @@ -1,7 +1,9 @@ -import { Controller } from '@nestjs/common'; +import { Controller, Get, Post, Put } from '@nestjs/common'; import { CarreraProgramaService } from './carrera-programa.service'; @Controller('carrera-programa') export class CarreraProgramaController { constructor(private carreraProgramaService: CarreraProgramaService) {} + + } diff --git a/src/carrera-programa/carrera-programa.entity.ts b/src/carrera-programa/carrera-programa.entity.ts index f3d4608..ff84f69 100644 --- a/src/carrera-programa/carrera-programa.entity.ts +++ b/src/carrera-programa/carrera-programa.entity.ts @@ -1,11 +1,5 @@ -import { - Entity, - Column, - PrimaryGeneratedColumn, - ManyToOne, - JoinColumn, -} from 'typeorm'; -import { Carrera } from '../carrera/carrera.entity'; +import { Entity, PrimaryGeneratedColumn, ManyToOne, JoinColumn } from 'typeorm'; +import { Carrera } from '../carrera/entity/carrera.entity'; import { Programa } from '../programa/programa.entity'; @Entity() @@ -13,11 +7,11 @@ export class CarreraPrograma { @PrimaryGeneratedColumn() id_carrera_programa: number; - @ManyToOne(() => Programa, (programa) => programa.carrerasPrograma) - @JoinColumn({ name: 'id_programa' }) - programa: Programa; - @ManyToOne(() => Carrera, (carrera) => carrera.carreraProgramas) @JoinColumn({ name: 'id_carrera' }) carrera: Carrera; + + @ManyToOne(() => Programa, (programa) => programa.carrerasPrograma) + @JoinColumn({ name: 'id_programa' }) + programa: Programa; } diff --git a/src/carrera-programa/carrera-programa.module.ts b/src/carrera-programa/carrera-programa.module.ts index f34c76f..399a5c4 100644 --- a/src/carrera-programa/carrera-programa.module.ts +++ b/src/carrera-programa/carrera-programa.module.ts @@ -1,8 +1,8 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; import { CarreraProgramaController } from './carrera-programa.controller'; -import { CarreraPrograma } from './carrera-programa.entity'; import { CarreraProgramaService } from './carrera-programa.service'; +import { CarreraPrograma } from './carrera-programa.entity'; @Module({ imports: [TypeOrmModule.forFeature([CarreraPrograma])], diff --git a/src/carrera-programa/carrera-programa.service.ts b/src/carrera-programa/carrera-programa.service.ts index bca7c6d..5745308 100644 --- a/src/carrera-programa/carrera-programa.service.ts +++ b/src/carrera-programa/carrera-programa.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; -import { Repository } from 'typeorm'; import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; import { CarreraPrograma } from './carrera-programa.entity'; @Injectable() diff --git a/src/carrera/carrera.controller.ts b/src/carrera/carrera.controller.ts index 958d86a..61761b0 100644 --- a/src/carrera/carrera.controller.ts +++ b/src/carrera/carrera.controller.ts @@ -1,7 +1,13 @@ -import { Controller } from '@nestjs/common'; +import { Controller, Get } from '@nestjs/common'; import { CarreraService } from './carrera.service'; @Controller('carrera') export class CarreraController { constructor(private carreraService: CarreraService) {} + + @Get() + get() {} + + @Get("carreras") + carreras() {} } diff --git a/src/carrera/carrera.module.ts b/src/carrera/carrera.module.ts index beb0436..9108d26 100644 --- a/src/carrera/carrera.module.ts +++ b/src/carrera/carrera.module.ts @@ -1,8 +1,8 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; import { CarreraController } from './carrera.controller'; -import { Carrera } from './carrera.entity'; import { CarreraService } from './carrera.service'; +import { Carrera } from './entity/carrera.entity'; @Module({ imports: [TypeOrmModule.forFeature([Carrera])], diff --git a/src/carrera/carrera.service.ts b/src/carrera/carrera.service.ts index e3063ff..02628ae 100644 --- a/src/carrera/carrera.service.ts +++ b/src/carrera/carrera.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { Repository } from 'typeorm'; import { InjectRepository } from '@nestjs/typeorm'; -import { Carrera } from './carrera.entity'; +import { Repository } from 'typeorm'; +import { Carrera } from './entity/carrera.entity'; @Injectable() export class CarreraService { diff --git a/src/carrera/carrera.entity.ts b/src/carrera/entity/carrera.entity.ts similarity index 68% rename from src/carrera/carrera.entity.ts rename to src/carrera/entity/carrera.entity.ts index ee5892d..2ed9653 100644 --- a/src/carrera/carrera.entity.ts +++ b/src/carrera/entity/carrera.entity.ts @@ -1,33 +1,33 @@ import { - Entity, Column, - PrimaryGeneratedColumn, - OneToMany, - ManyToOne, + Entity, JoinColumn, + ManyToOne, + OneToMany, + PrimaryGeneratedColumn, } from 'typeorm'; -import { Institucion } from '../institucion/entity/institucion.entity'; -import { Usuario } from '../usuario/usuario.entity'; -import { CarreraPrograma } from '../carrera-programa/carrera-programa.entity'; +import { CarreraPrograma } from '../../carrera-programa/carrera-programa.entity'; +import { Institucion } from '../../institucion/entity/institucion.entity'; +import { Usuario } from '../../usuario/usuario.entity'; @Entity() export class Carrera { @PrimaryGeneratedColumn() id_carrera: number; - @Column() + @Column({ type: String, nullable: false, length: 150 }) carrera: string; @ManyToOne(() => Institucion, (institucion) => institucion.carreras) @JoinColumn({ name: 'id_institucion' }) institucion: Institucion; - @OneToMany(() => Usuario, (usuario) => usuario.carrera) - usuarios: Usuario[]; - @OneToMany( () => CarreraPrograma, (carreraPrograma) => carreraPrograma.carrera, ) carreraProgramas: CarreraPrograma[]; + + @OneToMany(() => Usuario, (usuario) => usuario.carrera) + usuarios: Usuario[]; } diff --git a/src/institucion/entity/institucion.entity.ts b/src/institucion/entity/institucion.entity.ts index 2f2226d..645fdb4 100644 --- a/src/institucion/entity/institucion.entity.ts +++ b/src/institucion/entity/institucion.entity.ts @@ -1,5 +1,5 @@ import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; -import { Carrera } from '../../carrera/carrera.entity'; +import { Carrera } from '../../carrera/entity/carrera.entity'; import { InstitucionDia } from '../../institucion-dia/institucion-dia.entity'; import { InstitucionInfraccion } from '../../institucion-infraccion/institucion-infraccion.entity'; import { Modulo } from '../../modulo/entity/modulo.entity'; diff --git a/src/institucion/institucion.service.ts b/src/institucion/institucion.service.ts index 841c82a..fdcc90d 100644 --- a/src/institucion/institucion.service.ts +++ b/src/institucion/institucion.service.ts @@ -1,6 +1,6 @@ import { Injectable, NotFoundException } from '@nestjs/common'; -import { Repository } from 'typeorm'; import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; import { Institucion } from './entity/institucion.entity'; @Injectable() diff --git a/src/usuario/usuario.entity.ts b/src/usuario/usuario.entity.ts index 4a6c549..519f265 100644 --- a/src/usuario/usuario.entity.ts +++ b/src/usuario/usuario.entity.ts @@ -6,7 +6,7 @@ import { ManyToOne, JoinColumn, } from 'typeorm'; -import { Carrera } from '../carrera/carrera.entity'; +import { Carrera } from '../carrera/entity/carrera.entity'; import { Institucion } from '../institucion/entity/institucion.entity'; import { Prestamo } from '../prestamo/prestamo.entity'; import { TipoUsuario } from '../tipo-usuario/tipo-usuario.entity';