feat: referal spec on registration

This commit is contained in:
2026-08-03 10:35:26 +07:00
parent 680c15414c
commit 801014c392
8 changed files with 88 additions and 5 deletions

View File

@@ -24,17 +24,24 @@ class UserRepository:
res = await self.session.execute(stmt)
return res.scalar_one_or_none()
async def get_user_by_ref_code(self, ref_code: str) -> User | None:
stmt = select(User).where(User.referal_code == ref_code)
res = await self.session.execute(stmt)
return res.scalar_one_or_none()
async def create(
self,
*,
username: str | None = None,
hashed_password: str | None = None,
telegram_id: int | None = None,
referal_id: int | None = None,
) -> User:
obj = User(
username=username,
hashed_password=hashed_password,
telegram_id=telegram_id,
referal_id=referal_id,
)
self.session.add(obj)
await self.session.commit()