Files
xiaoxia-saas/packages/domain/asset_library.py
T
Xiaoxia AI ebcd2ceb63
Deploy / Deploy Staging (push) Failing after 7s
Deploy / Deploy Production (push) Has been skipped
Tests / test (push) Failing after 21s
Tests / lint (push) Failing after 20s
Phase 6: Complete admin pages (Analytics, Monitor, Logs) and Phase 7: Asset management foundation
Phase 6 completion:
- Add Analytics page with charts (user growth, revenue, retention)
- Add SystemMonitor page (CPU, memory, services health)
- Add LogViewer page (log search, filtering, details)
- Update sidebar navigation with Admin submenu
- Add recharts to package.json for data visualization

Phase 7 Day 1-2:
- Create Asset and AssetLibrary domain entities
- Define AssetRepository and AssetLibraryRepository interfaces
- Implement InMemory repositories for testing
- Implement PostgreSQL repository adapter
- Update SQLAlchemy models for assets and asset_libraries
- Add database migration script 004_asset_management.sql

Architecture: Strict Clean Architecture compliance
Testing: InMemory adapters ready for unit tests
Database: Migration script with indexes and foreign keys
2026-06-17 17:41:48 +08:00

53 lines
1.4 KiB
Python

"""
AssetLibrary 实体 - 素材库
"""
from datetime import datetime
from enum import Enum
class LibraryKind(str, Enum):
"""素材库类型"""
VIDEO = "video"
VOICE = "voice"
IMAGE = "image"
class AssetLibrary:
"""素材库实体"""
def __init__(
self,
id: str,
workspace_id: str,
name: str,
kind: LibraryKind,
project_id: str = None,
asset_count: int = 0,
total_size: int = 0,
created_at: datetime = None,
updated_at: datetime = None,
):
self.id = id
self.workspace_id = workspace_id
self.project_id = project_id
self.name = name
self.kind = kind
self.asset_count = asset_count
self.total_size = total_size
self.created_at = created_at or datetime.utcnow()
self.updated_at = updated_at or datetime.utcnow()
def to_dict(self) -> dict:
"""转换为字典"""
return {
"id": self.id,
"workspace_id": self.workspace_id,
"project_id": self.project_id,
"name": self.name,
"kind": self.kind.value,
"asset_count": self.asset_count,
"total_size": self.total_size,
"created_at": self.created_at.isoformat() if self.created_at else None,
"updated_at": self.updated_at.isoformat() if self.updated_at else None,
}