This commit is contained in:
iqudoo
2026-05-23 19:34:44 +08:00
parent 88fa1c88dd
commit c27a2433be
4 changed files with 37 additions and 38 deletions

View File

@@ -7,8 +7,8 @@
本插件为 MyBatis Generator 提供了以下增强功能:
1. **TapeMybatisGeneratorPlugin** - 扩展 MyBatis Mapper添加 `selectPrimaryKeyByExample`, `batchInsert` 方法,拓展查询分页支持
2. **TapeRepositoryGeneratorPlugin** - 为非视图表自动生成 Repository 接口和实现类,提供完整的 CRUD 和软删除功能
3. **TapeRepoviewGeneratorPlugin** - 为视图表自动生成 RepoView 接口和实现类,提供查询功能
2. **TapeTableRepositoryGeneratorPlugin** - 为非视图表自动生成 Repository 接口和实现类,提供完整的 CRUD 和软删除功能
3. **TapeViewRepositoryGeneratorPlugin** - 为视图表自动生成 ViewRepository 接口和实现类,提供查询功能
## 插件说明
@@ -19,13 +19,12 @@
- 在 Mapper 接口中添加 `selectPrimaryKeyByExample` 方法
- 在 Mapper XML 中生成对应的 SQL 查询语句
### TapeRepositoryGeneratorPlugin
### TapeTableRepositoryGeneratorPlugin
为非视图表生成 Repository 层代码:
- **接口位置**: `{facadeRepositoryPackage}.I{TableName}Repository`
- **实现类位置**: `{domainRepositoryPackage}.{TableName}RepositoryImpl`
- **视图表过滤**: 根据 `viewKeyWords` 配置自动识别并跳过视图表
**生成的方法**
@@ -45,7 +44,7 @@
- `updateByExampleSelective({Model} record, {Example} example)` - 按条件更新记录
- `update({Model} record)` - 更新记录(支持乐观锁)
### TapeRepoviewGeneratorPlugin
### TapeViewRepositoryGeneratorPlugin
为视图表生成 RepoView 层代码:
@@ -145,39 +144,39 @@
```xml
<context id="Mysql" targetRuntime="MyBatis3">
<!-- 配置属性 -->
<property name="targetProject" value="src/main/java"/>
<property name="mapperPackage" value="com.iqudoo.platform.application.database.mapper"/>
<property name="modelPackage" value="com.iqudoo.platform.application.database.model"/>
<property name="facadeRepositoryPackage" value="com.iqudoo.platform.application.facade.repository"/>
<property name="domainRepositoryPackage" value="com.iqudoo.platform.application.domain.repository"/>
<property name="domainRepositoryType" value="Repository"/>
<property name="facadeViewRepositoryPackage" value="com.iqudoo.platform.application.facade.repoview"/>
<property name="domainViewRepositoryPackage" value="com.iqudoo.platform.application.domain.repoview"/>
<property name="domainViewRepositoryType" value="Repository"/>
<property name="guidGeneratorClass" value="com.iqudoo.framework.tape.modules.utils.SnowflakeUtil"/>
<property name="guidGeneratorCode" value="SnowflakeUtil.nextId()"/>
<property name="changeLogContextClassPackage" value="com.iqudoo.platform.application.domain.changeLog"/>
<property name="changeLogContextClassName" value="ChangeLogContext"/>
<property name="changeLogEnable" value="false"/>
<property name="slowQueryLoggerTime" value="300"/>
<property name="slowQueryLoggerLevel" value="error"/>
<property name="optimisticLockEnable" value="true"/>
<property name="ignorePageSize" value="10000"/>
<property name="startPageNum" value="1"/>
<property name="maxPageSize" value="100"/>
<!-- 配置属性 -->
<property name="targetProject" value="src/main/java"/>
<property name="mapperPackage" value="com.iqudoo.platform.application.database.mapper"/>
<property name="modelPackage" value="com.iqudoo.platform.application.database.model"/>
<property name="facadeRepositoryPackage" value="com.iqudoo.platform.application.facade.repository"/>
<property name="domainRepositoryPackage" value="com.iqudoo.platform.application.domain.repository"/>
<property name="domainRepositoryType" value="Repository"/>
<property name="facadeViewRepositoryPackage" value="com.iqudoo.platform.application.facade.repoview"/>
<property name="domainViewRepositoryPackage" value="com.iqudoo.platform.application.domain.repoview"/>
<property name="domainViewRepositoryType" value="Repository"/>
<property name="guidGeneratorClass" value="com.iqudoo.framework.tape.modules.utils.SnowflakeUtil"/>
<property name="guidGeneratorCode" value="SnowflakeUtil.nextId()"/>
<property name="changeLogContextClassPackage" value="com.iqudoo.platform.application.domain.changeLog"/>
<property name="changeLogContextClassName" value="ChangeLogContext"/>
<property name="changeLogEnable" value="false"/>
<property name="slowQueryLoggerTime" value="300"/>
<property name="slowQueryLoggerLevel" value="error"/>
<property name="optimisticLockEnable" value="true"/>
<property name="ignorePageSize" value="10000"/>
<property name="startPageNum" value="1"/>
<property name="maxPageSize" value="100"/>
<!-- 添加插件 -->
<plugin type="com.iqudoo.framework.mybatis.TapeMybatisGeneratorPlugin"/>
<plugin type="com.iqudoo.framework.mybatis.TapeRepositoryGeneratorPlugin"/>
<plugin type="com.iqudoo.framework.mybatis.TapeRepoviewGeneratorPlugin"/>
<!-- 添加插件 -->
<plugin type="com.iqudoo.framework.mybatis.TapeMybatisGeneratorPlugin"/>
<plugin type="com.iqudoo.framework.mybatis.TapeTableRepositoryGeneratorPlugin"/>
<plugin type="com.iqudoo.framework.mybatis.TapeViewRepositoryGeneratorPlugin"/>
<!-- 搭配使用 -->
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
<plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>
<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin"/>
<!-- 搭配使用 -->
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
<plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>
<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin"/>
<!-- 其他配置... -->
<!-- 其他配置... -->
</context>
```