"""
{{ entity_name }} entity for {{ module_name }} module.

Generated at: {{ generated_at }}
Generator version: {{ generator_version }}
"""
from dataclasses import dataclass, field
from typing import Optional
from datetime import datetime, timezone
from uuid import UUID, uuid4


@dataclass
class {{ EntityName }}:
    """{{ EntityName }} domain entity.
    
    Represents a {{ entity_description }} in the {{ module_name }} domain.
    """
    
    # --- Identifiers ---
    # Primary Key: Handled by the database (auto-incrementing integer)
    id: Optional[int] = None
    
    # Public Identifier: Handled by the application
    identifier: UUID = field(default_factory=uuid4)
    
    # Add your domain-specific fields here
    # Example:
    # name: str = ""
    # description: Optional[str] = None
    
    # Audit fields
    created_at: Optional[datetime] = field(default_factory=lambda: datetime.now(timezone.utc))
    updated_at: Optional[datetime] = field(default_factory=lambda: datetime.now(timezone.utc))
    
    def __post_init__(self) -> None:
        """Post-initialization validation and setup."""
        # The identifier is automatically generated via field default_factory
        # The id (primary key) is managed by the database
        
        now = datetime.now(timezone.utc)
        if self.created_at is None:
            self.created_at = now
        if self.updated_at is None:
            self.updated_at = now
    
    def update_timestamp(self) -> None:
        """Update the updated_at timestamp."""
        self.updated_at = datetime.now(timezone.utc)
    
    def is_new(self) -> bool:
        """Check if this is a new entity (not persisted yet)."""
        return self.id is None