bug fix
This commit is contained in:
parent
d48ec86026
commit
281cce59f2
|
|
@ -35,13 +35,21 @@ def log_change(
|
|||
req_id: Optional[int] = 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(
|
||||
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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue