Files
api-AT/src/sancion/sancion.service.ts
T

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-09-18 21:08:19 -06:00
import { Injectable, NotFoundException } from '@nestjs/common';
2025-09-17 16:35:52 -06:00
import { CreateSancionDto } from './dto/create-sancion.dto';
import { UpdateSancionDto } from './dto/update-sancion.dto';
2025-09-18 21:08:19 -06:00
import { Sancion } from './entities/sancion.entity';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
2025-09-17 16:35:52 -06:00
@Injectable()
export class SancionService {
2025-09-18 21:08:19 -06:00
constructor(
@InjectRepository(Sancion)
private readonly sancionRepository: Repository<Sancion>
){}
2025-09-17 16:35:52 -06:00
create(createSancionDto: CreateSancionDto) {
return 'This action adds a new sancion';
}
findAll() {
return `This action returns all sancion`;
}
2025-09-18 21:08:19 -06:00
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;
2025-09-17 16:35:52 -06:00
}
update(id: number, updateSancionDto: UpdateSancionDto) {
return `This action updates a #${id} sancion`;
}
remove(id: number) {
return `This action removes a #${id} sancion`;
}
}
2025-09-18 21:08:19 -06:00
//IO