added new ep uso in mesa

This commit is contained in:
2026-02-24 18:47:49 -06:00
parent c63f59593c
commit eb52f9829f
2 changed files with 29 additions and 1 deletions
+6 -1
View File
@@ -15,7 +15,12 @@ export class MesaController {
async findAllActivo() {
return this.mesaService.findAllActivo();
}
@Get('uso')
async findActiveMesas() {
return this.mesaService.findActiveMesas();
}
@Patch(':id')
async updateActivo(
@Param('id') id: number,
+23
View File
@@ -119,4 +119,27 @@ export class MesaService {
activo: nuevoActivo,
};
}
findActiveMesas() {
return this.mesaRepository
.createQueryBuilder('mesa')
.select([
'mesa.id_mesa AS id_mesa',
`
EXISTS (
SELECT 1
FROM bitacora_mesa bm
WHERE bm.id_mesa = mesa.id_mesa
AND TIMESTAMPDIFF(
SECOND,
NOW(),
DATE_ADD(bm.tiempo_entrada, INTERVAL bm.tiempo_asignado MINUTE)
) > 0
) AS ocupado
`,
])
.where('mesa.activo = 1')
.orderBy('mesa.id_mesa', 'ASC')
.getRawMany();
}
}