fixed ep mesa

This commit is contained in:
2026-02-23 18:05:09 -06:00
parent 1aef1e8b0f
commit 472bfebb7a
2 changed files with 33 additions and 6 deletions
+2 -2
View File
@@ -21,13 +21,13 @@ export class AlumnoController {
return this.alumnoService.create(createStudentDto);
}
//@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard)
@Get(':id')
findOneWhitSancion(@Param('id') id: number) {
return this.alumnoService.findOneWhitSancion(+id);
}
//@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard)
@Get('sancion/:id')
findOne(@Param('id') id: number) {
return this.alumnoService.findOne(+id);
+31 -4
View File
@@ -38,15 +38,42 @@ export class MesaService {
});
}
async findAll(): Promise<Mesa[]> {
return await this.mesaRepository.find();
}
async findAllActivo(): Promise<Mesa[]> {
return await this.mesaRepository.find({ where: { activo: true } });
const mesas = await this.mesaRepository
.createQueryBuilder('mesa')
.andWhere('mesa.activo = true')
.andWhere((qb) => {
const subQuery = qb
.subQuery()
.select('bitacora_mesa.id_mesa')
.from('bitacora_mesa', 'bitacora_mesa')
.where(
`TIMESTAMPDIFF(
SECOND,
NOW(),
DATE_ADD(bitacora_mesa.tiempo_entrada, INTERVAL bitacora_mesa.tiempo_asignado MINUTE)
) > 0`,
)
.getQuery();
return `mesa.id_mesa NOT IN ${subQuery}`;
})
.orderBy('mesa.id_mesa', 'ASC')
.getMany();
if (!mesas.length) {
throw new NotFoundException('No usable table found');
}
return mesas;
}
async updateActivo(id: number, updateMesaDto: UpdateMesaDto) {