|
@@ -17,7 +17,6 @@ package com.baomidou.mybatisplus.generator.config.po;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
|
|
-import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
|
|
|
import com.baomidou.mybatisplus.generator.config.rules.IColumnType;
|
|
|
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
|
|
import lombok.Data;
|
|
@@ -34,7 +33,6 @@ import java.util.Map;
|
|
|
@Data
|
|
|
@Accessors(chain = true)
|
|
|
public class TableField {
|
|
|
-
|
|
|
private boolean convert;
|
|
|
private boolean keyFlag;
|
|
|
/**
|
|
@@ -104,25 +102,24 @@ public class TableField {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 按JavaBean规则来生成get和set方法
|
|
|
+ * 按 JavaBean 规则来生成 get 和 set 方法后面的属性名称
|
|
|
+ * 需要处理一下特殊情况:
|
|
|
+ * <p>
|
|
|
+ * 1、如果只有一位,转换为大写形式
|
|
|
+ * 2、如果多于 1 位,只有在第二位是小写的情况下,才会把第一位转为小写
|
|
|
+ * <p>
|
|
|
+ * 我们并不建议在数据库对应的对象中使用基本类型,因此这里不会考虑基本类型的情况
|
|
|
*/
|
|
|
public String getCapitalName() {
|
|
|
- if (propertyName.length() <= 1) {
|
|
|
+ if (propertyName.length() == 1) {
|
|
|
return propertyName.toUpperCase();
|
|
|
}
|
|
|
- String setGetName = propertyName;
|
|
|
- if (DbColumnType.BASE_BOOLEAN.getType().equalsIgnoreCase(columnType.getType())) {
|
|
|
- setGetName = StringUtils.removeIsPrefixIfBoolean(setGetName, Boolean.class);
|
|
|
- }
|
|
|
- // 第一个字母 小写、 第二个字母 大写 ,特殊处理
|
|
|
- String firstChar = setGetName.substring(0, 1);
|
|
|
- if (Character.isLowerCase(firstChar.toCharArray()[0])
|
|
|
- && Character.isUpperCase(setGetName.substring(1, 2).toCharArray()[0])) {
|
|
|
- return firstChar.toLowerCase() + setGetName.substring(1);
|
|
|
+ if (Character.isLowerCase(propertyName.charAt(1))) {
|
|
|
+ return Character.toLowerCase(propertyName.charAt(0)) + propertyName.substring(1);
|
|
|
}
|
|
|
- return firstChar.toUpperCase() + setGetName.substring(1);
|
|
|
+ return propertyName;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 获取注解字段名称
|
|
|
*
|
|
@@ -137,5 +134,5 @@ public class TableField {
|
|
|
}
|
|
|
return columnName;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|