feat: referal spec on registration
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user