aiteamutils 0.2.79__tar.gz → 0.2.80__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/PKG-INFO +1 -1
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/aiteamutils/base_repository.py +3 -3
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/aiteamutils/base_service.py +1 -19
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/aiteamutils/database.py +6 -4
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/aiteamutils/exceptions.py +2 -0
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/aiteamutils/security.py +4 -4
- aiteamutils-0.2.80/aiteamutils/version.py +2 -0
- aiteamutils-0.2.79/aiteamutils/version.py +0 -2
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/.cursorrules +0 -0
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/.gitignore +0 -0
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/README.md +0 -0
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/aiteamutils/__init__.py +0 -0
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/aiteamutils/base_model.py +0 -0
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/aiteamutils/cache.py +0 -0
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/aiteamutils/config.py +0 -0
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/aiteamutils/enums.py +0 -0
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/aiteamutils/validators.py +0 -0
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/pyproject.toml +0 -0
- {aiteamutils-0.2.79 → aiteamutils-0.2.80}/setup.py +0 -0
@@ -79,13 +79,13 @@ class BaseRepository(Generic[ModelType]):
|
|
79
79
|
async def delete(
|
80
80
|
self,
|
81
81
|
conditions: Dict[str, Any]
|
82
|
-
) ->
|
82
|
+
) -> bool:
|
83
83
|
await delete_entity(
|
84
84
|
session=self.session,
|
85
85
|
model=self.model,
|
86
86
|
conditions=conditions
|
87
87
|
)
|
88
|
-
|
88
|
+
return True
|
89
89
|
#########################
|
90
90
|
# 조회 및 검색 메서드 #
|
91
91
|
#########################
|
@@ -93,7 +93,7 @@ class BaseRepository(Generic[ModelType]):
|
|
93
93
|
self,
|
94
94
|
skip: int = 0,
|
95
95
|
limit: int = 100,
|
96
|
-
filters: Optional[Dict[str, Any]] = None,
|
96
|
+
filters: Optional[List[Dict[str, Any]]] = None,
|
97
97
|
explicit_joins: Optional[List[Any]] = None,
|
98
98
|
loading_joins: Optional[List[Any]] = None
|
99
99
|
) -> List[ModelType]:
|
@@ -125,7 +125,7 @@ class BaseService(Generic[ModelType]):
|
|
125
125
|
self,
|
126
126
|
ulid: str | None = None,
|
127
127
|
conditions: Dict[str, Any] | None = None
|
128
|
-
) ->
|
128
|
+
) -> bool:
|
129
129
|
try:
|
130
130
|
if not ULID.from_str(ulid):
|
131
131
|
raise CustomException(
|
@@ -168,29 +168,11 @@ class BaseService(Generic[ModelType]):
|
|
168
168
|
skip: int = 0,
|
169
169
|
limit: int = 100,
|
170
170
|
filters: List[Dict[str, Any]] | None = None,
|
171
|
-
model_name: str | None = None,
|
172
171
|
response_model: Any = None,
|
173
172
|
explicit_joins: Optional[List[Any]] = None,
|
174
173
|
loading_joins: Optional[List[Any]] = None
|
175
174
|
) -> List[Dict[str, Any]]:
|
176
175
|
try:
|
177
|
-
# 모델 이름을 통한 동적 처리
|
178
|
-
if model_name:
|
179
|
-
if model_name not in self.additional_models:
|
180
|
-
raise CustomException(
|
181
|
-
ErrorCode.INVALID_REQUEST,
|
182
|
-
detail=f"Model {model_name} not registered",
|
183
|
-
source_function=f"{self.__class__.__name__}.list"
|
184
|
-
)
|
185
|
-
model = self.additional_models[model_name]
|
186
|
-
entities = await self.repository.list(
|
187
|
-
skip=skip,
|
188
|
-
limit=limit,
|
189
|
-
filters=filters,
|
190
|
-
model=model
|
191
|
-
)
|
192
|
-
return [process_response(entity, response_model) for entity in entities]
|
193
|
-
|
194
176
|
entities = await self.repository.list(
|
195
177
|
skip=skip,
|
196
178
|
limit=limit,
|
@@ -364,7 +364,7 @@ async def delete_entity(
|
|
364
364
|
session: AsyncSession,
|
365
365
|
model: Type[ModelType],
|
366
366
|
conditions: Dict[str, Any]
|
367
|
-
) ->
|
367
|
+
) -> bool:
|
368
368
|
try:
|
369
369
|
stmt = select(model)
|
370
370
|
for key, value in conditions.items():
|
@@ -386,6 +386,7 @@ async def delete_entity(
|
|
386
386
|
await session.flush()
|
387
387
|
await session.refresh(entity)
|
388
388
|
|
389
|
+
return True
|
389
390
|
except SQLAlchemyError as e:
|
390
391
|
raise CustomException(
|
391
392
|
ErrorCode.DB_DELETE_ERROR,
|
@@ -398,17 +399,18 @@ async def purge_entity(
|
|
398
399
|
session: AsyncSession,
|
399
400
|
model: Type[ModelType],
|
400
401
|
entity: ModelType
|
401
|
-
) ->
|
402
|
+
) -> bool:
|
402
403
|
# 엔티티를 영구 삭제합니다.
|
403
404
|
await session.delete(entity)
|
404
|
-
|
405
|
+
|
406
|
+
return True
|
405
407
|
|
406
408
|
async def list_entities(
|
407
409
|
session: AsyncSession,
|
408
410
|
model: Type[ModelType],
|
409
411
|
skip: int = 0,
|
410
412
|
limit: int = 100,
|
411
|
-
filters: Optional[Dict[str, Any]] = None,
|
413
|
+
filters: Optional[List[Dict[str, Any]]] = None,
|
412
414
|
explicit_joins: Optional[List[Any]] = None,
|
413
415
|
loading_joins: Optional[List[Any]] = None
|
414
416
|
) -> List[Dict[str, Any]]:
|
@@ -74,6 +74,8 @@ class ErrorCode(Enum):
|
|
74
74
|
SERVICE_NOT_REGISTERED = ErrorResponse(5003, "GENERAL_SERVICE_UNAVAILABLE", 503, "서비스를 사용할 수 없습니다")
|
75
75
|
LOGIN_ERROR = ErrorResponse(5004, "LOGIN_ERROR", 401, "로그인 오류")
|
76
76
|
TOKEN_ERROR = ErrorResponse(5005, "TOKEN_ERROR", 401, "토큰 오류")
|
77
|
+
DELETE_ERROR = ErrorResponse(5006, "DELETE_ERROR", 400, "삭제 오류")
|
78
|
+
|
77
79
|
|
78
80
|
class CustomException(Exception):
|
79
81
|
"""사용자 정의 예외 클래스"""
|
@@ -162,10 +162,10 @@ async def create_jwt_token(
|
|
162
162
|
"token_type": token_type,
|
163
163
|
|
164
164
|
# 조직 관련 클레임
|
165
|
-
"organization_ulid": user_data.role.organization.ulid,
|
166
|
-
"organization_id": user_data.role.organization.id,
|
167
|
-
"organization_name": user_data.role.organization.name,
|
168
|
-
"company_name": user_data.role.organization.company.name
|
165
|
+
"organization_ulid": user_data.role.team.organization.ulid,
|
166
|
+
"organization_id": user_data.role.team.organization.id,
|
167
|
+
"organization_name": user_data.role.team.organization.name,
|
168
|
+
"company_name": user_data.role.team.organization.company.name
|
169
169
|
}
|
170
170
|
else: # refresh token
|
171
171
|
expires_at = datetime.now(timezone.utc) + timedelta(days=14)
|
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
|