This commit is contained in:
commit
46af290db3
100 files changed
+16663
No files matched your search
@@ -0,0 +1,51 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from uuid import uuid4
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class DocumentNode(BaseModel):
|
||||
"""Иерархическая модель документа: Книга → Глава → Сцена"""
|
||||
|
||||
id: str = Field(default_factory=lambda: str(uuid4()))
|
||||
project_id: str
|
||||
parent_id: Optional[str] = None
|
||||
title: str = Field(..., min_length=1, max_length=200)
|
||||
content: str = ""
|
||||
type: str = Field(default="scene", pattern="^(book|chapter|scene)$")
|
||||
order: int = 0
|
||||
created_at: str = Field(default_factory=lambda: datetime.now().isoformat())
|
||||
updated_at: str = Field(default_factory=lambda: datetime.now().isoformat())
|
||||
|
||||
|
||||
# --- Модели для обратной совместимости (старый плоский формат) ---
|
||||
|
||||
|
||||
class DocumentBase(BaseModel):
|
||||
"""Базовая модель документа (legacy)"""
|
||||
|
||||
title: str = Field(..., min_length=1, max_length=200)
|
||||
content: str = ""
|
||||
type: str = Field(default="scene", pattern="^(scene|chapter|bible)$")
|
||||
|
||||
|
||||
class DocumentCreate(DocumentBase):
|
||||
"""Модель для создания нового документа (legacy)"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class DocumentUpdate(BaseModel):
|
||||
"""Модель для обновления контента документа (legacy)"""
|
||||
|
||||
content: str
|
||||
|
||||
|
||||
class DocumentResponse(DocumentBase):
|
||||
"""Модель ответа с документом (legacy)"""
|
||||
|
||||
id: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Reference in new issue
Block a user