diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm
index 906d12c29..bfe2dc007 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm
@@ -63,7 +63,7 @@ export function export${simpleClassName}Excel(params) {
responseType: 'blob'
})
}
-## 特殊:主子表专属逻辑
+## 特殊:主子表专属逻辑 TODO @puhui999:下面方法的【空格】不太对
#foreach ($subTable in $subTables)
#set ($index = $foreach.count - 1)
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm
index c1595798d..1c1553622 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm
@@ -1,137 +1,137 @@
\ No newline at end of file
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm
index d7794b0ff..eab90c12a 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm
@@ -2,375 +2,372 @@
- #foreach($column in $columns)
- #if ($column.listOperation)
- #set ($dictType = $column.dictType)
- #set ($javaField = $column.javaField)
- #set ($javaType = $column.javaType)
- #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
- #set ($comment = $column.columnComment)
- #set ($dictMethod = "getDictOptions")## 计算使用哪个 dict 字典方法
- #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
- #set ($dictMethod = "getIntDictOptions")
- #elseif ($javaType == "String")
- #set ($dictMethod = "getStrDictOptions")
- #elseif ($javaType == "Boolean")
- #set ($dictMethod = "getBoolDictOptions")
- #end
- #if ($column.htmlType == "input")
-
-
-
- #elseif ($column.htmlType == "select" || $column.htmlType == "radio")
-
-
- #if ("" != $dictType)## 设置了 dictType 数据字典的情况
-
- #else## 未设置 dictType 数据字典的情况
-
- #end
-
-
- #elseif($column.htmlType == "datetime")
- #if ($column.listOperationCondition != "BETWEEN")## 非范围
-
-
-
- #else## 范围
-
-
-
- #end
- #end
+ #foreach($column in $columns)
+ #if ($column.listOperation)
+ #set ($dictType = $column.dictType)
+ #set ($javaField = $column.javaField)
+ #set ($javaType = $column.javaType)
+ #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
+ #set ($comment = $column.columnComment)
+ #set ($dictMethod = "getDictOptions")## 计算使用哪个 dict 字典方法
+ #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
+ #set ($dictMethod = "getIntDictOptions")
+ #elseif ($javaType == "String")
+ #set ($dictMethod = "getStrDictOptions")
+ #elseif ($javaType == "Boolean")
+ #set ($dictMethod = "getBoolDictOptions")
#end
- #end
+ #if ($column.htmlType == "input")
+
+
+
+ #elseif ($column.htmlType == "select" || $column.htmlType == "radio")
+
+
+ #if ("" != $dictType)## 设置了 dictType 数据字典的情况
+
+ #else## 未设置 dictType 数据字典的情况
+
+ #end
+
+
+ #elseif($column.htmlType == "datetime")
+ #if ($column.listOperationCondition != "BETWEEN")## 非范围
+
+
+
+ #else## 范围
+
+
+
+ #end
+ #end
+ #end
+ #end
搜索
重置
新增
导出
- ## 特殊:树表专属逻辑
- #if ( $table.templateType == 2 )
-
- 展开/折叠
-
- #end
+## 特殊:树表专属逻辑
+#if ( $table.templateType == 2 )
+
+ 展开/折叠
+
+#end
- ## 特殊:主子表专属逻辑
- #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
-
- ## 特殊:树表专属逻辑
- #elseif ( $table.templateType == 2 )
-
- #else
-
- #end
- ## 特殊:主子表专属逻辑
- #if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
-
-
-
-
- #foreach ($subTable in $subTables)
- #set ($index = $foreach.count - 1)
- #set ($subClassNameVar = $subClassNameVars.get($index))
- #set ($subSimpleClassName = $subSimpleClassNames.get($index))
- #set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
-
- <${subSimpleClassName}List :${subJoinColumn_strikeCase}="scope.row.id" />
-
- #end
-
-
-
- #end
+## 特殊:主子表专属逻辑
+#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
+
+## 特殊:树表专属逻辑
+#elseif ( $table.templateType == 2 )
+
+#else
+
+#end
+## 特殊:主子表专属逻辑
+#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
+
+
+
+
+ #foreach ($subTable in $subTables)
+ #set ($index = $foreach.count - 1)
+ #set ($subClassNameVar = $subClassNameVars.get($index))
+ #set ($subSimpleClassName = $subSimpleClassNames.get($index))
+ #set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
+
+ <${subSimpleClassName}List :${subJoinColumn_strikeCase}="scope.row.id" />
+
+ #end
+
+
+
+#end
#foreach($column in $columns)
- #if ($column.listOperationResult)
- #set ($dictType=$column.dictType)
- #set ($javaField = $column.javaField)
- #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
- #set ($comment=$column.columnComment)
- #if ($column.javaType == "LocalDateTime")## 时间类型
-
- #elseif($column.dictType && "" != $column.dictType)## 数据字典
-
-
-
-
-
- #else
-
- #end
- #end
+ #if ($column.listOperationResult)
+ #set ($dictType=$column.dictType)
+ #set ($javaField = $column.javaField)
+ #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
+ #set ($comment=$column.columnComment)
+ #if ($column.javaType == "LocalDateTime")## 时间类型
+
+ #elseif($column.dictType && "" != $column.dictType)## 数据字典
+
+
+
+
+
+ #else
+
+ #end
#end
-
-
-
+
+
- 编辑
-
-
+ 编辑
+
+
- 删除
-
-
-
-
-## 特殊:树表专属逻辑(树不需要分页)
-#if ( $table.templateType != 2 )
+ >
+ 删除
+
+
+
+
-#end
<${simpleClassName}Form ref="formRef" @success="getList" />
- ## 特殊:主子表专属逻辑
- #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
-
-
-
- #foreach ($subTable in $subTables)
- #set ($index = $foreach.count - 1)
- #set ($subClassNameVar = $subClassNameVars.get($index))
- #set ($subSimpleClassName = $subSimpleClassNames.get($index))
- #set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
-
- <${subSimpleClassName}List :${subJoinColumn_strikeCase}="currentRow.id" />
-
- #end
-
-
- #end
+## 特殊:主子表专属逻辑
+#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
+
+
+
+ #foreach ($subTable in $subTables)
+ #set ($index = $foreach.count - 1)
+ #set ($subClassNameVar = $subClassNameVars.get($index))
+ #set ($subSimpleClassName = $subSimpleClassNames.get($index))
+ #set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
+
+ <${subSimpleClassName}List :${subJoinColumn_strikeCase}="currentRow.id" />
+
+ #end
+
+
+#end
\ No newline at end of file
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java
similarity index 50%
rename from yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineTest.java
rename to yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java
index 7c5a87724..588f2b08b 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineTest.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java
@@ -10,33 +10,32 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO;
import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO;
-import cn.iocoder.yudao.module.infra.enums.codegen.*;
import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties;
-import org.apache.ibatis.type.JdbcType;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Spy;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
- * {@link CodegenEngine} 的单元测试
+ * {@link CodegenEngine} 的单元测试抽象基类
*
* @author 芋道源码
*/
-public class CodegenEngineTest extends BaseMockitoUnitTest {
+public abstract class CodegenEngineAbstractTest extends BaseMockitoUnitTest {
@InjectMocks
- private CodegenEngine codegenEngine;
+ protected CodegenEngine codegenEngine;
@Spy
- private CodegenProperties codegenProperties = new CodegenProperties()
+ protected CodegenProperties codegenProperties = new CodegenProperties()
.setBasePackage("cn.iocoder.yudao");
@BeforeEach
@@ -44,87 +43,12 @@ public class CodegenEngineTest extends BaseMockitoUnitTest {
codegenEngine.initGlobalBindingMap();
}
- @Test
- public void testExecute_vue3_one() {
- // 准备参数
- CodegenTableDO table = getTable("student")
- .setFrontType(CodegenFrontTypeEnum.VUE3.getType())
- .setTemplateType(CodegenTemplateTypeEnum.ONE.getType());
- List columns = getColumnList("student");
-
- // 调用
- Map result = codegenEngine.execute(table, columns, null, null);
- // 断言
- assertResult(result, "codegen/vue3_one");
-// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue3_one");
- }
-
- @Test
- public void testExecute_vue3_tree() {
- // 准备参数
- CodegenTableDO table = getTable("category")
- .setFrontType(CodegenFrontTypeEnum.VUE3.getType())
- .setTemplateType(CodegenTemplateTypeEnum.TREE.getType());
- List columns = getColumnList("category");
-
- // 调用
- Map result = codegenEngine.execute(table, columns, null, null);
- // 断言
- assertResult(result, "codegen/vue3_tree");
-// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue3_tree");
-// writeFile(result, "/Users/yunai/test/demo66.zip");
- }
-
- @Test
- public void testExecute_vue3_master_normal() {
- testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_NORMAL, "codegen/vue3_master_normal");
- }
-
- @Test
- public void testExecute_vue3_master_erp() {
- testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_ERP, "codegen/vue3_master_erp");
- }
-
- @Test
- public void testExecute_vue3_master_inner() {
- testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_INNER, "codegen/vue3_master_inner");
- }
-
- private void testExecute_vue3_master(CodegenTemplateTypeEnum templateType,
- String path) {
- // 准备参数
- CodegenTableDO table = getTable("student")
- .setFrontType(CodegenFrontTypeEnum.VUE3.getType())
- .setTemplateType(templateType.getType());
- List columns = getColumnList("student");
- // 准备参数(子表)
- CodegenTableDO contactTable = getTable("contact")
- .setTemplateType(CodegenTemplateTypeEnum.SUB.getType())
- .setFrontType(CodegenFrontTypeEnum.VUE3.getType())
- .setSubJoinColumnId(100L).setSubJoinMany(true);
- List contactColumns = getColumnList("contact");
- // 准备参数(班主任)
- CodegenTableDO teacherTable = getTable("teacher")
- .setTemplateType(CodegenTemplateTypeEnum.SUB.getType())
- .setFrontType(CodegenFrontTypeEnum.VUE3.getType())
- .setSubJoinColumnId(200L).setSubJoinMany(false);
- List teacherColumns = getColumnList("teacher");
-
- // 调用
- Map result = codegenEngine.execute(table, columns,
- Arrays.asList(contactTable, teacherTable), Arrays.asList(contactColumns, teacherColumns));
- // 断言
- assertResult(result, path);
-// writeResult(result, "/root/ruoyi-vue-pro/yudao-module-infra/yudao-module-infra-biz/src/test/resources/" + path);
-// writeFile(result, "/Users/yunai/test/demo11.zip");
- }
-
- private static CodegenTableDO getTable(String name) {
+ protected static CodegenTableDO getTable(String name) {
String content = ResourceUtil.readUtf8Str("codegen/table/" + name + ".json");
return JsonUtils.parseObject(content, "table", CodegenTableDO.class);
}
- private static List getColumnList(String name) {
+ protected static List getColumnList(String name) {
String content = ResourceUtil.readUtf8Str("codegen/table/" + name + ".json");
List list = JsonUtils.parseArray(content, "columns", CodegenColumnDO.class);
list.forEach(column -> {
@@ -148,7 +72,7 @@ public class CodegenEngineTest extends BaseMockitoUnitTest {
}
@SuppressWarnings("rawtypes")
- private static void assertResult(Map result, String path) {
+ protected static void assertResult(Map result, String path) {
String assertContent = ResourceUtil.readUtf8Str(path + "/assert.json");
List asserts = JsonUtils.parseArray(assertContent, HashMap.class);
assertEquals(asserts.size(), result.size());
@@ -169,7 +93,7 @@ public class CodegenEngineTest extends BaseMockitoUnitTest {
* @param result 生成的代码
* @param path 写入文件的路径
*/
- private void writeFile(Map result, String path) {
+ protected void writeFile(Map result, String path) {
// 生成压缩包
String[] paths = result.keySet().toArray(new String[0]);
ByteArrayInputStream[] ins = result.values().stream().map(IoUtil::toUtf8Stream).toArray(ByteArrayInputStream[]::new);
@@ -185,7 +109,7 @@ public class CodegenEngineTest extends BaseMockitoUnitTest {
* @param result 生成的代码
* @param basePath 写入文件的路径(绝对路径)
*/
- private void writeResult(Map result, String basePath) {
+ protected void writeResult(Map result, String basePath) {
// 写入文件内容
List