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