added new ep uso in mesa
This commit is contained in:
@@ -15,7 +15,12 @@ export class MesaController {
|
|||||||
async findAllActivo() {
|
async findAllActivo() {
|
||||||
return this.mesaService.findAllActivo();
|
return this.mesaService.findAllActivo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('uso')
|
||||||
|
async findActiveMesas() {
|
||||||
|
return this.mesaService.findActiveMesas();
|
||||||
|
}
|
||||||
|
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
async updateActivo(
|
async updateActivo(
|
||||||
@Param('id') id: number,
|
@Param('id') id: number,
|
||||||
|
|||||||
@@ -119,4 +119,27 @@ export class MesaService {
|
|||||||
activo: nuevoActivo,
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user