import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { CentroCusto } from './entities/centro-custo.entity'; @Injectable() export class CentrosCustoService { constructor(@InjectRepository(CentroCusto) private repo: Repository) {} findAll() { return this.repo.find({ where: { ativo: true } }); } findOne(id: string) { return this.repo.findOne({ where: { id } }); } create(data: Partial) { return this.repo.save(data); } async update(id: string, data: Partial) { await this.repo.update(id, data); return this.findOne(id); } async remove(id: string) { await this.repo.update(id, { ativo: false }); } }