pbl_blueprint/pbl_blueprint/json/m1b/pbl_blueprint_template.json
2026-09-16 16:25:33 +08:00

49 lines
4.1 KiB
JSON
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.

{
"table": "pbl_blueprint_template",
"comment": "PBL 蓝图模板(M1b:支持平台公共模板 tenant_id IS NULL;租户私有模板 tenant_id 非空)",
"engine": "InnoDB",
"charset": "utf8mb4",
"multi_tenant": true,
"tenant_policy": {
"column": "tenant_id",
"nullable": true,
"null_meaning": "platform_common",
"read": "租户可见 = (tenant_id = :tenant OR tenant_id IS NULL AND is_public = 1)",
"write": "平台公共模板写操作需 is_platform_admin;租户模板写操作需 tenant_id 匹配",
"fail_closed": true
},
"columns": [
{"name": "id", "type": "varchar(64)", "primary_key": true, "comment": "模板ID tpl-xxxx"},
{"name": "tenant_id", "type": "varchar(64)", "nullable": true, "index": true, "comment": "租户ID;NULL=平台公共模板(Q-OPEN-3 决议:不改 world 表,平台公共数据只落在 pbl_* 自有表)"},
{"name": "code", "type": "varchar(64)", "nullable": false, "comment": "模板编码,租户内唯一;平台公共模板在 tenant_id IS NULL 域内唯一"},
{"name": "name", "type": "varchar(200)", "nullable": false, "comment": "模板名称"},
{"name": "category", "type": "varchar(64)", "nullable": true, "comment": "分类:stem/humanities/interdisciplinary/vocational/custom"},
{"name": "subject_tags", "type": "json", "nullable": true, "comment": "学科标签数组"},
{"name": "grade_range", "type": "varchar(64)", "nullable": true, "comment": "适用学段,如 G4-G6"},
{"name": "duration_hours", "type": "int", "nullable": true, "comment": "建议课时(小时)"},
{"name": "summary", "type": "varchar(1000)", "nullable": true, "comment": "模板简介"},
{"name": "content", "type": "json", "nullable": true, "comment": "模板内容:driving_question/missions/roles/artifacts/assessment 等子对象骨架"},
{"name": "subobject_kinds", "type": "json", "nullable": true, "comment": "模板包含的子对象类型清单(7类泛化契约)"},
{"name": "ext_schema", "type": "json", "nullable": true, "comment": "扩展字段定义(字段名/类型/必填/枚举/默认值),实例化时用于校验"},
{"name": "is_public", "type": "tinyint(1)", "nullable": false, "default": "1", "comment": "平台公共模板是否对全部租户可见(仅 tenant_id IS NULL 时有意义)"},
{"name": "is_builtin", "type": "tinyint(1)", "nullable": false, "default": "0", "comment": "是否内置(内置模板禁止删除,仅可停用)"},
{"name": "source", "type": "varchar(32)", "nullable": false, "default": "platform", "comment": "来源:platform/tenant/fork/import"},
{"name": "source_template_id", "type": "varchar(64)", "nullable": true, "comment": "fork 来源模板ID(租户从平台公共模板派生时记录)"},
{"name": "version", "type": "varchar(32)", "nullable": false, "default": "1.0.0", "comment": "模板版本号"},
{"name": "status", "type": "varchar(32)", "nullable": false, "default": "draft", "comment": "draft/published/deprecated"},
{"name": "usage_count", "type": "int", "nullable": false, "default": "0", "comment": "被实例化次数(平台公共模板跨租户累计)"},
{"name": "owner_id", "type": "varchar(64)", "nullable": true, "comment": "创建人/负责人"},
{"name": "created_by", "type": "varchar(64)", "nullable": true},
{"name": "created_at", "type": "datetime", "nullable": true},
{"name": "updated_by", "type": "varchar(64)", "nullable": true},
{"name": "updated_at", "type": "datetime", "nullable": true},
{"name": "deleted", "type": "tinyint(1)", "nullable": false, "default": "0", "comment": "软删除标记"}
],
"indexes": [
{"name": "uk_pbl_tpl_tenant_code", "unique": true, "columns": ["tenant_id", "code", "deleted"], "comment": "租户内编码唯一;tenant_id NULL 时 MySQL 唯一索引不去重,故平台公共模板唯一性由应用层 ensure 校验兜底"},
{"name": "idx_pbl_tpl_status", "columns": ["tenant_id", "status", "deleted"]},
{"name": "idx_pbl_tpl_category", "columns": ["category"]}
],
"seed": "pbl_blueprint/json/seed_template_offline.json"
}