added new EP

This commit is contained in:
2025-09-18 21:08:19 -06:00
15 changed files with 87 additions and 33 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ export class Sancion {
@OneToMany(
() => AlumnoSancion,
(alusancion) => alusancion.id_sancion,
(alusancion) => alusancion.sancion,
)
alumnosSancionados: AlumnoSancion[];
}
+5
View File
@@ -1,9 +1,14 @@
import { Module } from '@nestjs/common';
import { SancionService } from './sancion.service';
import { SancionController } from './sancion.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Sancion } from './entities/sancion.entity';
@Module({
imports:[TypeOrmModule.forFeature([Sancion])],
controllers: [SancionController],
providers: [SancionService],
exports:[SancionService],
})
export class SancionModule {}
//IO
+17 -3
View File
@@ -1,9 +1,16 @@
import { Injectable } from '@nestjs/common';
import { Injectable, NotFoundException } from '@nestjs/common';
import { CreateSancionDto } from './dto/create-sancion.dto';
import { UpdateSancionDto } from './dto/update-sancion.dto';
import { Sancion } from './entities/sancion.entity';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
@Injectable()
export class SancionService {
constructor(
@InjectRepository(Sancion)
private readonly sancionRepository: Repository<Sancion>
){}
create(createSancionDto: CreateSancionDto) {
return 'This action adds a new sancion';
}
@@ -12,8 +19,14 @@ export class SancionService {
return `This action returns all sancion`;
}
findOne(id: number) {
return `This action returns a #${id} sancion`;
async findOne(id_sancion: number): Promise<Sancion> {
const sancion = await this.sancionRepository.findOne({
where: { id_sancion },
});
if (!sancion) {
throw new NotFoundException(`Sancion not found`);
}
return sancion;
}
update(id: number, updateSancionDto: UpdateSancionDto) {
@@ -24,3 +37,4 @@ export class SancionService {
return `This action removes a #${id} sancion`;
}
}
//IO