get table by number acount
This commit is contained in:
@@ -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 { BitacoraMesaService } from './bitacora_mesa.service';
|
||||||
import { CreateBitacoraMesaDto } from './dto/create-bitacora_mesa.dto';
|
import { CreateBitacoraMesaDto } from './dto/create-bitacora_mesa.dto';
|
||||||
|
|
||||||
@@ -20,4 +28,9 @@ export class BitacoraMesaController {
|
|||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.bitacoraMesaService.findOne(+id);
|
return this.bitacoraMesaService.findOne(+id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('/cuenta/:id_cuenta')
|
||||||
|
findByCuenta(@Param('id_cuenta') id_cuenta: string) {
|
||||||
|
return this.bitacoraMesaService.findByCuenta(+id_cuenta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||||
import { CreateBitacoraMesaDto } from './dto/create-bitacora_mesa.dto';
|
import { CreateBitacoraMesaDto } from './dto/create-bitacora_mesa.dto';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { BitacoraMesa } from './entities/bitacora_mesa.entity';
|
import { BitacoraMesa } from './entities/bitacora_mesa.entity';
|
||||||
@@ -15,10 +15,39 @@ export class BitacoraMesaService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
findAll() {
|
findAll() {
|
||||||
return this.bitacoraMesaRepository.find({relations:['mesa','alumno_inscrito'],take:100});
|
return this.bitacoraMesaRepository.find({
|
||||||
|
relations: ['mesa', 'alumno_inscrito'],
|
||||||
|
take: 100,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
findOne(id: number) {
|
findOne(id: number) {
|
||||||
return `This action returns a #${id} bitacoraMesa`;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user