lavkach3
1import uuid2
3from pydantic import BaseModel, UUID4, computed_field4from typing import Optional, List5from sqlalchemy import select6from core.db.session import session7
8#from app.basic.user.models import User
9from core.types import TypeLocale10
11
12class CurrentUser(BaseModel):13user_id: Optional[UUID4] = None14company_ids: Optional[List[UUID4]] = []15company_id: Optional[UUID4] = False16store_id: Optional[UUID4] = False17role_ids: Optional[List[str]] = []18is_admin: Optional[bool] = False19locale: Optional[TypeLocale] = False20nickname: Optional[str] = None21email: Optional[str] = None22
23class Config:24validate_assignment = True25
26@computed_field27@property28def id(self) -> str:29return self.user_id30
31async def get_user_data(self):32query = select(User).where(User.id == self.id)33result = await session.execute(query)34return result.scalars().first()35