Files
eip4-platform/docs/skills/eip4-data-modeling.md
zhengwr 0e457d9945 feat(cli): agent 接入补全(token/MCP/REST 分流)+ 修 page-recipe recipe-id
- fix: page-recipe 的 maintenance-crud 漏 `-v1`,而 compile 端点精确匹配
  maintenance-crud-v1,agent 照抄示例会 400;统一为 -v1,并引导以
  GET /api/ai/page-recipes 为权威列表,避免硬写字面量漂移。
- env-manage 新增「鉴权/Token」段:非 prod profile permitAll 免 token,
  prod/JWT 环境需 POST /api/auth/login 取顶层 `token` + `Authorization: Bearer`
  (核实 AuthController/JwtAuthFilter)。
- AGENTS.md(writeAgentsMd):把「优先 platform-cli」误导修为按类分流
  (env/ai/release 用 CLI,建模/页面/授权用 REST 或 platform-mcp),
  并点名 platform-mcp 注册方式 + token 获取指引。
- data-modeling/page-recipe/acl-manage 各加调用方式与 token 交叉引用。
- 测试 +3:page-recipe recipe-id 回归、AGENTS.md MCP/auth、bundled skills 防漂移。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 09:50:23 +08:00

2.1 KiB
Raw Blame History

Skill: eip4-data-modeling

触发场景

  • 用户要新建业务实体(表)、给已有表加字段。
  • 需要引用列(外键)、主子表结构。

调用方式:经 REST(无对应 CLI 子命令),或经 platform-mcp(MCP)。非 local 环境需带 Authorization: Bearer <token>,取 token 见 eip4-env-manage。

端点

建实体:POST {{EIP4_BASE_URL}}/api/meta/entity

{
  "tablename": "EIP4AI_DEMO",
  "name": "演示实体",
  "attributes": [
    {"column": "TITLE", "display": "标题", "type": "string", "length": 200, "mandatory": true},
    {"column": "OWNER", "display": "负责人", "type": "reference", "referenceTable": "SYS_USER"}
  ],
  "tabletype": 0,
  "masterTable": "PARENT_TABLE"
}
  • tablename 必须 EIP4 前缀,大写,匹配 [A-Z][A-Z0-9_]{2,40}。
  • type:string | integer | number | date | datetime | boolean | reference。
    • reference 必带 referenceTable,自动生成 CHAR(36) 外键列指向目标表。
  • tabletype:0=主表 1=子表 2=中间表;子表用 masterTable 指定主表,自动加 MASTERID 回链列。
  • 标准列(主键/版本/审计时间/操作人)由引擎自动补齐,不要手传。

加字段:POST {{EIP4_BASE_URL}}/api/meta/entity/{table}/attributes,body 为 {"attributes":[...]}。

  • ALTER ADD COLUMN 恒可空(有数据的表加 NOT NULL 会失败)。

查询:

  • GET {{EIP4_BASE_URL}}/api/meta/entities — 实体目录(引用列目标表选择)。
  • GET {{EIP4_BASE_URL}}/api/meta/entity/{table} — 单实体属性(columns + displayColumn)。
  • GET {{EIP4_BASE_URL}}/api/meta/entity-types — 实体分类。

删除:DELETE {{EIP4_BASE_URL}}/api/meta/entity/{table}(仅 EIP4 前缀表)。

命令示例

curl -X POST {{EIP4_BASE_URL}}/api/meta/entity \
  -H "Content-Type: application/json" \
  --data-binary @entity.json

红线

  • 表名必须 EIP4 前缀,DDL 经 CreateTableSqlGuard / AlterTableSqlGuard / DropTableSqlGuard 强制校验。
  • 建表/加列/删表只对 EIP4 前缀表;生产表禁碰。
  • 不手传标准审计列。