added ep table
This commit is contained in:
@@ -34,6 +34,11 @@ export class BitacoraMesaController {
|
|||||||
return this.bitacoraMesaService.findByCuenta(+id_cuenta);
|
return this.bitacoraMesaService.findByCuenta(+id_cuenta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('/table/:id_mesa')
|
||||||
|
findByTable(@Param('id_mesa') id_mesa: number) {
|
||||||
|
return this.bitacoraMesaService.findByTable(id_mesa);
|
||||||
|
}
|
||||||
|
|
||||||
@Patch('cancelar/:id')
|
@Patch('cancelar/:id')
|
||||||
cancelationByMachine(
|
cancelationByMachine(
|
||||||
@Param('id') id: number,
|
@Param('id') id: number,
|
||||||
|
|||||||
@@ -56,13 +56,36 @@ export class BitacoraMesaService {
|
|||||||
return student;
|
return student;
|
||||||
}
|
}
|
||||||
|
|
||||||
async cancelation(id_bitacora_mesa: number, nuevoTiempo: number) {
|
async findByTable(id_mesa: number) {
|
||||||
|
const student = await this.bitacoraMesaRepository
|
||||||
|
.createQueryBuilder('bitacora')
|
||||||
|
.leftJoinAndSelect('bitacora.alumno_inscrito', 'alumnoInscrito')
|
||||||
|
.leftJoinAndSelect('alumnoInscrito.alumno', 'alumno')
|
||||||
|
.leftJoinAndSelect('alumno.carrera', 'carrera')
|
||||||
|
.leftJoinAndSelect('bitacora.mesa', 'mesa')
|
||||||
|
.where('mesa.id_mesa = :id_mesa', { id_mesa })
|
||||||
|
|
||||||
|
.andWhere(
|
||||||
|
`TIMESTAMPDIFF(SECOND,NOW(),DATE_ADD(bitacora.tiempo_entrada, INTERVAL bitacora.tiempo_asignado MINUTE)) > 0`,
|
||||||
|
)
|
||||||
|
|
||||||
|
.orderBy('bitacora.tiempo_entrada', 'DESC')
|
||||||
|
.getOne();
|
||||||
|
|
||||||
|
if (!student) {
|
||||||
|
throw new NotFoundException('Mesa no asignada');
|
||||||
|
}
|
||||||
|
|
||||||
|
return student;
|
||||||
|
}
|
||||||
|
|
||||||
|
async cancelation(id_bitacora_mesa: number, nuevoTiempo: number) {
|
||||||
const bitacora = await this.bitacoraMesaRepository.findOne({
|
const bitacora = await this.bitacoraMesaRepository.findOne({
|
||||||
where: { id_bitacora_mesa },
|
where: { id_bitacora_mesa },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!bitacora) {
|
if (!bitacora) {
|
||||||
throw new NotFoundException('alumno sin mesa asignada');
|
throw new NotFoundException('Mesa no encontrada');
|
||||||
}
|
}
|
||||||
|
|
||||||
bitacora.tiempo_asignado -= nuevoTiempo;
|
bitacora.tiempo_asignado -= nuevoTiempo;
|
||||||
|
|||||||
Reference in New Issue
Block a user