RENAME_CONTENT_TO_RESOURCE.md 1.9 KB

Content → Resource 重命名总结

重命名原因

避免与Knowledge表的content字段混淆,提高命名清晰度。

已完成的修改

1. 数据库

  • ✅ 表名:contentsresources

2. 代码 (knowhub/server.py)

  • ✅ 模型:ContentInResourceIn
  • ✅ 模型:ContentOutResourceOut
  • ✅ 模型:ContentPatchInResourcePatchIn
  • ✅ 模型:ContentNodeResourceNode
  • ✅ 函数:submit_contentsubmit_resource
  • ✅ 函数:get_contentget_resource
  • ✅ 函数:patch_contentpatch_resource
  • ✅ 函数:list_contentslist_resources
  • ✅ 函数:encrypt_contentencrypt_resource
  • ✅ 函数:decrypt_contentdecrypt_resource
  • ✅ 参数:content_idresource_id
  • ✅ API路径:/api/content/api/resource

3. 文档

  • knowhub/docs/content-storage.mdresource-storage.md
  • knowhub/docs/content-storage-examples.mdresource-storage-examples.md
  • ✅ 更新 knowhub/docs/knowledge-management.md
  • ✅ 更新 knowhub/docs/decisions.md

4. 测试和工具

  • ✅ 测试脚本:test_resource_storage.py
  • ✅ 实现总结:RESOURCE_STORAGE_IMPLEMENTATION.md

API端点变更

旧端点 新端点
POST /api/content POST /api/resource
GET /api/content/{content_id} GET /api/resource/{resource_id}
PATCH /api/content/{content_id} PATCH /api/resource/{resource_id}
GET /api/content GET /api/resource

验证

# 1. 导入测试
python -c "from knowhub.server import app; print('✅ OK')"

# 2. 启动服务
uvicorn knowhub.server:app --reload

# 3. 运行测试
python test_resource_storage.py

注意事项

  • 数据库表已重命名,旧的API端点不再可用
  • 如果有外部系统调用旧API,需要更新
  • 文档中所有引用已更新