package org.raddatz.familienarchiv.geschichte;

import io.swagger.v3.oas.annotations.media.Schema;
import org.raddatz.familienarchiv.geschichte.journeyitem.JourneyItemView;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
import java.util.UUID;

/**
 * Detail-view response for GET /api/geschichten/{id}. Assembled by
 * GeschichteService — never the raw entity (author AppUser graph must not leak).
 * items is always present (both STORY and JOURNEY); empty list for stories with no items.
 */
public record GeschichteView(
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) UUID id,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) String title,
        String body,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) GeschichteStatus status,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) GeschichteType type,
        AuthorView author,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) Set<PersonView> persons,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) List<JourneyItemView> items,
        LocalDateTime publishedAt,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) LocalDateTime createdAt,
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED) LocalDateTime updatedAt
) {
    /** Summarised author — exposes only id and displayName, never email or group memberships. */
    public record AuthorView(
            @Schema(requiredMode = Schema.RequiredMode.REQUIRED) UUID id,
            @Schema(requiredMode = Schema.RequiredMode.REQUIRED) String displayName
    ) {}

    /** Summarised person — exposes only id, firstName, and lastName. No admin-only fields. */
    public record PersonView(
            @Schema(requiredMode = Schema.RequiredMode.REQUIRED) UUID id,
            String firstName,
            String lastName
    ) {}
}
