aiteamutils 0.2.159__py3-none-any.whl → 0.2.160__py3-none-any.whl
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/base_service.py
CHANGED
@@ -37,7 +37,7 @@ class BaseService(Generic[ModelType]):
|
|
37
37
|
self.additional_models = additional_models or {},
|
38
38
|
|
39
39
|
#######################
|
40
|
-
#
|
40
|
+
# 파일 관련 메서드 #
|
41
41
|
#######################
|
42
42
|
async def _separate_file_data(
|
43
43
|
self,
|
@@ -52,7 +52,6 @@ class BaseService(Generic[ModelType]):
|
|
52
52
|
Tuple[Dict[str, Any], Dict[str, Any]]: (파일 제외된 엔티티 데이터, 분리된 파일 데이터)
|
53
53
|
"""
|
54
54
|
try:
|
55
|
-
logger.info("[파일 데이터 분리 시작]")
|
56
55
|
entity_data_copy = entity_data.copy()
|
57
56
|
separated_files = {}
|
58
57
|
|
@@ -62,11 +61,9 @@ class BaseService(Generic[ModelType]):
|
|
62
61
|
|
63
62
|
# 파일 필드 체크 및 분리 (딕셔너리 수정 없이)
|
64
63
|
for field_name, files in extra_data.items():
|
65
|
-
logger.info(f"[필드 검사] 필드명: {field_name}, 타입: {type(files)}")
|
66
64
|
if files and isinstance(files, (list, tuple)):
|
67
65
|
# 파일 객체를 포함하는 튜플/리스트인 경우만 처리
|
68
66
|
if any(isinstance(item, (tuple, list)) and len(item) == 2 and hasattr(item[0], 'read') for item in files):
|
69
|
-
logger.info(f"[파일 필드 발견] {field_name}")
|
70
67
|
separated_files[field_name] = files
|
71
68
|
fields_to_remove.append(field_name)
|
72
69
|
|
@@ -76,11 +73,9 @@ class BaseService(Generic[ModelType]):
|
|
76
73
|
|
77
74
|
entity_data_copy['extra_data'] = extra_data
|
78
75
|
|
79
|
-
logger.info("[파일 데이터 분리 완료]")
|
80
76
|
return entity_data_copy, separated_files
|
81
77
|
|
82
78
|
except Exception as e:
|
83
|
-
logger.error(f"[파일 분리 중 에러 발생] {str(e)}")
|
84
79
|
raise CustomException(
|
85
80
|
ErrorCode.INTERNAL_ERROR,
|
86
81
|
detail=str(e),
|
@@ -112,12 +107,10 @@ class BaseService(Generic[ModelType]):
|
|
112
107
|
source_function=f"{self.__class__.__name__}._save_files"
|
113
108
|
)
|
114
109
|
|
115
|
-
logger.info("[파일 저장 시작]")
|
116
110
|
file_infos = {}
|
117
111
|
from .files import FileHandler
|
118
112
|
|
119
113
|
for field_name, files in separated_files.items():
|
120
|
-
logger.info(f"[필드 처리] {field_name}, 파일 수: {len(files)}")
|
121
114
|
saved_files = await FileHandler.save_files(
|
122
115
|
files=files,
|
123
116
|
storage_dir=storage_dir,
|
@@ -144,15 +137,12 @@ class BaseService(Generic[ModelType]):
|
|
144
137
|
]
|
145
138
|
|
146
139
|
await self.db_session.flush()
|
147
|
-
logger.info("[파일 저장 완료]")
|
148
140
|
return file_infos
|
149
141
|
|
150
142
|
except CustomException as e:
|
151
|
-
logger.error(f"[파일 저장 중 CustomException 발생] {e.error_code}: {e.detail}")
|
152
143
|
await self._cleanup_saved_files(file_infos)
|
153
144
|
raise e
|
154
145
|
except Exception as e:
|
155
|
-
logger.error(f"[파일 저장 중 에러 발생] {str(e)}")
|
156
146
|
await self._cleanup_saved_files(file_infos)
|
157
147
|
raise CustomException(
|
158
148
|
ErrorCode.FILE_SYSTEM_ERROR,
|
@@ -167,7 +157,6 @@ class BaseService(Generic[ModelType]):
|
|
167
157
|
from .files import FileHandler
|
168
158
|
for file_list in file_infos.values():
|
169
159
|
for file_info in file_list:
|
170
|
-
logger.info(f"[에러 복구] 파일 삭제: {file_info['storage_path']}")
|
171
160
|
await FileHandler.delete_files(file_info["storage_path"])
|
172
161
|
|
173
162
|
async def _delete_files(
|
@@ -180,7 +169,6 @@ class BaseService(Generic[ModelType]):
|
|
180
169
|
entity_result (Any): 삭제할 파일이 있는 엔티티
|
181
170
|
"""
|
182
171
|
try:
|
183
|
-
logger.info("[파일 삭제 시작]")
|
184
172
|
from .files import FileHandler
|
185
173
|
|
186
174
|
# files 테이블에서 기존 파일 정보 조회
|
@@ -197,11 +185,9 @@ class BaseService(Generic[ModelType]):
|
|
197
185
|
}
|
198
186
|
)
|
199
187
|
existing_files = existing_files.fetchall()
|
200
|
-
logger.info(f"[기존 파일 조회 결과] {existing_files}")
|
201
188
|
|
202
189
|
# 기존 파일 삭제
|
203
190
|
for file_info in existing_files:
|
204
|
-
logger.info(f"[파일 삭제] {file_info[0]}")
|
205
191
|
await FileHandler.delete_files(file_info[0])
|
206
192
|
|
207
193
|
# files 테이블에서 레코드 삭제
|
@@ -216,10 +202,8 @@ class BaseService(Generic[ModelType]):
|
|
216
202
|
"entity_ulid": entity_result.ulid
|
217
203
|
}
|
218
204
|
)
|
219
|
-
logger.info("[파일 DB 레코드 삭제 완료]")
|
220
205
|
|
221
206
|
except Exception as e:
|
222
|
-
logger.error(f"[파일 삭제 중 에러 발생] {str(e)}")
|
223
207
|
raise CustomException(
|
224
208
|
ErrorCode.FILE_SYSTEM_ERROR,
|
225
209
|
detail=str(e),
|
@@ -227,6 +211,9 @@ class BaseService(Generic[ModelType]):
|
|
227
211
|
original_error=e
|
228
212
|
)
|
229
213
|
|
214
|
+
#######################
|
215
|
+
# 입력 및 수정 메서드 #
|
216
|
+
#######################
|
230
217
|
async def create(
|
231
218
|
self,
|
232
219
|
request: Request,
|
@@ -401,6 +388,9 @@ class BaseService(Generic[ModelType]):
|
|
401
388
|
original_error=e
|
402
389
|
)
|
403
390
|
|
391
|
+
#######################
|
392
|
+
# 삭제 메서드 #
|
393
|
+
#######################
|
404
394
|
async def delete(
|
405
395
|
self,
|
406
396
|
request: Request,
|
aiteamutils/version.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
"""버전 정보"""
|
2
|
-
__version__ = "0.2.
|
2
|
+
__version__ = "0.2.160"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
aiteamutils/__init__.py,sha256=kRBpRjark0M8ZwFfmKiMFol6CbIILN3WE4f6_P6iIq0,1089
|
2
2
|
aiteamutils/base_model.py,sha256=yBZqzTDF9PA4wCAvmYfG12FdVwLtxOEUCcA3z2i6fXU,4176
|
3
3
|
aiteamutils/base_repository.py,sha256=Oy2zE1i5qx60Xf1tnsaKLyFWapiPqt5JH8NejwNrPWg,4647
|
4
|
-
aiteamutils/base_service.py,sha256=
|
4
|
+
aiteamutils/base_service.py,sha256=5YSRpulLI-tO6zQ75LBTsyzYoMzayPITWhE5-8rie3s,21068
|
5
5
|
aiteamutils/cache.py,sha256=07xBGlgAwOTAdY5mnMOQJ5EBxVwe8glVD7DkGEkxCtw,1373
|
6
6
|
aiteamutils/config.py,sha256=YdalpJb70-txhGJAS4aaKglEZAFVWgfzw5BXSWpkUz4,3232
|
7
7
|
aiteamutils/database.py,sha256=msvBKtxWeQVOo0v2Q9i2azuTNtnUItuNNar52gdRZTo,20418
|
@@ -11,7 +11,7 @@ aiteamutils/files.py,sha256=Qq2w3VAEOzvsDirYtxRTN48LnIzf4TPUH2LftmyYtQk,12831
|
|
11
11
|
aiteamutils/models.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
|
12
12
|
aiteamutils/security.py,sha256=McUl3t5Z5SyUDVUHymHdDkYyF4YSeg4g9fFMML4W6Kw,11630
|
13
13
|
aiteamutils/validators.py,sha256=_WHN6jqJQzKM5uPTg-Da8U2qqevS84XeKMkCCF4C_lY,9591
|
14
|
-
aiteamutils/version.py,sha256=
|
15
|
-
aiteamutils-0.2.
|
16
|
-
aiteamutils-0.2.
|
17
|
-
aiteamutils-0.2.
|
14
|
+
aiteamutils/version.py,sha256=Dv_RPFPM_ljwt7FQn4GsgrSYOBxg7SL2-aDSf-jrp30,43
|
15
|
+
aiteamutils-0.2.160.dist-info/METADATA,sha256=-mvX5XwdZbNh-6odVtUghcR6k9YU_P2eOv8XruEj5Gg,1743
|
16
|
+
aiteamutils-0.2.160.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
17
|
+
aiteamutils-0.2.160.dist-info/RECORD,,
|
File without changes
|