GeezerVison is showing github.com — refactor: tenants module uses integer ids · IDTS-LAB/python-codebase@48dce53
File treeExpand file treeCollapse file tree Open diff view settings infrastructure/repositories
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/modules/tenants/domain/entities/tenant.py +3-6Lines changed: 3 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -from uuid import UUID | 2 | | - | 3 | | - | 4 | 1 | class Tenant: | 5 | 2 | def __init__( | 6 | 3 | self, | 7 | | - id: UUID, | 8 | | - name: str, | 9 | | - slug: str, | | 4 | + id: int | None = None, | | 5 | + name: str = "", | | 6 | + slug: str = "", | 10 | 7 | domain: str | None = None, | 11 | 8 | ): | 12 | 9 | self.id = id | |
Collapse file Copy file name to clipboard +1-3Lines changed: 1 addition & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -from uuid import UUID | 2 | | - | 3 | 1 | from src.modules.tenants.domain.entities.tenant import Tenant | 4 | 2 |
| 5 | 3 |
| @@ -8,6 +6,6 @@ async def get_by_slug(self, slug: str) -> Tenant | None: ... | 8 | 6 |
| 9 | 7 | async def get_by_domain(self, domain: str) -> Tenant | None: ... | 10 | 8 |
| 11 | | - async def get_by_id(self, tenant_id: UUID) -> Tenant | None: ... | | 9 | + async def get_by_id(self, tenant_id: int) -> Tenant | None: ... | 12 | 10 |
| 13 | 11 | async def save(self, tenant: Tenant) -> Tenant: ... |
Collapse file Copy file name to clipboardExpand all lines: src/modules/tenants/infrastructure/repositories/tenant_repository.py +2-5Lines changed: 2 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -from uuid import UUID | 2 | | - | 3 | 1 | from sqlalchemy import select | 4 | 2 | from sqlalchemy.ext.asyncio import AsyncSession | 5 | 3 |
| @@ -26,7 +24,7 @@ async def get_by_domain(self, domain: str) -> Tenant | None: | 26 | 24 | model = result.scalar_one_or_none() | 27 | 25 | return self._to_entity(model) if model else None | 28 | 26 |
| 29 | | - async def get_by_id(self, tenant_id: UUID) -> Tenant | None: | | 27 | + async def get_by_id(self, tenant_id: int) -> Tenant | None: | 30 | 28 | result = await self._db.execute( | 31 | 29 | select(TenantModel).where(TenantModel.id == tenant_id) | 32 | 30 | ) | @@ -45,7 +43,6 @@ async def save(self, tenant: Tenant) -> Tenant: | 45 | 43 | model.domain = tenant.domain | 46 | 44 | else: | 47 | 45 | model = TenantModel( | 48 | | - id=tenant.id, | 49 | 46 | name=tenant.name, | 50 | 47 | slug=tenant.slug, | 51 | 48 | domain=tenant.domain, | @@ -56,7 +53,7 @@ async def save(self, tenant: Tenant) -> Tenant: | 56 | 53 | await self._db.refresh(model) | 57 | 54 | return self._to_entity(model) | 58 | 55 |
| 59 | | - async def _get_model(self, tenant_id: UUID) -> TenantModel: | | 56 | + async def _get_model(self, tenant_id: int) -> TenantModel: | 60 | 57 | result = await self._db.execute( | 61 | 58 | select(TenantModel).where(TenantModel.id == tenant_id) | 62 | 59 | ) | |
Collapse file Copy file name to clipboardExpand all lines: src/modules/tenants/presentation/schemas.py +1-3Lines changed: 1 addition & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -from uuid import UUID | 2 | | - | 3 | 1 | from pydantic import BaseModel | 4 | 2 |
| 5 | 3 |
| 6 | 4 | class TenantResponse(BaseModel): | 7 | | - id: UUID | | 5 | + id: int | 8 | 6 | name: str | 9 | 7 | slug: str | 10 | 8 | domain: str | None = None | |
|