Files
xiaoxia-saas/packages/ports/project_repository.py
T
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

43 lines
1.0 KiB
Python

"""
Project 仓储接口
"""
from abc import ABC, abstractmethod
from typing import Optional
from packages.domain.entities import Project
class ProjectRepository(ABC):
"""Project 仓储接口"""
@abstractmethod
def save(self, project: Project) -> None:
"""保存项目"""
pass
@abstractmethod
def find_by_id(self, project_id: str) -> Optional[Project]:
"""根据 ID 查找项目"""
pass
@abstractmethod
def find_by_owner_user_id(self, owner_user_id: str) -> list[Project]:
"""根据所有者用户 ID 查找项目"""
pass
@abstractmethod
def find_accessible_projects(self, user_id: str) -> list[Project]:
"""查找用户可访问的所有项目(自己拥有的 + 被共享的)"""
pass
@abstractmethod
def count_by_owner(self, owner_user_id: str) -> int:
"""统计用户的项目数量"""
pass
@abstractmethod
def delete(self, project_id: str) -> bool:
"""删除项目"""
pass