add carrera

This commit is contained in:
2025-09-26 17:43:19 -06:00
parent 531ca5bdef
commit 7370e25e89
10 changed files with 79 additions and 24 deletions
+12
View File
@@ -0,0 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { CarreraService } from './carrera.service';
@Controller('carrera')
export class CarreraController {
constructor(private readonly carreraService: CarreraService) {}
@Get()
findAll() {
return this.carreraService.findAll();
}
}
+12
View File
@@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';
import { CarreraService } from './carrera.service';
import { CarreraController } from './carrera.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Carrera } from './entities/carrera.entity';
@Module({
imports: [TypeOrmModule.forFeature([Carrera])],
controllers: [CarreraController],
providers: [CarreraService],
})
export class CarreraModule {}
+15
View File
@@ -0,0 +1,15 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Carrera } from './entities/carrera.entity';
import { Repository } from 'typeorm';
@Injectable()
export class CarreraService {
constructor(
@InjectRepository(Carrera)
private readonly carreraRepository: Repository<Carrera>,
) {}
findAll() {
return this.carreraRepository.find();
}
}
+1
View File
@@ -0,0 +1 @@
export class CreateCarreraDto {}
+4
View File
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateCarreraDto } from './create-carrera.dto';
export class UpdateCarreraDto extends PartialType(CreateCarreraDto) {}
+19
View File
@@ -0,0 +1,19 @@
import { Alumno } from 'src/alumno/entities/student.entity';
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
@Entity({ name: 'carrera' })
export class Carrera {
@PrimaryGeneratedColumn({ name: 'id_carrera', type: 'int', unsigned: true })
id_carrera: number;
@Column({
name: 'carrera',
type: 'varchar',
length: 100,
nullable: false,
})
carrera: string;
@OneToMany(() => Alumno, (student) => student.carrera)
estudiantes: Alumno[];
}