feat: add AI page preview URL

This commit is contained in:
2026-06-17 14:17:53 +08:00
parent d91da77038
commit 4b2cedfd1d
8 changed files with 52 additions and 5 deletions

View File

@@ -984,6 +984,7 @@ public class AiAgentService {
String name = test.path("name").asText("");
String recipe = test.path("recipe").asText("");
String schemaUrl = test.path("schemaUrl").asText("");
String previewUrl = test.path("previewUrl").asText("");
String rootType = test.path("expectedRootType").asText("");
String bodyType = test.path("expectedBodyType").asText("");
String crudName = test.path("expectedCrudName").asText("");
@@ -1001,6 +1002,11 @@ public class AiAgentService {
if (!schemaUrl.startsWith("/api/page/schema/")) {
messages.add("render schemaUrl 必须以 /api/page/schema/ 开头: " + schemaUrl);
}
if (!previewUrl.startsWith("/amis.html?schema=")
&& !previewUrl.startsWith("/amis.html?templateId=")
&& !previewUrl.startsWith("/amis.html?schemaUrl=")) {
messages.add("render previewUrl 必须指向可解析 schema 的 /amis.html: " + previewUrl);
}
if (!"page".equals(rootType)) {
messages.add("render expectedRootType 必须是 page");
}

View File

@@ -164,6 +164,7 @@ public class AiFeatureDraftGenerator {
render.put("name", "page-render");
render.put("recipe", spec.pageRecipe());
render.put("schemaUrl", "/api/page/schema/" + spec.templateId());
render.put("previewUrl", "/amis.html?schema=" + spec.templateId());
render.put("expectedRootType", "page");
render.put("expectedBodyType", "crud");
render.put("expectedCrudName", expectedCrudName(spec));

View File

@@ -153,6 +153,7 @@ class AiAgentServiceTest {
"name":"page-render",
"recipe":"maintenance-crud-v1",
"schemaUrl":"/api/page/schema/demo",
"previewUrl":"/amis.html?schema=demo",
"expectedRootType":"page",
"expectedBodyType":"crud",
"expectedCrudName":"demoCrud",
@@ -657,6 +658,7 @@ class AiAgentServiceTest {
"name": "page-render",
"recipe": "maintenance-crud-v1",
"schemaUrl": "/api/page/schema/test-page",
"previewUrl": "/amis.html?schema=test-page",
"expectedRootType": "page",
"expectedBodyType": "crud",
"expectedCrudName": "testPageCrud",

View File

@@ -60,6 +60,8 @@ class AiFeatureDraftGeneratorTest {
assertEquals("maintenance-crud-v1", test.payload().path("renderTests").get(0).path("recipe").asText());
assertEquals("/api/page/schema/eip4ai-contract-type",
test.payload().path("renderTests").get(0).path("schemaUrl").asText());
assertEquals("/amis.html?schema=eip4ai-contract-type",
test.payload().path("renderTests").get(0).path("previewUrl").asText());
assertEquals("eip4aiContractTypeCrud",
test.payload().path("renderTests").get(0).path("expectedCrudName").asText());
assertEquals("NAME", test.payload().path("renderTests").get(0)
@@ -130,6 +132,8 @@ class AiFeatureDraftGeneratorTest {
assertEquals("eip4aiOrgCategoryTreeCrud",
test.payload().path("renderTests").get(0).path("expectedCrudName").asText());
assertEquals("children", test.payload().path("renderTests").get(0).path("childrenColumnName").asText());
assertEquals("/amis.html?schema=eip4ai-org-category",
test.payload().path("renderTests").get(0).path("previewUrl").asText());
assertEquals("/api/entity/EIP4AI_ORG_CATEGORY/tree?parentKey=PARENTID&idKey=EIP4AI_ORG_CATEGORY_ID&perPage=2000",
test.payload().path("renderTests").get(0).path("expectedApi").asText());
assertTrue(hasText(test.payload().path("renderTests").get(0).path("expectedActions"), "新增顶级组织分类"));