Merge branch 'Axel' of https://github.com/IO420/api-nexus into Lino

This commit is contained in:
2025-09-18 15:56:27 -06:00
27 changed files with 463 additions and 39 deletions
+2
View File
@@ -21,3 +21,5 @@ export class CreateStudentDto {
@IsString()
correo: string;
}
//Hubo pedos con la base , revisar
+43 -4
View File
@@ -1,4 +1,30 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
import { AlumnoSancion } from 'src/alumno_sancion/entities/alumno_sancion.entity';
import { DetalleServicio } from 'src/detalle_servicio/entities/detalle_servicio.entity';
import {
Column,
Entity,
JoinColumn,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
} from 'typeorm';
@Entity({ name: 'carrea' })
export class Carrera {
@PrimaryGeneratedColumn({ name: 'id_carrera', type: 'int', unsigned: true })
id_carrera: number;
@Column({
name: 'nombre_carrea',
type: 'varchar',
length: 100,
nullable: false,
})
nombre_carrea: string;
@OneToMany(() => Student, (id_carrera) => id_carrera.id_cuenta)
id_carreras: Student[];
}
@Entity({ name: 'alumno' })
export class Student {
@@ -54,9 +80,22 @@ export class Student {
})
fecha_registro: Date;
@Column({ name: 'id_carrera', type: 'int', nullable: false })
id_carrera: number;
@Column({ name: 'generacion', type: 'int', width: 4, nullable: true })
generacion: number | null;
@OneToMany(
() => DetalleServicio,
(id_detalle_servicio) => id_detalle_servicio.id_cuenta,
)
detalles_servicio: DetalleServicio[];
@ManyToOne(() => Carrera, (id_cuenta) => id_cuenta.id_carreras, {
eager: true,
nullable: true,
})
@JoinColumn({ name: 'id_carrera' })
id_periodos: Carrera;
@OneToMany(() => AlumnoSancion, (id_cuenta) => id_cuenta.id_alumno_sancion)
id_cuentas: AlumnoSancion[];
}
+6 -12
View File
@@ -1,30 +1,24 @@
import {
Controller,
Get,
Post,
Body,
Param,
} from '@nestjs/common';
import { StudentService } from './student.service';
import { Controller, Get, Post, Body, Param } from '@nestjs/common';
import { AlumnoService } from './student.service';
import { CreateStudentDto } from './dto/create-student.dto';
import { Student } from './entities/student.entity';
@Controller('student')
export class StudentController {
constructor(private readonly studentService: StudentService) {}
constructor(private readonly alumnoService: AlumnoService) {}
@Post()
async create(@Body() createStudentDto: CreateStudentDto): Promise<Student> {
return this.studentService.create(createStudentDto);
return this.alumnoService.create(createStudentDto);
}
@Get()
async findAll(): Promise<Student[]> {
return this.studentService.findAll();
return this.alumnoService.findAll();
}
@Get(':id')
findOne(@Param('id') id: number) {
return this.studentService.findOne(+id);
return this.alumnoService.findOne(+id);
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
import { Module } from '@nestjs/common';
import { StudentService } from './student.service';
import { AlumnoService } from './student.service';
import { StudentController } from './student.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Student } from './entities/student.entity';
@@ -7,6 +7,6 @@ import { Student } from './entities/student.entity';
@Module({
imports: [TypeOrmModule.forFeature([Student])],
controllers: [StudentController],
providers: [StudentService],
providers: [AlumnoService],
})
export class StudentModule {}
+2 -1
View File
@@ -5,13 +5,14 @@ import { EntityManager, Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
@Injectable()
export class StudentService {
export class AlumnoService {
constructor(
@InjectRepository(Student)
private readonly studentRepository: Repository<Student>,
) {}
async create(createStudentDto: CreateStudentDto): Promise<Student> {
//Hubo pedos con la base , revisar
const student = this.studentRepository.create(createStudentDto);
return await this.studentRepository.save(student);
}