This commit is contained in:
2025-09-22 18:09:41 -06:00
parent 429678dc3b
commit c39faa513b
7 changed files with 83 additions and 1 deletions
+27
View File
@@ -0,0 +1,27 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { UpdateMesaDto } from './dto/update-mesa.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Mesa } from './entities/mesa.entity';
@Injectable()
export class MesaService {
constructor(
@InjectRepository(Mesa)
private readonly mesaRepository: Repository<Mesa>,
) {}
async findAll(): Promise<Mesa[]> {
return await this.mesaRepository.find();
}
async updateActivo(id: number, updateMesaDto: UpdateMesaDto) {
const mesa = await this.mesaRepository.findOne({ where: { idMesa: id } });
if (!mesa) {
throw new NotFoundException(`La mesa no fue encontrada`);
}
mesa.activo = updateMesaDto.activo;
return this.mesaRepository.save(mesa);
}
}