!112 修复代码生成器遇到无符号类型数据库类型时无法匹配到 javaType

Merge pull request !112 from wanwan/fix-codegen-unsigned-20220327
This commit is contained in:
芋道源码 2022-03-28 01:09:03 +00:00 committed by Gitee
commit 172b227f90
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -160,8 +160,9 @@ public class CodegenBuilder {
// 处理 javaField 字段
column.setJavaField(toCamelCase(column.getColumnName()));
// 处理 dictType 字段暂无
// 处理 javaType 字段
String dbType = subBefore(column.getColumnType(), '(', false);
// 处理 javaType 字段(兼容无符号类型)
String dbType = replaceIgnoreCase(subBefore(column.getColumnType(), '(', false),
" UNSIGNED", "");
javaTypeMappings.entrySet().stream()
.filter(entry -> entry.getValue().contains(dbType))
.findFirst().ifPresent(entry -> column.setJavaType(entry.getKey()));