feat(metadata): createEntity 支持 masterTable(子表自动加 MASTERID 引用列回链主表)
主子表向导一步建子表:传 masterTable 时自动加 MASTERID 引用列(=子表回链主表外键), linkColumn 固定 MASTERID,再由 MasterDetailLinker 接线。已由主子表 Playwright e2e 端到端证明。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -121,6 +121,18 @@ public class MetaController {
|
||||
Map<String, String> refTargets = new HashMap<>();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map<String, Object>> attrs = (List<Map<String, Object>>) req.get("attributes");
|
||||
// 主子表:子表建模传 masterTable 时,自动加一个 MASTERID 引用列指向主表(= 子表回链主表的外键)。
|
||||
// 建模器据此一步建子表,linkColumn 固定 'MASTERID',再由 MasterDetailLinker 接线。
|
||||
Object masterTable = req.get("masterTable");
|
||||
if (masterTable != null && !String.valueOf(masterTable).isBlank()) {
|
||||
attrs = attrs == null ? new ArrayList<>() : new ArrayList<>(attrs);
|
||||
Map<String, Object> fk = new HashMap<>();
|
||||
fk.put("column", "MASTERID");
|
||||
fk.put("display", "主表");
|
||||
fk.put("type", "reference");
|
||||
fk.put("referenceTable", String.valueOf(masterTable).toUpperCase());
|
||||
attrs.add(fk);
|
||||
}
|
||||
if (attrs != null) {
|
||||
for (Map<String, Object> a : attrs) {
|
||||
String col = String.valueOf(a.get("column")).toUpperCase();
|
||||
|
||||
Reference in New Issue
Block a user