Backend: - Add uuid, sync_version, is_deleted fields to all syncable models - Add SyncSettings model for WebDAV configuration (AES-256-GCM encrypted passwords) - Add crypto.py: AES-256-GCM encryption derived from JWT_SECRET via PBKDF2 - Add sync_lock.py: thread-level sync lock with 503 middleware for write blocking - Add webdav.py: WebDAV client using requests (PUT/GET/MKCOL/DELETE) - Add sync_service.py: push/pull/bidirectional merge with LWW conflict resolution - Add sync router with 8 endpoints: config, test, push, pull, sync, status, remote delete - Add UUID backfill for existing records in init_db() - Add SQLAlchemy before_update event to auto-increment sync_version - Register sync middleware to block writes during sync (503) Frontend: - Add sync API client (WebUI/src/api/sync.ts) - Add useSyncStore with config, test, push/pull/sync operations - Add WebDAV config + sync UI in SettingsView - Add 503 status code handling in axios interceptor - Add uuid field to all TypeScript type definitions Scripts: - Add scripts/start.bat and scripts/stop.bat for project management Design doc: docs/plan/webdav-sync-design.md
31 lines
728 B
Python
31 lines
728 B
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
|
|
|
|
class CategoryBase(BaseModel):
|
|
"""分类基础模型"""
|
|
name: str = Field(..., max_length=100)
|
|
color: str = Field(default="#FFB7C5", max_length=20)
|
|
icon: str = Field(default="folder", max_length=50)
|
|
|
|
|
|
class CategoryCreate(CategoryBase):
|
|
"""创建分类请求模型"""
|
|
pass
|
|
|
|
|
|
class CategoryUpdate(BaseModel):
|
|
"""更新分类请求模型"""
|
|
name: str = Field(None, max_length=100)
|
|
color: str = Field(None, max_length=20)
|
|
icon: str = Field(None, max_length=50)
|
|
|
|
|
|
class CategoryResponse(CategoryBase):
|
|
"""分类响应模型"""
|
|
id: int
|
|
uuid: Optional[str] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|