Skip to content

Commit 2eb519c

Browse files
committed
增加全局IDType的设置,用于控制部分无法自动识别的数据库的ID生成策略
1 parent a60904b commit 2eb519c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/main/java/com/github/davidfantasy/mybatisplus/generatorui/GeneratorConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.davidfantasy.mybatisplus.generatorui;
22

3+
import com.baomidou.mybatisplus.annotation.IdType;
34
import com.baomidou.mybatisplus.generator.config.ITypeConvert;
45
import com.baomidou.mybatisplus.generator.config.rules.DateType;
56
import com.github.davidfantasy.mybatisplus.generatorui.mbp.NameConverter;
@@ -77,6 +78,11 @@ public class GeneratorConfig {
7778
*/
7879
private ITypeConvert typeConvert;
7980

81+
/**
82+
* 全局指定数据表中ID的生成模式,影响自动生成的Entity中ID字段的注解
83+
*/
84+
private IdType idType;
85+
8086
public NameConverter getAvailableNameConverter() {
8187
if (nameConverter == null) {
8288
nameConverter = new NameConverter() {

src/main/java/com/github/davidfantasy/mybatisplus/generatorui/service/MbpGeneratorService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public void genCodeBatch(GenSetting genSetting, List<String> tables) {
8181
BeanUtils.copyProperties(userConfig.getEntityStrategy(), mpg.getGlobalConfig());
8282
mpg.getGlobalConfig().setAuthor(genSetting.getAuthor());
8383
mpg.getGlobalConfig().setFileOverride(genSetting.isOverride());
84+
mpg.getGlobalConfig().setIdType(generatorConfig.getIdType());
8485
StrategyConfig strategy = getCurrentStrategy(userConfig);
8586
NameConverter nameConverter = generatorConfig.getAvailableNameConverter();
8687
strategy.setNameConvert(new INameConvert() {

0 commit comments

Comments
 (0)