feat: add import

This commit is contained in:
2026-06-04 18:09:06 +03:00
parent 62a48c3f70
commit aabea07293
8 changed files with 21 additions and 19 deletions

View File

@@ -12,7 +12,7 @@ from src.infrastructure.database.models.mixins import AuditTimestampsMixin, Ulid
class AdminUserModel(Base, UlidPrimaryKeyMixin, AuditTimestampsMixin):
__tablename__ = 'admin_users'
email: Mapped[str] = mapped_column(String(255), nullable=False, unique=True, index=True)
login: Mapped[str] = mapped_column(String(255), nullable=False, unique=True, index=True)
password_hash: Mapped[str] = mapped_column(String(255), nullable=False)
first_name: Mapped[str | None] = mapped_column(String(128), nullable=True)
last_name: Mapped[str | None] = mapped_column(String(128), nullable=True)

View File

@@ -22,7 +22,7 @@ class AdminUserRepository(IAdminUserRepository):
def _to_entity(self, m: AdminUserModel) -> AdminUserEntity:
return AdminUserEntity(
id=m.id,
email=m.email,
login=m.login,
password_hash=m.password_hash,
first_name=m.first_name,
last_name=m.last_name,
@@ -33,9 +33,9 @@ class AdminUserRepository(IAdminUserRepository):
updated_at=m.updated_at,
)
async def get_by_email(self, email: str) -> AdminUserEntity:
async def get_by_login(self, login: str) -> AdminUserEntity:
try:
stmt = select(AdminUserModel).where(func.lower(AdminUserModel.email) == email.lower())
stmt = select(AdminUserModel).where(func.lower(AdminUserModel.login) == login.lower())
result = await self._session.execute(stmt)
user = result.scalar_one_or_none()
if user is None: