- 重构报销状态注册表、审批流路由与平台风险标记 - 完善管家意图规划器与模型计划构建器全链路 - 新增 OCR Worker 脚本、数据库会话管理与通知状态 - 优化文档中心、日志视图、预算中心与员工管理交互 - 增强工作台摘要、图标资源与全局主题样式 - 补充审批路由、状态注册、OCR 服务与管家规划器测试覆盖
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
|
|
|
|
def _normalize_text(value: Any) -> str:
|
|
return str(value or "").strip()
|
|
|
|
|
|
class NotificationStatePatch(BaseModel):
|
|
notification_id: str = Field(min_length=1, max_length=180)
|
|
read: bool = False
|
|
hidden: bool = False
|
|
context_json: dict[str, Any] = Field(default_factory=dict)
|
|
|
|
@field_validator("notification_id", mode="before")
|
|
@classmethod
|
|
def normalize_notification_id(cls, value: Any) -> str:
|
|
return _normalize_text(value)
|
|
|
|
@field_validator("context_json", mode="before")
|
|
@classmethod
|
|
def normalize_context(cls, value: Any) -> dict[str, Any]:
|
|
return value if isinstance(value, dict) else {}
|
|
|
|
|
|
class NotificationStateBatchPatch(BaseModel):
|
|
states: list[NotificationStatePatch] = Field(default_factory=list, max_length=500)
|
|
|
|
|
|
class NotificationStateRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
notification_id: str
|
|
read_at: datetime | None
|
|
hidden_at: datetime | None
|
|
context_json: dict[str, Any]
|
|
updated_at: datetime
|
|
|
|
|
|
class NotificationStateListRead(BaseModel):
|
|
states: list[NotificationStateRead] = Field(default_factory=list)
|