package fr.marouse.service;

import fr.marouse.entity.Client;
import fr.marouse.entity.Compte;
import fr.marouse.repository.ClientRepository;

import java.util.List;

public class BanqueService {

    private final ClientRepository clientRepository;

    public BanqueService(ClientRepository clientRepository) {
        this.clientRepository = clientRepository;
    }

    public void creerClient(Client client) {
        clientRepository.save(client);
    }

    public Client getClient(int idClient) {
        return clientRepository.findById(idClient)
                .orElseThrow(() ->
                        new RuntimeException("Client introuvable"));
    }

    public List<Compte> getComptesClient(int idClient) {
        return clientRepository.findComptesByClient(idClient);
    }
}