|
@@ -1,30 +1,14 @@
|
|
|
package com.chelvc.framework.database.config;
|
|
|
|
|
|
-import java.io.InputStream;
|
|
|
-import java.io.Reader;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.lang.reflect.ParameterizedType;
|
|
|
import java.lang.reflect.Type;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.BigInteger;
|
|
|
import java.sql.CallableStatement;
|
|
|
import java.sql.PreparedStatement;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
-import java.time.Instant;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.LocalTime;
|
|
|
-import java.time.Month;
|
|
|
-import java.time.OffsetDateTime;
|
|
|
-import java.time.OffsetTime;
|
|
|
-import java.time.Year;
|
|
|
-import java.time.YearMonth;
|
|
|
-import java.time.ZonedDateTime;
|
|
|
-import java.time.chrono.JapaneseDate;
|
|
|
import java.util.Collection;
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -95,8 +79,8 @@ import com.chelvc.framework.database.handler.StringSetTypeHandler;
|
|
|
import com.chelvc.framework.database.handler.StringsTypeHandler;
|
|
|
import com.chelvc.framework.database.sql.CallableStringDecrypter;
|
|
|
import com.chelvc.framework.database.sql.ResultStringDecrypter;
|
|
|
-import com.chelvc.framework.database.sql.SQLUtils;
|
|
|
import com.chelvc.framework.database.sql.WriteStringEncryptor;
|
|
|
+import com.chelvc.framework.database.support.MyBatisUtils;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.google.common.collect.Sets;
|
|
|
import javassist.CannotCompileException;
|
|
@@ -179,32 +163,10 @@ public class TypeHandlerConfigurer extends MybatisConfigurer {
|
|
|
* @return true/false
|
|
|
*/
|
|
|
private boolean isMetaType(Class<?> type) {
|
|
|
- return this.isTypeHandlerRegistered(type) || Map.class.isAssignableFrom(type)
|
|
|
+ return isTypeHandlerRegistered(type) || Map.class.isAssignableFrom(type)
|
|
|
|| Collection.class.isAssignableFrom(type);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 判断对象类型处理器是否已注册
|
|
|
- *
|
|
|
- * @param type 对象类型
|
|
|
- * @return true/false
|
|
|
- */
|
|
|
- private boolean isTypeHandlerRegistered(Class<?> type) {
|
|
|
- return type == byte.class || type == Byte.class || type == byte[].class || type == Byte[].class
|
|
|
- || type == char.class || type == Character.class || type == short.class || type == Short.class
|
|
|
- || type == int.class || type == Integer.class || type == long.class || type == Long.class
|
|
|
- || type == float.class || type == Float.class || type == double.class || type == Double.class
|
|
|
- || type == boolean.class || type == Boolean.class || type == String.class || type == Object.class
|
|
|
- || type == BigInteger.class || type == BigDecimal.class || type == Reader.class
|
|
|
- || type == InputStream.class || type == Date.class || type == java.sql.Date.class
|
|
|
- || type == java.sql.Time.class || type == java.sql.Timestamp.class || type == Instant.class
|
|
|
- || type == LocalDate.class || type == LocalTime.class || type == LocalDateTime.class
|
|
|
- || type == OffsetTime.class || type == OffsetDateTime.class || type == ZonedDateTime.class
|
|
|
- || type == Year.class || type == Month.class || type == YearMonth.class || type == JapaneseDate.class
|
|
|
- || (type != null && Enum.class.isAssignableFrom(type)) || type == File.class || type == Period.class
|
|
|
- || type == Region.class || type == Modification.class;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 判断对象是否可配置类型处理器
|
|
|
*
|
|
@@ -223,7 +185,7 @@ public class TypeHandlerConfigurer extends MybatisConfigurer {
|
|
|
|
|
|
// JSON字段
|
|
|
Type type = TypeParameterResolver.resolveFieldType(field, clazz);
|
|
|
- return !this.isTypeHandlerRegistered(ObjectUtils.type2class(type));
|
|
|
+ return !isTypeHandlerRegistered(ObjectUtils.type2class(type));
|
|
|
}));
|
|
|
}
|
|
|
|
|
@@ -384,7 +346,7 @@ public class TypeHandlerConfigurer extends MybatisConfigurer {
|
|
|
if (((handler == null && (handler = (Class<? extends TypeHandler<?>>)
|
|
|
ObjectUtils.ifNull(annotation, TableField::typeHandler)) == null)
|
|
|
|| handler == UnknownTypeHandler.class || handler == JacksonTypeHandler.class)
|
|
|
- && !this.isTypeHandlerRegistered(model)) {
|
|
|
+ && !isTypeHandlerRegistered(model)) {
|
|
|
handler = this.lookupJsonHandlerClass(type);
|
|
|
}
|
|
|
|
|
@@ -529,7 +491,7 @@ public class TypeHandlerConfigurer extends MybatisConfigurer {
|
|
|
aliases.add(StringUtils.hump2underscore(property));
|
|
|
aliases.add(StringUtils.underscore2hump(property));
|
|
|
String column = ObjectUtils.ifNull(field.getAnnotation(TableField.class), TableField::value);
|
|
|
- if (StringUtils.notEmpty(column = SQLUtils.unquote(column))) {
|
|
|
+ if (StringUtils.notEmpty(column = MyBatisUtils.unquote(column))) {
|
|
|
aliases.add(column);
|
|
|
aliases.add(StringUtils.hump2underscore(column));
|
|
|
aliases.add(StringUtils.underscore2hump(column));
|