fix(strategy-map): 三处缺陷——D1 完备度/摘要路由先注册(修 /completeness/objectives 422)、D2 连线增删显式 flag_modified(修 DELETE 200 不落库)、D3 拖拽命中改 rect 判定(修窄屏知识面板遮挡导致拖拽失效)
ci/woodpecker/push/main Pipeline was successful
ci/woodpecker/push/main Pipeline was successful
This commit is contained in:
@@ -558,6 +558,8 @@ def add_connection(map_id: int, data: dict, db: Session = Depends(get_db), entit
|
||||
"label": data.get("label", ""),
|
||||
})
|
||||
m.canvas_data["connections"] = conns
|
||||
from sqlalchemy.orm.attributes import flag_modified
|
||||
flag_modified(m, "canvas_data") # 同上:JSON 列需显式标脏才能落库
|
||||
db.commit()
|
||||
# updated_at: 供前端采纳为新基准(并发保护 base_updated_at),避免自伤 409
|
||||
return {"connections": conns, "updated_at": _stamp(m.updated_at)}
|
||||
@@ -580,6 +582,10 @@ def delete_connection_by_key(map_id: int, data: dict, db: Session = Depends(get_
|
||||
raise HTTPException(404, "连线不存在")
|
||||
|
||||
m.canvas_data["connections"] = new_conns
|
||||
# JSON 列就地/换列表赋值不会被 ORM 自动标记为 dirty ⇒ 必须显式 flag_modified,
|
||||
# 否则接口返回 200 且响应列表已减 1,但 commit 不 flush,重读仍是旧值(删连线变哑弹)。
|
||||
from sqlalchemy.orm.attributes import flag_modified
|
||||
flag_modified(m, "canvas_data")
|
||||
db.commit()
|
||||
return {"connections": new_conns, "removed": {"from": from_id, "to": to_id},
|
||||
"updated_at": _stamp(m.updated_at)}
|
||||
|
||||
Reference in New Issue
Block a user