2026-01-23 16:46:55 -06:00
|
|
|
import { Injectable, NotFoundException } from '@nestjs/common';
|
2026-01-21 15:13:21 -06:00
|
|
|
import { CreateBitacoraMesaDto } from './dto/create-bitacora_mesa.dto';
|
2026-01-21 17:10:49 -06:00
|
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
|
|
|
import { BitacoraMesa } from './entities/bitacora_mesa.entity';
|
|
|
|
|
import { Repository } from 'typeorm';
|
2026-01-21 15:13:21 -06:00
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class BitacoraMesaService {
|
2026-01-21 17:10:49 -06:00
|
|
|
constructor(
|
|
|
|
|
@InjectRepository(BitacoraMesa)
|
|
|
|
|
private readonly bitacoraMesaRepository: Repository<BitacoraMesa>,
|
|
|
|
|
) {}
|
2026-01-21 15:13:21 -06:00
|
|
|
create(createBitacoraMesaDto: CreateBitacoraMesaDto) {
|
|
|
|
|
return 'This action adds a new bitacoraMesa';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
findAll() {
|
2026-01-23 16:46:55 -06:00
|
|
|
return this.bitacoraMesaRepository.find({
|
|
|
|
|
relations: ['mesa', 'alumno_inscrito'],
|
|
|
|
|
take: 100,
|
|
|
|
|
});
|
2026-01-21 15:13:21 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
findOne(id: number) {
|
|
|
|
|
return `This action returns a #${id} bitacoraMesa`;
|
|
|
|
|
}
|
2026-01-23 16:46:55 -06:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2026-01-21 15:13:21 -06:00
|
|
|
}
|