This commit is contained in:
sonto.lau 2026-03-07 01:06:05 +08:00
parent d48ec86026
commit 281cce59f2
1 changed files with 13 additions and 5 deletions

View File

@ -35,13 +35,21 @@ def log_change(
req_id: Optional[int] = None,
) -> None:
"""统一变更历史记录入口,持久化到数据库。"""
# 将所有业务字段打包进 changesText 列)
changes_payload = {
"change_type": change_type,
"module": module,
"req_id": req_id,
"summary": summary,
"logged_at": datetime.utcnow().isoformat(),
}
changes_text = json.dumps(changes_payload, ensure_ascii=False, indent=2)
# ✅ 只传 ChangeHistory 模型真实存在的字段
history = ChangeHistory(
project_id = project_id,
change_type = change_type,
module = module,
req_id = req_id,
changes = summary,
created_at = datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
changes = changes_text,
status = "created",
)
db.create_change_history(history)