package org.raddatz.familienarchiv.person;

import org.raddatz.familienarchiv.document.DatePrecision;

import java.time.LocalDate;
import java.util.UUID;

/**
 * Projection returned by the /api/persons list endpoint.
 * Includes document count to avoid N+1 queries in the UI.
 * Uses interface projection for compatibility with native queries.
 */
public interface PersonSummaryDTO {
    UUID getId();
    String getTitle();
    String getFirstName();
    String getLastName();
    String getPersonType();
    String getAlias();
    Integer getBirthYear();
    Integer getDeathYear();
    // Full date + precision alongside the derived years: list consumers that render
    // precise life dates (mention dropdown) read these; year-only consumers keep
    // the cheaper getBirthYear/getDeathYear.
    LocalDate getBirthDate();
    DatePrecision getBirthDatePrecision();
    LocalDate getDeathDate();
    DatePrecision getDeathDatePrecision();
    String getNotes();
    boolean isFamilyMember();
    boolean isProvisional();
    long getDocumentCount();

    default String getDisplayName() {
        return org.raddatz.familienarchiv.user.DisplayNameFormatter.format(
                getTitle(), getFirstName(), getLastName());
    }
}
