Files
xiaoxia-saas/packages/application/asset_libraries.py
xiaoxia 0422967229 refactor: Remove workspace concept - Projects now directly under User
BREAKING CHANGES:
- Removed Workspace, WorkspaceMember, WorkspaceInvitation entities
- Project now has owner_user_id instead of workspace_id
- Added shared_users list to Project for collaboration
- Subscription/quota moved from Workspace to User level

Changes:
- packages/domain/entities.py: Removed Workspace entities, updated Project
- packages/adapters/sqlalchemy_impl/models.py: Updated models
- packages/application/: Removed workspace use cases, updated other use cases
- packages/ports/: Removed workspace repository interfaces
- apps/api/: Updated routes, schemas, dependencies, router
- alembic/versions/007_remove_workspace_concept.py: Database migration

New APIs:
- POST /projects/{id}/share: Share project with user
- DELETE /projects/{id}/share/{user_id}: Unshare project
2026-06-26 19:16:54 +08:00

37 lines
1.2 KiB
Python

from __future__ import annotations
from dataclasses import dataclass
from packages.domain import AssetLibrary, AssetLibraryKind
from packages.ports.asset_library_repository import AssetLibraryRepository
@dataclass(slots=True)
class CreateAssetLibraryCommand:
project_id: str
name: str
kind: AssetLibraryKind
class ListAssetLibrariesUseCase:
def __init__(self, asset_library_repository: AssetLibraryRepository):
self.asset_library_repository = asset_library_repository
def execute(self, project_id: str) -> list[AssetLibrary]:
if not project_id.strip():
raise ValueError("project_id 不能为空")
return self.asset_library_repository.find_by_project(project_id.strip())
class CreateAssetLibraryUseCase:
def __init__(self, asset_library_repository: AssetLibraryRepository):
self.asset_library_repository = asset_library_repository
def execute(self, command: CreateAssetLibraryCommand) -> AssetLibrary:
library = AssetLibrary.create(
project_id=command.project_id,
name=command.name,
kind=command.kind,
)
return self.asset_library_repository.create(library)