Creacion de entities

This commit is contained in:
2025-09-10 17:32:00 -06:00
parent 93d681a604
commit 4b5c1e4d95
32 changed files with 448 additions and 5 deletions
+1
View File
@@ -0,0 +1 @@
export class CreateStudentDto {}
+4
View File
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateStudentDto } from './create-student.dto';
export class UpdateStudentDto extends PartialType(CreateStudentDto) {}
+58
View File
@@ -0,0 +1,58 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
@Entity({ name: 'alumno' })
export class Student {
@PrimaryGeneratedColumn({ name: 'id_cuenta', type: 'int', unsigned: true })
id_cuenta: number;
@Column({ name: 'nombre', type: 'varchar', length: 300, nullable: false })
nombre: string;
@Column({
name: 'fecha_nacimiento',
type: 'varchar',
length: 8,
nullable: true,
})
fecha_nacimiento: string | null;
@Column({ name: 'correo', type: 'varchar', length: 100, nullable: true })
correo: string | null;
@Column({
name: 'credito',
type: 'decimal',
precision: 10,
scale: 2,
default: 0.0,
})
credito: string;
@Column({
name: 'fecha_actualizacion_credito',
type: 'timestamp',
default: () => 'CURRENT_TIMESTAMP',
onUpdate: 'CURRENT_TIMESTAMP',
})
fecha_actualizacion_credito: Date;
@Column({
name: 'vigente',
type: 'enum',
enum: ['si', 'no'],
default: 'si',
})
vigente: 'si' | 'no';
@Column({ name: 'id_periodo', type: 'int', nullable: true })
id_periodo: number | null;
@Column({ name: 'fecha_registro', type: 'datetime', nullable: false })
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;
}
+34
View File
@@ -0,0 +1,34 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { StudentService } from './student.service';
import { CreateStudentDto } from './dto/create-student.dto';
import { UpdateStudentDto } from './dto/update-student.dto';
@Controller('student')
export class StudentController {
constructor(private readonly studentService: StudentService) {}
@Post()
create(@Body() createStudentDto: CreateStudentDto) {
return this.studentService.create(createStudentDto);
}
@Get()
findAll() {
return this.studentService.findAll();
}
@Get(':id')
findOne(@Param('id') id: string) {
return this.studentService.findOne(+id);
}
@Patch(':id')
update(@Param('id') id: string, @Body() updateStudentDto: UpdateStudentDto) {
return this.studentService.update(+id, updateStudentDto);
}
@Delete(':id')
remove(@Param('id') id: string) {
return this.studentService.remove(+id);
}
}
+9
View File
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { StudentService } from './student.service';
import { StudentController } from './student.controller';
@Module({
controllers: [StudentController],
providers: [StudentService],
})
export class StudentModule {}
+26
View File
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateStudentDto } from './dto/create-student.dto';
import { UpdateStudentDto } from './dto/update-student.dto';
@Injectable()
export class StudentService {
create(createStudentDto: CreateStudentDto) {
return 'This action adds a new student';
}
findAll() {
return `This action returns all student`;
}
findOne(id: number) {
return `This action returns a #${id} student`;
}
update(id: number, updateStudentDto: UpdateStudentDto) {
return `This action updates a #${id} student`;
}
remove(id: number) {
return `This action removes a #${id} student`;
}
}