package org.raddatz.familienarchiv.person.relationship.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import org.raddatz.familienarchiv.document.DatePrecision;
import org.raddatz.familienarchiv.person.relationship.RelationType;

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

/**
 * Wire shape for one stored relationship row. Both sides include name + years
 * so the frontend can render the row from either perspective (e.g. on the
 * subject's page the row reads "Elternteil von [related]"; on the object's
 * page it reads "Kind von [person]").
 *
 * <p>Storage truth: {@code personId} is the {@code person_id} column,
 * {@code relatedPersonId} is the {@code related_person_id} column. The
 * frontend determines orientation by comparing against the viewpoint.
 */
public record RelationshipDTO(
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) UUID id,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) UUID personId,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) UUID relatedPersonId,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) String personDisplayName,
        Integer personBirthYear,
        Integer personDeathYear,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) String relatedPersonDisplayName,
        Integer relatedPersonBirthYear,
        Integer relatedPersonDeathYear,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) RelationType relationType,
        LocalDate fromDate,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) DatePrecision fromDatePrecision,
        LocalDate toDate,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) DatePrecision toDatePrecision,
        String notes
) {}
