aiteamutils 0.2.66__tar.gz → 0.2.69__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/PKG-INFO +1 -1
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/aiteamutils/base_repository.py +21 -9
- aiteamutils-0.2.69/aiteamutils/base_service.py +0 -0
- aiteamutils-0.2.69/aiteamutils/version.py +2 -0
- aiteamutils-0.2.66/aiteamutils/base_service.py +0 -78
- aiteamutils-0.2.66/aiteamutils/version.py +0 -2
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/.cursorrules +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/.gitignore +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/README.md +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/aiteamutils/__init__.py +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/aiteamutils/base_model.py +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/aiteamutils/cache.py +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/aiteamutils/config.py +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/aiteamutils/database.py +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/aiteamutils/enums.py +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/aiteamutils/exceptions.py +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/aiteamutils/security.py +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/aiteamutils/validators.py +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/pyproject.toml +0 -0
- {aiteamutils-0.2.66 → aiteamutils-0.2.69}/setup.py +0 -0
@@ -40,12 +40,24 @@ class BaseRepository(Generic[ModelType]):
|
|
40
40
|
"""
|
41
41
|
엔티티 목록 조회.
|
42
42
|
"""
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
try:
|
44
|
+
# 기본 CRUD 작업 호출
|
45
|
+
return await list_entities(
|
46
|
+
session=self.session,
|
47
|
+
model=self.model,
|
48
|
+
skip=skip,
|
49
|
+
limit=limit,
|
50
|
+
filters=filters,
|
51
|
+
joins=joins,
|
52
|
+
)
|
53
|
+
except CustomException as e:
|
54
|
+
e.detail = f"Repository list error for {self.model.__tablename__}: {e.detail}"
|
55
|
+
e.source_function = f"{self.__class__.__name__}.list -> {e.source_function}"
|
56
|
+
raise e
|
57
|
+
except Exception as e:
|
58
|
+
raise CustomException(
|
59
|
+
ErrorCode.INTERNAL_ERROR,
|
60
|
+
detail=str(e),
|
61
|
+
source_function=f"{self.__class__.__name__}.list",
|
62
|
+
original_error=e
|
63
|
+
)
|
File without changes
|
@@ -1,78 +0,0 @@
|
|
1
|
-
#기본 라이브러리
|
2
|
-
from fastapi import Request
|
3
|
-
from typing import TypeVar, Generic, Type, Dict, Any, Union, List
|
4
|
-
from sqlalchemy.orm import DeclarativeBase
|
5
|
-
from sqlalchemy.ext.asyncio import AsyncSession
|
6
|
-
from datetime import datetime
|
7
|
-
|
8
|
-
#패키지 라이브러리
|
9
|
-
from .exceptions import ErrorCode, CustomException
|
10
|
-
from .base_repository import BaseRepository
|
11
|
-
from .database import (
|
12
|
-
process_response,
|
13
|
-
build_search_filters
|
14
|
-
)
|
15
|
-
|
16
|
-
ModelType = TypeVar("ModelType", bound=DeclarativeBase)
|
17
|
-
|
18
|
-
class BaseService(Generic[ModelType]):
|
19
|
-
##################
|
20
|
-
# 1. 초기화 영역 #
|
21
|
-
##################
|
22
|
-
def __init__(
|
23
|
-
self,
|
24
|
-
model: Type[ModelType],
|
25
|
-
repository: BaseRepository[ModelType],
|
26
|
-
db_session: AsyncSession,
|
27
|
-
additional_models: Dict[str, Type[DeclarativeBase]] = None,
|
28
|
-
):
|
29
|
-
self.model = model
|
30
|
-
self.repository = repository
|
31
|
-
self.db_session = db_session
|
32
|
-
self.additional_models = additional_models or {},
|
33
|
-
|
34
|
-
async def list(
|
35
|
-
self,
|
36
|
-
skip: int = 0,
|
37
|
-
limit: int = 100,
|
38
|
-
filters: Dict[str, Any] | None = None,
|
39
|
-
search_params: Dict[str, Any] | None = None,
|
40
|
-
model_name: str | None = None,
|
41
|
-
request: Request | None = None,
|
42
|
-
response_model: Any = None
|
43
|
-
) -> List[Dict[str, Any]]:
|
44
|
-
try:
|
45
|
-
# 검색 조건 처리 및 필터 병합
|
46
|
-
if search_params:
|
47
|
-
search_filters = build_search_filters(request, search_params)
|
48
|
-
if filters:
|
49
|
-
# 기존 filters와 search_filters 병합 (search_filters가 우선 적용)
|
50
|
-
filters.update(search_filters)
|
51
|
-
else:
|
52
|
-
filters = search_filters
|
53
|
-
|
54
|
-
# 모델 이름을 통한 동적 처리
|
55
|
-
if model_name:
|
56
|
-
if model_name not in self.additional_models:
|
57
|
-
raise CustomException(
|
58
|
-
ErrorCode.INVALID_REQUEST,
|
59
|
-
detail=f"Model {model_name} not registered",
|
60
|
-
source_function=f"{self.__class__.__name__}.list"
|
61
|
-
)
|
62
|
-
model = self.additional_models[model_name]
|
63
|
-
return await self.repository.list(skip=skip, limit=limit, filters=filters, model=model)
|
64
|
-
|
65
|
-
return await self.repository.list(skip=skip, limit=limit, filters=filters)
|
66
|
-
except CustomException as e:
|
67
|
-
e.detail = f"Service list error for {self.repository.model.__tablename__}: {e.detail}"
|
68
|
-
e.source_function = f"{self.__class__.__name__}.list -> {e.source_function}"
|
69
|
-
raise e
|
70
|
-
except Exception as e:
|
71
|
-
raise CustomException(
|
72
|
-
ErrorCode.INTERNAL_ERROR,
|
73
|
-
detail=str(e),
|
74
|
-
source_function=f"{self.__class__.__name__}.list",
|
75
|
-
original_error=e
|
76
|
-
)
|
77
|
-
|
78
|
-
|
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
|