Files
persionalBrand/docs/brand-runtime-multitenancy-plan.md

59 lines
2.9 KiB
Markdown
Raw Permalink 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.
# 品牌运行时与多品牌隔离推进计划
## 目标
个人品牌是产品主线,行业模板、视觉模板和能力插件都必须在品牌隔离的运行时上下文中工作。Admin 与小程序不得维护第二套实时品牌数据。
## 当前结论
- 数据模型已经普遍包含 `brandId`,但 Admin 运行时仍依赖 `DEFAULT_BRAND_ID`,当前属于单品牌运行模式。
- `BrandProfile` 及其品牌业务表应是实时品牌内容的唯一来源。
- `BrandTemplateInstallation.configSnapshot` 仅用于模板版本、升级和回滚,不得覆盖实时品牌内容。
- `RuntimeWorkspace` 是 Admin 和小程序统一消费的读取契约。
- 小程序静态数据只能作为按模板选择的离线 fallback,不能覆盖成功的 API 返回。
## 阶段
### Phase 1:统一品牌运行时数据
- Admin 页面统一通过 `/admin/workspace` 获取运行时数据。
- 小程序页面移除直接读取行业静态数据的路径。
- fallback 按 `personal`、`food`、`doors` 模板拆分。
- 页面不再直接读取 `linjing-data.js` 作为实时业务来源。
- `/public/workspace` 返回已发布信任内容,供 Admin 与小程序统一消费。
- API 成功时不允许 fallback 覆盖 API 数据。
- 增加三模板数据一致性和 API 失败 fallback 测试。
### Phase 2:品牌上下文与权限隔离
- 增加 `AdminUser`、`BrandMembership` 和角色模型。
- 从 token 与 membership 解析可信当前品牌,不再依赖 `DEFAULT_BRAND_ID`。
- 所有 Admin 查询、写入、删除强制使用服务端品牌上下文。
- 增加跨品牌越权集成测试。
- [x] `BrandMembership`、管理员品牌 token 和全局 Admin membership guard 已完成。
- [x] Workspace、配置、预约、能力、模板和信任内容接口均按品牌上下文隔离。
### Phase 3:公开品牌解析与缓存隔离
- 生产环境支持 `brandSlug` 或 `appId -> brandId` 解析。
- Runtime Workspace 缓存按品牌和版本隔离。
- 公开接口只返回当前品牌已发布内容。
- [x] `BrandProfile.slug` 和 `/public/workspace?brandSlug=` 已完成。
- [x] 无效品牌 slug 返回 404,Runtime Workspace 缓存按 brandId 隔离。
### Phase 4:行业能力扩展
- 在前 3 个阶段通过验收前,不新增行业专属页面。
- 后续行业差异继续通过模板、模块、能力插件和声明式字段表达。
- [x] `personal`、`food`、`doors` 三模板均通过结构、内容和视觉 fixture 验收。
- [x] 门窗示例内容支持预览、幂等导入和审计。
- [x] 注册通用 `quote-request` 能力插件,可由品牌独立启用,不绑定行业模板。
## 交付门槛
- API integration tests 通过。
- Admin production build 通过。
- 小程序结构和视觉 fixture 通过。
- personal、food、doors 不得出现跨行业文案、字段或业务数据污染。
- 每个完成阶段使用一个完整、可审查的提交收口。