Initial commit

This commit is contained in:
shahzeydyfah
2024-02-15 00:17:51 +03:30
commit 4b0396466d
111 changed files with 6296 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
from uuid import UUID
from app.models.customer import CustomerModel
from auth.models import UserInDB
from auth.utils.mongo import use_auth_collection
async def get_user_by_username(username: str) -> UserInDB:
"""
Retrieves user from the database by username.
"""
result = await use_auth_collection('users').find_one({'username': username})
return UserInDB(**result) if result else None
async def get_customer_by_username(username: str) -> UserInDB:
"""
Retrieves user from the database by username.
"""
result = await use_auth_collection('customer').find_one({'$or': [{'username': username}, {'mobile': username}]})
return UserInDB(**result) if result else None
async def get_user_by_id(user_id: str) -> UserInDB | None:
"""
Retrieves user from the database by username.
"""
try:
uuid = UUID(str(user_id))
except ValueError:
return None
result = await use_auth_collection('users').find_one({'_id': uuid})
return UserInDB(**result) if result else None
async def get_customer_by_id(customer_id: str) -> UserInDB | None:
"""
Retrieves user from the database by username.
"""
try:
uuid = UUID(str(customer_id))
except ValueError:
return None
result = await use_auth_collection('customer').find_one({'_id': uuid})
return CustomerModel(**result) if result else None
+36
View File
@@ -0,0 +1,36 @@
from typing import List, Optional
from core.models.base import BaseModel
class RouteMeta(BaseModel):
orderNo: int
title: str
ignoreAuth: Optional[bool]
roles: Optional[List[str]]
ignoreKeepAlive: Optional[bool]
affix: Optional[bool]
icon: Optional[str]
frameSrc: Optional[str]
transitionName: Optional[str]
hideBreadcrumb: Optional[bool]
hideChildrenInMenu: Optional[bool]
carryParam: Optional[bool]
single: Optional[bool]
currentActiveMenu: Optional[str]
hideTab: Optional[bool]
hideMenu: Optional[bool]
isLink: Optional[bool]
ignoreRoute: Optional[bool]
hidePathForChildren: Optional[bool]
class VueRouteNative(BaseModel):
name: str
meta: RouteMeta
props: Optional[dict]
fullPath: Optional[str]
class VueRoute(VueRouteNative):
children: List[VueRouteNative]
View File