Skip to content

Commit a6bd2dc

Browse files
author
hewei
committed
兼容老版本配置
1 parent 1de9e88 commit a6bd2dc

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/main/java/com/itfsw/mybatis/generator/plugins/LogicalDeletePlugin.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ public void initialized(IntrospectedTable introspectedTable) {
176176
this.logicalDeleteColumn = null;
177177
warnings.add("itfsw(逻辑删除插件):" + introspectedTable.getFullyQualifiedTable() + "没有找到您配置的逻辑删除值,请全局或者局部配置logicalDeleteValue和logicalUnDeleteValue值!");
178178
} else {
179+
// 兼容处理以前一些老用户配置的Long 和 Float配置问题
180+
if (this.logicalDeleteColumn.getFullyQualifiedJavaType().getFullyQualifiedName().equals(Long.class.getName())){
181+
this.logicalUnDeleteValue = this.logicalUnDeleteValue.replaceAll("L|l", "");
182+
this.logicalDeleteValue = this.logicalDeleteValue.replaceAll("L|l", "");
183+
} else if (this.logicalDeleteColumn.getFullyQualifiedJavaType().getFullyQualifiedName().equals(Float.class.getName())){
184+
this.logicalUnDeleteValue = this.logicalUnDeleteValue.replaceAll("F|f", "");
185+
this.logicalDeleteValue = this.logicalDeleteValue.replaceAll("F|f", "");
186+
}
187+
179188
enumInfo.addItem(this.logicalUnDeleteConstName, "未删除", this.logicalUnDeleteValue);
180189
enumInfo.addItem(this.logicalDeleteConstName, "已删除", this.logicalDeleteValue);
181190
this.logicalDeleteEnum = enumInfo.generateEnum(commentGenerator, introspectedTable);

src/test/java/com/itfsw/mybatis/generator/plugins/tools/AbstractShellCallback.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,12 @@ public void setTool(MyBatisGeneratorTool tool) {
5252
*/
5353
@Override
5454
public void refreshProject(String project) {
55-
SqlSession sqlSession = null;
56-
try {
57-
// 编译项目
58-
sqlSession = tool.compile();
55+
// 编译项目
56+
try (SqlSession sqlSession = tool.compile()){
5957
reloadProject(sqlSession, tool.getTargetClassLoader(), tool.getTargetPackage());
6058
} catch (Exception e) {
6159
e.printStackTrace();
6260
Assert.assertTrue(false);
63-
} finally {
64-
sqlSession.close();
6561
}
6662
}
6763

0 commit comments

Comments
 (0)