We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.5.3
AbstractTemplateEngine
protected void outputCustomFile(@NotNull List<CustomFile> customFiles, @NotNull TableInfo tableInfo, @NotNull Map<String, Object> objectMap) { String entityName = tableInfo.getEntityName(); String parentPath = getPathInfo(OutputFile.parent); customFiles.forEach(file -> { String filePath = StringUtils.isNotBlank(file.getFilePath()) ? file.getFilePath() : parentPath; if (StringUtils.isNotBlank(file.getPackageName())) { filePath = filePath + File.separator + file.getPackageName(); } String fileName = filePath + File.separator + entityName + file.getFileName(); outputFile(new File(fileName), objectMap, file.getTemplatePath(), file.isFileOverride()); }); }
1.建议在TableInfo对象里保留一个根据表名转换后的最原始字段名,tableInfo.getEntityName()该返回值已经被entity.formatFileName污染了。比如我要自定义Vo,最终生成的Vo类名会变成TableEntityVo。fileName拼接的时候使用原始的字段名加上自定义后缀。 CustomFile.Builder().fileName("Vo").build()
2.模板路径调用getTemplateFilePath方法,会自动拼接后缀
getTemplateFilePath
3.模板路径只有entity可以设置kotlin,其他service、mapper、controller没有
希望可以自定义类名后缀
The text was updated successfully, but these errors were encountered:
请关注版本 3.5.3.2 发布,已支持 a3d7709
3.5.3.2
@Test public void testCustomFileByList() { // 设置自定义输出文件 AutoGenerator generator = new AutoGenerator(DATA_SOURCE_CONFIG); generator.strategy(strategyConfig().build()); // 警用默认模板 generator.template(templateConfig().disable(TemplateType.CONTROLLER).build()); generator.injection(injectionConfig().customFile(new ArrayList<CustomFile>() {{ add(new CustomFile.Builder().fileName("DTO.java").templatePath("/templates/dto.java.vm").packageName("dto").build()); add(new CustomFile.Builder().fileName("VO.java").templatePath("/templates/vo.java.vm").packageName("vo").build()); // 通过格式化函数添加文件最后缀 add(new CustomFile.Builder().formatNameFunction(tableInfo -> "Prefix" + tableInfo.getEntityName() + "Suffix") .fileName("Controller.java").templatePath("/templates/controller.java.vm").packageName("controller").build()); }}).build()); generator.global(globalConfig().build()); generator.execute(); }
Sorry, something went wrong.
No branches or pull requests
当前使用版本(必填,否则不予处理)
3.5.3
该问题是如何引起的?(确定最新版也有问题再提!!!)
AbstractTemplateEngine
1.建议在TableInfo对象里保留一个根据表名转换后的最原始字段名,tableInfo.getEntityName()该返回值已经被entity.formatFileName污染了。比如我要自定义Vo,最终生成的Vo类名会变成TableEntityVo。fileName拼接的时候使用原始的字段名加上自定义后缀。
CustomFile.Builder().fileName("Vo").build()
2.模板路径调用
getTemplateFilePath
方法,会自动拼接后缀3.模板路径只有entity可以设置kotlin,其他service、mapper、controller没有
重现步骤(如果有就写完整)
希望可以自定义类名后缀
The text was updated successfully, but these errors were encountered: