added alumno_inscrito and others Ep

This commit is contained in:
2025-09-24 11:04:08 -04:00
parent c39faa513b
commit 86ccf98479
16 changed files with 230 additions and 23 deletions
+1 -3
View File
@@ -20,6 +20,4 @@ export class CreateStudentDto {
@IsEmail()
@IsString()
correo: string;
}
//Hubo pedos con la base , revisar
}
+3 -3
View File
@@ -84,9 +84,6 @@ export class Alumno {
@Column({ name: 'generacion', type: 'int', width: 4, nullable: true })
generacion: number | null;
@OneToMany(() => DetalleServicio, (detalle) => detalle.alum)
detalles_servicio: DetalleServicio[];
@ManyToOne(() => Carrera, (carrera) => carrera.estudiantes, {
eager: true,
nullable: true,
@@ -94,6 +91,9 @@ export class Alumno {
@JoinColumn({ name: 'id_carrera' })
carrera: Carrera;
@OneToMany(() => DetalleServicio, (detalle) => detalle.alum)
detalles_servicio: DetalleServicio[];
@OneToMany(() => AlumnoSancion, (alusancion) => alusancion.sancion)
sanciones: AlumnoSancion[];
+5
View File
@@ -21,5 +21,10 @@ export class AlumnoController {
findOne(@Param('id') id: number) {
return this.alumnoService.findOne(+id);
}
@Post('/create')
async newStudent(@Body() createStudentDto: CreateStudentDto) {
return this.alumnoService.create(createStudentDto);
}
}
//IO
+2 -2
View File
@@ -2,10 +2,10 @@ import { Module } from '@nestjs/common';
import { AlumnoService } from './student.service';
import { AlumnoController } from './student.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Alumno } from './entities/student.entity';
import { Alumno, Carrera } from './entities/student.entity';
@Module({
imports: [TypeOrmModule.forFeature([Alumno])],
imports: [TypeOrmModule.forFeature([Alumno,Carrera])],
controllers: [AlumnoController],
providers: [AlumnoService],
exports:[AlumnoService]
+17 -6
View File
@@ -1,6 +1,6 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { CreateStudentDto } from './dto/create-student.dto';
import { Alumno } from './entities/student.entity';
import { Alumno, Carrera } from './entities/student.entity';
import { EntityManager, Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
@@ -9,11 +9,21 @@ export class AlumnoService {
constructor(
@InjectRepository(Alumno)
private readonly studentRepository: Repository<Alumno>,
) {}
@InjectRepository(Carrera)
private readonly carreraRepository: Repository<Carrera>,
) { }
async create(createStudentDto: CreateStudentDto): Promise<Alumno> {
//Hubo pedos con la base , revisar
const student = this.studentRepository.create(createStudentDto);
async create(data: CreateStudentDto): Promise<Alumno> {
const { id_carrera, ...rest } = data;
const carrera = await this.carreraRepository.findOne({
where: { id_carrera: data.id_carrera },
});
if (!carrera) {
throw new NotFoundException(`Carrera not found`);
}
const createStudent = { ...rest, carrera ,fecha_registro: new Date()};
const student = this.studentRepository.create(createStudent);
return await this.studentRepository.save(student);
}
@@ -24,6 +34,7 @@ export class AlumnoService {
async findOne(id_cuenta: number): Promise<Alumno> {
const student = await this.studentRepository.findOne({
where: { id_cuenta },
select: {id_cuenta:true,nombre:true,credito:true},
});
if (!student) {
throw new NotFoundException(`Student not found`);
@@ -50,7 +61,7 @@ export class AlumnoService {
.execute();
}
async addCredit(
async addCredit(
id_cuenta: number,
credit: number,
manager: EntityManager,