# Copyright (c) 2025 Patrick Motsch
# All rights reserved.
"""Base Pydantic model with system-managed fields (DB + API + UI metadata)."""

from typing import Optional

from pydantic import BaseModel, Field

from modules.shared.attributeUtils import registerModelLabels


class PowerOnModel(BaseModel):
    sysCreatedAt: Optional[float] = Field(
        default=None,
        description="Record creation timestamp (UTC, set by system)",
        json_schema_extra={
            "frontend_type": "timestamp",
            "frontend_readonly": True,
            "frontend_required": False,
            "frontend_visible": False,
            "system": True,
        },
    )
    sysCreatedBy: Optional[str] = Field(
        default=None,
        description="User ID who created this record (set by system)",
        json_schema_extra={
            "frontend_type": "text",
            "frontend_readonly": True,
            "frontend_required": False,
            "frontend_visible": False,
            "system": True,
        },
    )
    sysModifiedAt: Optional[float] = Field(
        default=None,
        description="Record last modification timestamp (UTC, set by system)",
        json_schema_extra={
            "frontend_type": "timestamp",
            "frontend_readonly": True,
            "frontend_required": False,
            "frontend_visible": False,
            "system": True,
        },
    )
    sysModifiedBy: Optional[str] = Field(
        default=None,
        description="User ID who last modified this record (set by system)",
        json_schema_extra={
            "frontend_type": "text",
            "frontend_readonly": True,
            "frontend_required": False,
            "frontend_visible": False,
            "system": True,
        },
    )


registerModelLabels(
    "PowerOnModel",
    {"en": "Base Record", "de": "Basisdatensatz"},
    {
        "sysCreatedAt": {"en": "Created At", "de": "Erstellt am", "fr": "Cree le"},
        "sysCreatedBy": {"en": "Created By", "de": "Erstellt von", "fr": "Cree par"},
        "sysModifiedAt": {"en": "Modified At", "de": "Geaendert am", "fr": "Modifie le"},
        "sysModifiedBy": {"en": "Modified By", "de": "Geaendert von", "fr": "Modifie par"},
    },
)
