service and controller done

This commit is contained in:
Olivier PARPAILLON
2025-07-16 10:28:43 +02:00
parent b6242d0f2c
commit 9c24ef5b22
7 changed files with 100 additions and 2 deletions

View File

@@ -1,4 +1,36 @@
package fr.eni.demo.bll;
import fr.eni.demo.bo.Facture;
import fr.eni.demo.dal.FactureRepository;
import java.util.List;
public class FactureServiceImpl implements FactureService {
private final FactureRepository factureRepo;
public FactureServiceImpl(FactureRepository factureRepo) {
this.factureRepo = factureRepo;
}
@Override
public List<Facture> getByClient(Long clientId) {
if (clientId == null) {
throw new IllegalArgumentException("Client id can't be null");
}
List<Facture> factures = factureRepo.findByClient(clientId);
if (factures == null) {
throw new IllegalArgumentException("No factures found");
};
return factures;
}
@Override
public List<Facture> getAll() {
return factureRepo.findAll();
}
@Override
public List<Facture> getUnpayed() {
return factureRepo.findByDatePayEmpty();
}
}