aiteamutils 0.2.19__tar.gz → 0.2.20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/PKG-INFO +1 -1
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/database.py +12 -4
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/dependencies.py +3 -1
- aiteamutils-0.2.20/aiteamutils/version.py +2 -0
- aiteamutils-0.2.19/aiteamutils/version.py +0 -2
- aiteamutils-0.2.19/app/auth/service.py +0 -4
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/.gitignore +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/README.md +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/__init__.py +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/base_model.py +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/base_repository.py +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/base_service.py +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/cache.py +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/config.py +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/enums.py +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/exceptions.py +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/security.py +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/aiteamutils/validators.py +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/pyproject.toml +0 -0
- {aiteamutils-0.2.19 → aiteamutils-0.2.20}/setup.py +0 -0
@@ -85,7 +85,7 @@ class DatabaseService:
|
|
85
85
|
pool_pre_ping=True,
|
86
86
|
poolclass=QueuePool,
|
87
87
|
)
|
88
|
-
self.
|
88
|
+
self.session_factory = sessionmaker(
|
89
89
|
bind=self.engine,
|
90
90
|
class_=AsyncSession,
|
91
91
|
expire_on_commit=False
|
@@ -93,7 +93,11 @@ class DatabaseService:
|
|
93
93
|
self.db = None
|
94
94
|
elif session:
|
95
95
|
self.engine = session.bind
|
96
|
-
self.
|
96
|
+
self.session_factory = sessionmaker(
|
97
|
+
bind=self.engine,
|
98
|
+
class_=AsyncSession,
|
99
|
+
expire_on_commit=False
|
100
|
+
)
|
97
101
|
self.db = session
|
98
102
|
else:
|
99
103
|
raise ValueError("Either db_url or session must be provided")
|
@@ -788,9 +792,13 @@ class DatabaseService:
|
|
788
792
|
CustomException: 데이터베이스 작업 중 오류 발생 시
|
789
793
|
"""
|
790
794
|
try:
|
791
|
-
|
792
|
-
result = await
|
795
|
+
if self.db:
|
796
|
+
result = await self.db.execute(query)
|
793
797
|
return result
|
798
|
+
else:
|
799
|
+
async with self.session_factory() as session:
|
800
|
+
result = await session.execute(query)
|
801
|
+
return result
|
794
802
|
except Exception as e:
|
795
803
|
raise CustomException(
|
796
804
|
ErrorCode.DB_QUERY_ERROR,
|
@@ -2,6 +2,7 @@ from typing import Type, Dict, Tuple, Any, Callable
|
|
2
2
|
from fastapi import Depends, status
|
3
3
|
from fastapi.security import OAuth2PasswordBearer
|
4
4
|
from jose import JWTError, jwt
|
5
|
+
from sqlalchemy.ext.asyncio import AsyncSession
|
5
6
|
|
6
7
|
from .database import DatabaseService, get_database_service
|
7
8
|
from .exceptions import CustomException, ErrorCode
|
@@ -59,7 +60,8 @@ def get_service(name: str):
|
|
59
60
|
Returns:
|
60
61
|
Callable: 서비스 인스턴스를 반환하는 의존성 함수
|
61
62
|
"""
|
62
|
-
def _get_service(
|
63
|
+
def _get_service(db: AsyncSession = Depends(get_db)):
|
64
|
+
db_service = DatabaseService(session=db)
|
63
65
|
repository_class, service_class = service_registry.get(name)
|
64
66
|
repository = repository_class(db_service)
|
65
67
|
return service_class(repository, db_service)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|