refactor(backend): 重构后端admin和schedule部分
This commit is contained in:
1 parent
9f5493185d
commit
4a14960e01
74 files changed
+5937
-3644
No files matched your search
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
backend/app/services/schedule/serialization.py
|
||||
|
||||
用途:排程域 JSON 序列化辅助(SQL 预览、测试跑结果)。
|
||||
依赖:标准库 decimal/datetime。
|
||||
逻辑:api/schedule/common 与 test_run_service 共用;不依赖 api 层。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import decimal
|
||||
from datetime import date, datetime, timedelta
|
||||
|
||||
|
||||
def safe_json_value(value):
|
||||
"""将 SQL 查询结果中的 Decimal/datetime 转为 JSON 可序列化类型。"""
|
||||
if isinstance(value, decimal.Decimal):
|
||||
return float(value)
|
||||
if isinstance(value, (date, datetime)):
|
||||
return value.isoformat()
|
||||
if isinstance(value, timedelta):
|
||||
return str(value)
|
||||
return value
|
||||
Reference in new issue
Block a user