chore: 落地 eip4-platform 多模块骨架基线(PoC→工程化)
从 eip4-poc 迁入双层制模块化单体:保真层 platform-legacy-core (com.dsasp 引擎原样)+ 现代层 platform-metadata/auth/flow-gateway/ converter/ai + platform-app 启动器。ArchUnit 纪律固化(保真层禁依赖现代层)。 此为 C1 对拍工作的编译通过基线。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
19
platform-converter/pom.xml
Normal file
19
platform-converter/pom.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.eip4</groupId>
|
||||
<artifactId>eip4-platform</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>platform-converter</artifactId>
|
||||
<name>platform-converter</name>
|
||||
<description>模板转换器 + S3 脚本改写器(可独立 CLI 跑批)</description>
|
||||
<dependencies>
|
||||
<dependency><groupId>com.eip4</groupId><artifactId>platform-legacy-core</artifactId></dependency>
|
||||
<dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,175 @@
|
||||
package com.eip4.platform.converter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 模板 XML → amis schema 转换器原型(P4 批量转换器的种子,对应 PoC 方案 4.1.5)。
|
||||
* 当前覆盖 GRID(type=1) 模板的 display/search/button 三段;
|
||||
* 每个映射决策都登记进 mappingNotes,作为映射表 v0 的数据来源。
|
||||
*/
|
||||
@Component
|
||||
public class TemplateToAmisConverter {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
public TemplateToAmisConverter(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
public Map<String, Object> convert(String templateXml, List<String> mappingNotes) throws Exception {
|
||||
Document doc = DocumentHelper.parseText(templateXml);
|
||||
Element crud = doc.getRootElement();
|
||||
if (!"crud".equals(crud.getName())) {
|
||||
throw new IllegalArgumentException("非 crud 模板: " + crud.getName());
|
||||
}
|
||||
|
||||
String title = crud.attributeValue("title", "");
|
||||
String entityId = crud.attributeValue("entityid", "");
|
||||
String table = resolveTableName(entityId);
|
||||
mappingNotes.add("crud@entityid=" + entityId + " → 实体表 " + table + "(经 SYS_ENTITY 解析)");
|
||||
|
||||
// ── display/field → columns
|
||||
List<Map<String, Object>> columns = new ArrayList<>();
|
||||
Element display = crud.element("display");
|
||||
if (display != null) {
|
||||
for (Element f : display.elements("field")) {
|
||||
String name = f.attributeValue("name", "");
|
||||
Map<String, Object> col = new LinkedHashMap<>();
|
||||
if (name.endsWith("_DISPLAY__")) {
|
||||
// 旧引擎的字典/时间翻译列;PoC 先映射回原始列,翻译值待 REST 层补
|
||||
String raw = name.substring(0, name.length() - "_DISPLAY__".length());
|
||||
col.put("name", raw);
|
||||
mappingNotes.add("display@field " + name + " → 原始列 " + raw + "(翻译列,REST 层待补显示值)");
|
||||
} else {
|
||||
col.put("name", name);
|
||||
}
|
||||
col.put("label", f.attributeValue("text", name));
|
||||
String width = f.attributeValue("width");
|
||||
if (width != null) {
|
||||
col.put("width", Integer.parseInt(width));
|
||||
}
|
||||
if ("true".equals(f.attributeValue("hidden"))) {
|
||||
col.put("toggled", false);
|
||||
mappingNotes.add("display@field " + name + " hidden=true → columns-toggler 默认隐藏");
|
||||
}
|
||||
columns.add(col);
|
||||
}
|
||||
}
|
||||
|
||||
// ── search/field → filter 表单
|
||||
Map<String, Object> filter = null;
|
||||
Element search = crud.element("search");
|
||||
if (search != null && !search.elements("field").isEmpty()) {
|
||||
List<Map<String, Object>> items = new ArrayList<>();
|
||||
for (Element f : search.elements("field")) {
|
||||
String name = f.attributeValue("name", "");
|
||||
String uitype = f.attributeValue("uitype", "TextField");
|
||||
Map<String, Object> item = new LinkedHashMap<>();
|
||||
item.put("name", name);
|
||||
item.put("label", f.attributeValue("label", name));
|
||||
switch (uitype) {
|
||||
case "ComboBox" -> {
|
||||
item.put("type", "select");
|
||||
item.put("clearable", true);
|
||||
String dict = f.attributeValue("comboboxid", "");
|
||||
item.put("source", "/api/poc/dict/" + dict);
|
||||
mappingNotes.add("search@field " + name + " uitype=ComboBox(comboboxid=" + dict
|
||||
+ ") → select + source 字典接口(接口待实现)");
|
||||
}
|
||||
case "DateField" -> {
|
||||
item.put("type", "input-date");
|
||||
mappingNotes.add("search@field " + name + " uitype=DateField → input-date");
|
||||
}
|
||||
default -> {
|
||||
item.put("type", "input-text");
|
||||
if (!"TextField".equals(uitype)) {
|
||||
mappingNotes.add("search@field " + name + " uitype=" + uitype
|
||||
+ " → 暂映射 input-text(映射表待补该控件)");
|
||||
}
|
||||
}
|
||||
}
|
||||
items.add(item);
|
||||
}
|
||||
filter = new LinkedHashMap<>();
|
||||
filter.put("title", "查询");
|
||||
filter.put("body", items);
|
||||
String script = search.attributeValue("script");
|
||||
if (script != null && !script.isBlank()) {
|
||||
mappingNotes.add("search@script 存在(" + script.length() + " 字符)→ 归入脚本分桶处理,本转换器跳过");
|
||||
}
|
||||
}
|
||||
|
||||
// ── button → headerToolbar
|
||||
List<Object> toolbar = new ArrayList<>();
|
||||
toolbar.add("bulkActions");
|
||||
for (Element b : crud.elements("button")) {
|
||||
if ("false".equals(b.attributeValue("isshow"))) {
|
||||
continue;
|
||||
}
|
||||
String btnType = b.attributeValue("type", "");
|
||||
Map<String, Object> btn = new LinkedHashMap<>();
|
||||
btn.put("type", "button");
|
||||
btn.put("label", b.attributeValue("name", b.attributeValue("id", "")));
|
||||
switch (btnType) {
|
||||
case "insert" -> {
|
||||
btn.put("level", "primary");
|
||||
btn.put("actionType", "dialog");
|
||||
Map<String, Object> dlg = new LinkedHashMap<>();
|
||||
dlg.put("type", "dialog");
|
||||
dlg.put("title", b.attributeValue("name", ""));
|
||||
dlg.put("body", Map.of("type", "tpl",
|
||||
"tpl", "表单页(pageid=" + b.attributeValue("pageid", "") + ")待 EDITFORM 模板转换"));
|
||||
btn.put("dialog", dlg);
|
||||
mappingNotes.add("button[insert] " + b.attributeValue("name") + " → dialog 占位(指向 pageid="
|
||||
+ b.attributeValue("pageid", "") + ",需 EDITFORM 转换器)");
|
||||
}
|
||||
case "delete" -> {
|
||||
btn.put("level", "danger");
|
||||
btn.put("actionType", "ajax");
|
||||
btn.put("confirmText", "确认删除选中记录?");
|
||||
btn.put("api", "delete:/api/entity/" + table + "/${ids}");
|
||||
mappingNotes.add("button[delete] → ajax DELETE /api/entity/" + table + "/${ids}(REST 端点待实现)");
|
||||
}
|
||||
default -> mappingNotes.add("button[" + btnType + "] " + b.attributeValue("name") + " → 普通按钮占位");
|
||||
}
|
||||
toolbar.add(btn);
|
||||
}
|
||||
toolbar.add("pagination");
|
||||
|
||||
// ── 组装 page > crud
|
||||
Map<String, Object> crudSchema = new LinkedHashMap<>();
|
||||
crudSchema.put("type", "crud");
|
||||
crudSchema.put("api", "/api/entity/" + table + "/list?page=${page}&perPage=${perPage}");
|
||||
crudSchema.put("syncLocation", false);
|
||||
if (filter != null) {
|
||||
crudSchema.put("filter", filter);
|
||||
}
|
||||
crudSchema.put("columns", columns);
|
||||
crudSchema.put("headerToolbar", toolbar);
|
||||
crudSchema.put("primaryField", table + "_ID");
|
||||
|
||||
Map<String, Object> page = new LinkedHashMap<>();
|
||||
page.put("type", "page");
|
||||
page.put("title", title);
|
||||
page.put("body", crudSchema);
|
||||
return page;
|
||||
}
|
||||
|
||||
private String resolveTableName(String entityId) {
|
||||
try {
|
||||
return jdbcTemplate.queryForObject(
|
||||
"SELECT TABLENAME FROM SYS_ENTITY WHERE SYS_ENTITY_ID=?", String.class, entityId);
|
||||
} catch (Exception e) {
|
||||
return "UNKNOWN_" + entityId;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user