修复: 灵感 CRUD 工具补齐 + handler 透传 affected(B-260801-01)
This commit is contained in:
@@ -52,8 +52,13 @@ pub fn register(registry: &mut AiToolRegistry, db: &Arc<Database>) {
|
||||
anyhow::bail!("不允许更新字段 '{}'", field);
|
||||
}
|
||||
let repo = df_storage::crud::ProjectRepo::new(&db);
|
||||
repo.update_field(id, field, value).await?;
|
||||
Ok(serde_json::json!({ "id": id, "field": field, "updated": true }))
|
||||
// 透传 affected:0 行(id 不存在 / 已软删)→ updated=false + name 空,
|
||||
// 让 AI 知道 id 不对而非假成功(对齐 update_idea / update_task)。
|
||||
let updated = repo.update_field(id, field, value).await?;
|
||||
// 返回 name 供前端卡片友好展示(对齐 update_task 返 title);update_field 返 bool 不含
|
||||
// record,单独 get_by_id 取 name;0 行时 get_by_id 返 None→name 空,配合 updated:false。
|
||||
let name = repo.get_by_id(id).await?.map(|p| p.name).unwrap_or_default();
|
||||
Ok(serde_json::json!({ "id": id, "name": name, "field": field, "updated": updated }))
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user