【功能优化】INFRA:代码生成时,默认禁用单元测试的生成,更符合大家的习惯

This commit is contained in:
YunaiV
2024-09-19 13:10:23 +08:00
parent af5520db46
commit 805f80c36a
3 changed files with 12 additions and 0 deletions

View File

@ -34,4 +34,10 @@ public class CodegenProperties {
@NotNull(message = "代码生成的前端类型不能为空")
private Integer frontType;
/**
* 是否生成单元测试
*/
@NotNull(message = "是否生成单元测试不能为空")
private Boolean unitTestEnable;
}

View File

@ -398,6 +398,11 @@ public class CodegenEngine {
Map<String, String> templates = new LinkedHashMap<>();
templates.putAll(SERVER_TEMPLATES);
templates.putAll(FRONT_TEMPLATES.row(frontType));
// 如果禁用单元测试,则移除对应的模版
if (Boolean.FALSE.equals(codegenProperties.getUnitTestEnable())) {
templates.remove(javaTemplatePath("test/serviceTest"));
templates.remove("codegen/sql/h2.vm");
}
return templates;
}