Creacion de entities y servicios

This commit is contained in:
2025-09-17 16:35:52 -06:00
parent 8cc039947f
commit 54306452ab
26 changed files with 460 additions and 39 deletions
+12
View File
@@ -0,0 +1,12 @@
import { IsInt, IsNotEmpty, IsString, MaxLength } from 'class-validator';
export class CreateSancionDto {
@IsNotEmpty()
@IsString()
@MaxLength(45)
sancion: string;
@IsNotEmpty()
@IsInt()
duracion: number;
}
+4
View File
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateSancionDto } from './create-sancion.dto';
export class UpdateSancionDto extends PartialType(CreateSancionDto) {}
+20
View File
@@ -0,0 +1,20 @@
import { AlumnoSancion } from 'src/alumno_sancion/entities/alumno_sancion.entity';
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
@Entity({ name: 'sancion' })
export class Sancion {
@PrimaryGeneratedColumn({ name: 'id_sancion', type: 'int' })
id_sancion: number;
@Column({ name: 'sancion', type: 'varchar', length: 45, nullable: false })
sancion: string;
@Column({ name: 'duracion', type: 'int', nullable: false })
duracion: number;
@OneToMany(
() => AlumnoSancion,
(id_sanncion) => id_sanncion.id_alumno_sancion,
)
id_sanciones: AlumnoSancion[];
}
+20
View File
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { SancionController } from './sancion.controller';
import { SancionService } from './sancion.service';
describe('SancionController', () => {
let controller: SancionController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [SancionController],
providers: [SancionService],
}).compile();
controller = module.get<SancionController>(SancionController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
+34
View File
@@ -0,0 +1,34 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { SancionService } from './sancion.service';
import { CreateSancionDto } from './dto/create-sancion.dto';
import { UpdateSancionDto } from './dto/update-sancion.dto';
@Controller('sancion')
export class SancionController {
constructor(private readonly sancionService: SancionService) {}
@Post()
create(@Body() createSancionDto: CreateSancionDto) {
return this.sancionService.create(createSancionDto);
}
@Get()
findAll() {
return this.sancionService.findAll();
}
@Get(':id')
findOne(@Param('id') id: string) {
return this.sancionService.findOne(+id);
}
@Patch(':id')
update(@Param('id') id: string, @Body() updateSancionDto: UpdateSancionDto) {
return this.sancionService.update(+id, updateSancionDto);
}
@Delete(':id')
remove(@Param('id') id: string) {
return this.sancionService.remove(+id);
}
}
+9
View File
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { SancionService } from './sancion.service';
import { SancionController } from './sancion.controller';
@Module({
controllers: [SancionController],
providers: [SancionService],
})
export class SancionModule {}
+18
View File
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { SancionService } from './sancion.service';
describe('SancionService', () => {
let service: SancionService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [SancionService],
}).compile();
service = module.get<SancionService>(SancionService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
+26
View File
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateSancionDto } from './dto/create-sancion.dto';
import { UpdateSancionDto } from './dto/update-sancion.dto';
@Injectable()
export class SancionService {
create(createSancionDto: CreateSancionDto) {
return 'This action adds a new sancion';
}
findAll() {
return `This action returns all sancion`;
}
findOne(id: number) {
return `This action returns a #${id} sancion`;
}
update(id: number, updateSancionDto: UpdateSancionDto) {
return `This action updates a #${id} sancion`;
}
remove(id: number) {
return `This action removes a #${id} sancion`;
}
}