Skip to content

代码生成器,如果entity设置了 %sDO, 自定义代码也会附上DO,这个类名能修改吗? #6774

New issue

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

Closed
3 tasks done
lucky-lbc opened this issue Apr 11, 2025 · 6 comments

Comments

@lucky-lbc
Copy link

确认

  • 我使用的版本是最新版, 并且使用插件确认过项目里无依赖版本冲突
  • 我已经在 issue 中搜索过, 确认问题没有被提出过
  • 我已经修改标题, 将标题中的 描述 替换为遇到的问题

当前程序版本

3.5.11

问题描述

Image

com.baomidou.mybatisplus.generator.config.po.TableInfo 这个类的name, entityName就会带上DO.

详细堆栈日志

@lucky-lbc
Copy link
Author

Image

Image

自定义的类名能修改吗?

@lucky-lbc lucky-lbc changed the title 代码生成器,如果entity设置了 %sDO, 自定义代码也会附上DO,这个类目能修改吗? 代码生成器,如果entity设置了 %sDO, 自定义代码也会附上DO,这个类名能修改吗? Apr 11, 2025
@nieqiurong
Copy link
Contributor

不支持,自定义模板的你只能自己处理。

@lucky-lbc
Copy link
Author

不支持,自定义模板的你只能自己处理。

关键名字框架自动生成的,我能控制里面不带DO.

@nieqiurong
Copy link
Contributor

这个配置就是设置entityName名字的,如果你又想指定,那自定义模板取变量或者你在定义的时候customMap中手动去除后缀新增一个模板变量,后续你的自定义模板全部引用新的自定义变量

@nieqiurong
Copy link
Contributor

在定义文件中加上处理逻辑 .formatNameFunction(tableInfo -> {return tableInfo.getEntityName();})

@nieqiurong
Copy link
Contributor

injectionConfig().beforeOutputFile((tableInfo, customMap) -> {
    // 加工处理新名称
    var newEntityName = tableInfo.getEntityName();
    customMap.put("newEntityName",newEntityName);
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants