tenant/README.md
yumoqing d8eea22b89 feat: tenant 多租户域名管理模块
- tenant_domain 表: domain → resellerid 映射, UNIQUE(domain)
- init.py: get_domain_by_host() 根据域名查找分销商
- index.ui: Tabular CRUD 管理界面
- load_path.py: RBAC 权限注册
2026-06-30 15:35:08 +08:00

42 lines
1.4 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.

# Tenant 模块
多租户域名管理。每个分销商可申请独立域名,客户在域名下注册即自动绑定为该分销商的客户。
## 数据模型
### tenant_domain租户域名
| 字段 | 类型 | 说明 |
|------|------|------|
| id | VARCHAR(32) | 主键 |
| domain | VARCHAR(200) | 域名 UNIQUE |
| resellerid | VARCHAR(32) | 分销商机构ID |
| orgid | VARCHAR(32) | 所属平台机构ID |
| status | VARCHAR(10) | active/inactive |
| created_at | TIMESTAMP | 创建时间 |
| updated_at | TIMESTAMP | 更新时间 |
## 集成点
1. **注册自动绑定**: 用户注册时根据 `request.host` 查询 `tenant_domain` → 找到 `resellerid` → 写入 `discount_customer_bind`
2. **RBAC**: `load_path.py` 注册所有路径
3. **Sage 集成**: 需要在 `app/sage.py` import + load, `build.sh` install loop, `global_menu.ui` menu entry
## DB 迁移
```sql
CREATE TABLE tenant_domain (
id VARCHAR(32) NOT NULL,
domain VARCHAR(200) NOT NULL,
resellerid VARCHAR(32) NOT NULL,
orgid VARCHAR(32) NOT NULL,
status VARCHAR(10) NOT NULL DEFAULT 'active',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE INDEX idx_tenant_domain_domain (domain),
INDEX idx_tenant_domain_reseller (resellerid),
INDEX idx_tenant_domain_orgid (orgid)
);
```