get table by number acount

This commit is contained in:
2026-01-23 16:46:55 -06:00
parent 1ae0911847
commit 90e4aa9810
2 changed files with 45 additions and 3 deletions
+14 -1
View File
@@ -1,4 +1,12 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import {
Controller,
Get,
Post,
Body,
Patch,
Param,
Delete,
} from '@nestjs/common';
import { BitacoraMesaService } from './bitacora_mesa.service';
import { CreateBitacoraMesaDto } from './dto/create-bitacora_mesa.dto';
@@ -20,4 +28,9 @@ export class BitacoraMesaController {
findOne(@Param('id') id: string) {
return this.bitacoraMesaService.findOne(+id);
}
@Get('/cuenta/:id_cuenta')
findByCuenta(@Param('id_cuenta') id_cuenta: string) {
return this.bitacoraMesaService.findByCuenta(+id_cuenta);
}
}
+31 -2
View File
@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common';
import { Injectable, NotFoundException } from '@nestjs/common';
import { CreateBitacoraMesaDto } from './dto/create-bitacora_mesa.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { BitacoraMesa } from './entities/bitacora_mesa.entity';
@@ -15,10 +15,39 @@ export class BitacoraMesaService {
}
findAll() {
return this.bitacoraMesaRepository.find({relations:['mesa','alumno_inscrito'],take:100});
return this.bitacoraMesaRepository.find({
relations: ['mesa', 'alumno_inscrito'],
take: 100,
});
}
findOne(id: number) {
return `This action returns a #${id} bitacoraMesa`;
}
async findByCuenta(id_cuenta: number) {
const alumno = await this.bitacoraMesaRepository.findOne({
where: {
alumno_inscrito: {
alumno: {
id_cuenta: id_cuenta,
},
},
},
relations: {
alumno_inscrito: {
alumno: true,
},
mesa: true,
},
order: {
tiempo_entrada: 'DESC',
},
});
if (!alumno) {
throw new NotFoundException('alumno sin mesa');
}
return alumno;
}
}