package sn.ladoum.bergerie.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import sn.ladoum.bergerie.entity.Mouton;
import sn.ladoum.bergerie.entity.enums.Sexe;
import sn.ladoum.bergerie.entity.enums.StatutMouton;

import java.time.LocalDate;
import java.util.List;

@Repository
public interface MoutonRepository extends JpaRepository<Mouton, Long> {
    List<Mouton> findByNomContainingIgnoreCase(String nom);
    List<Mouton> findBySexe(Sexe sexe);
    List<Mouton> findByStatut(StatutMouton statut);
    List<Mouton> findByPereId(Long pereId);
    List<Mouton> findByMereId(Long mereId);
    List<Mouton> findByMereIdAndDateNaissanceAndNaissanceIsNull(Long mereId, LocalDate dateNaissance);
    List<Mouton> findByNaissanceId(Long naissanceId);
    long countByStatut(StatutMouton statut);

    // Filtrage par éleveur (visibilité par rôle)
    List<Mouton> findByEleveurId(Long eleveurId);
    List<Mouton> findByEleveurIdAndSexe(Long eleveurId, Sexe sexe);
    List<Mouton> findByEleveurIdAndStatut(Long eleveurId, StatutMouton statut);
    List<Mouton> findByEleveurIdAndNomContainingIgnoreCase(Long eleveurId, String nom);
}
