new ep usoWhitout
This commit is contained in:
@@ -11,26 +11,33 @@ export class MesaController {
|
|||||||
constructor(private readonly mesaService: MesaService) { }
|
constructor(private readonly mesaService: MesaService) { }
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR, Role.ATENCION_USUARIOS, Role.SERVICIO_SOCIAL)
|
||||||
@Get()
|
@Get()
|
||||||
async findAll() {
|
async findAll() {
|
||||||
return this.mesaService.findAll();
|
return this.mesaService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR, Role.ATENCION_USUARIOS, Role.SERVICIO_SOCIAL)
|
||||||
@Get('activo')
|
@Get('activo')
|
||||||
async findAllActivo() {
|
async findAllActivo() {
|
||||||
return this.mesaService.findAllActivo();
|
return this.mesaService.findAllActivo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR, Role.ATENCION_USUARIOS, Role.SERVICIO_SOCIAL)
|
||||||
@Get('uso')
|
@Get('uso')
|
||||||
async findActiveMesas() {
|
async findActiveMesas() {
|
||||||
return this.mesaService.findActiveMesas();
|
return this.mesaService.findActiveMesas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR, Role.ATENCION_USUARIOS, Role.SERVICIO_SOCIAL)
|
||||||
|
@Get('usoWhitout')
|
||||||
|
async findActiveMesasWhitoudOcupado() {
|
||||||
|
return this.mesaService.findActiveMesasWhitoudOcupado();
|
||||||
|
}
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
@@ -42,7 +49,7 @@ export class MesaController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR, Role.ATENCION_USUARIOS, Role.SERVICIO_SOCIAL)
|
||||||
@Patch(':id/activo')
|
@Patch(':id/activo')
|
||||||
toggleActivo(@Param('id') id: number) {
|
toggleActivo(@Param('id') id: number) {
|
||||||
return this.mesaService.toggleActivo(+id);
|
return this.mesaService.toggleActivo(+id);
|
||||||
|
|||||||
@@ -142,4 +142,27 @@ export class MesaService {
|
|||||||
.orderBy('mesa.id_mesa', 'ASC')
|
.orderBy('mesa.id_mesa', 'ASC')
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findActiveMesasWhitoudOcupado() {
|
||||||
|
return this.mesaRepository
|
||||||
|
.createQueryBuilder('mesa')
|
||||||
|
.select([
|
||||||
|
'mesa.id_mesa AS id_mesa',
|
||||||
|
])
|
||||||
|
.where('mesa.activo = 1')
|
||||||
|
.andWhere(`
|
||||||
|
NOT 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
|
||||||
|
)
|
||||||
|
`)
|
||||||
|
.orderBy('mesa.id_mesa', 'ASC')
|
||||||
|
.getRawMany();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user