feat: add workspace

This commit is contained in:
Artem Tsyrulnikov
2025-12-13 22:09:55 +03:00
parent 2fdd56c3e0
commit af32e2a507
55 changed files with 677 additions and 227 deletions

View File

@@ -0,0 +1,28 @@
import uuid
from typing import TYPE_CHECKING
from src import domain, dto
if TYPE_CHECKING:
from .. import Usecase
async def create_workspace(
self: 'Usecase', user_id: uuid.UUID, input: dto.CreateWorkspaceInput
) -> dto.CreateWorkspaceOutput:
user = await self.database.get_user(user_id=user_id)
if not user:
raise domain.UserNotFound(user_id)
workspace = domain.Workspace(
name=input.name,
)
async with self.database.transaction():
await self.database.create_workspace(workspace)
await self.database.add_user_to_workspace(workspace.id, user_id)
return dto.CreateWorkspaceOutput(
id=workspace.id,
name=workspace.name,
)