bug fix
This commit is contained in:
parent
d48ec86026
commit
281cce59f2
|
|
@ -35,13 +35,21 @@ def log_change(
|
||||||
req_id: Optional[int] = None,
|
req_id: Optional[int] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""统一变更历史记录入口,持久化到数据库。"""
|
"""统一变更历史记录入口,持久化到数据库。"""
|
||||||
|
# 将所有业务字段打包进 changes(Text 列)
|
||||||
|
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(
|
history = ChangeHistory(
|
||||||
project_id = project_id,
|
project_id = project_id,
|
||||||
change_type = change_type,
|
changes = changes_text,
|
||||||
module = module,
|
status = "created",
|
||||||
req_id = req_id,
|
|
||||||
changes = summary,
|
|
||||||
created_at = datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
|
||||||
)
|
)
|
||||||
db.create_change_history(history)
|
db.create_change_history(history)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue