Files
Genarrative/docs/technical/WORK_AUTHOR_ID_RESOLUTION_2026-04-30.md
2026-04-30 17:49:07 +08:00

43 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 作品作者按用户 ID 解析设计 2026-04-30
## 背景
作品列表、公开广场和详情页需要展示作者信息。旧链路里部分作品表会同时写入 `author_display_name`,如果用户后续修改昵称,旧作品仍会显示发布时的昵称快照,造成作者信息不一致。
## 目标
1. 作品作者的真相源统一使用 `owner_user_id`
2. API 返回作品读模型时,通过 `owner_user_id` 读取账号公开资料,并使用最新 `display_name` 作为 `authorDisplayName`
3. `author_display_name` 暂时保留为历史兼容字段,只在用户资料不存在或读取失败时作为回退值。
4. 前端详情页优先展示按 `ownerUserId` 读取到的公开用户资料;作品字段里的作者名只作为兜底展示。
## 落地规则
### SpacetimeDB 存储
1. `custom_world_profile.owner_user_id` / `custom_world_gallery_entry.owner_user_id` 是 RPG 作品作者 ID。
2. `puzzle_work_profile.owner_user_id` 是拼图作品作者 ID。
3. `big_fish_creation_session.owner_user_id` 是大鱼吃小鱼作品作者 ID。
4. 现有 `author_display_name` 不再作为作者真相源,不新增依赖它做权限、同作者推荐或作者资料展示的逻辑。
5. 本次不删除 `author_display_name`,避免破坏历史迁移包、生成绑定和旧客户端兼容;后续若要删除,必须单独做 schema 迁移和绑定刷新。
### API facade
1. 输出 `authorDisplayName` 时先用 `owner_user_id` 查询认证用户表。
2. 查询成功时使用用户最新 `display_name`,并同步补齐 `public_user_code`
3. 查询失败或用户缺失时才回退作品表旧 `author_display_name`
4. 大鱼吃小鱼公开作品不再由前端硬编码作者名API 根据 `owner_user_id` 输出作者显示名。
### 前端
1. 统一作品详情页已按 `ownerUserId` 读取公开用户摘要,用于头像和作者名。
2. 详情页展示作者名时优先使用公开用户摘要的 `displayName`,缺失时回退作品读模型的 `authorDisplayName`
3. 新增作品类型接入平台详情页时,不允许只在前端写固定作者昵称。
## 验收点
1. 用户修改昵称后RPG / 拼图 / 大鱼公开作品列表与详情页能展示新昵称。
2. 旧作品缺少可读取用户资料时,仍能用历史 `author_display_name` 或“玩家”兜底。
3. 作品权限和“同作者”判断继续使用 `owner_user_id`
4. 本次不改变 SpacetimeDB 表结构,因此不需要调整 `migration.rs` 白名单或导入补字段逻辑。