|
@@ -2,21 +2,19 @@ package com.boman.web.core.utils;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.util.TypeUtils;
|
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
|
import com.boman.common.core.utils.StringUtils;
|
|
|
import com.boman.common.core.utils.collection.CollectionUtils;
|
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
|
import com.boman.domain.GenTableColumn;
|
|
|
+import com.boman.domain.constant.MysqlDataTypeConst;
|
|
|
import com.boman.domain.exception.UnknownColumnException;
|
|
|
import com.google.common.base.Joiner;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
-import org.apache.commons.lang3.ArrayUtils;
|
|
|
-import org.apache.commons.lang3.BooleanUtils;
|
|
|
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
import java.sql.Timestamp;
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -320,4 +318,26 @@ public class ColumnUtils {
|
|
|
return joiner.join(iterable);
|
|
|
}
|
|
|
|
|
|
+ public static String getColumnTypeByColumnName(List<GenTableColumn> columns, String columnName){
|
|
|
+ String result = "";
|
|
|
+ for (GenTableColumn column : columns) {
|
|
|
+ if (column.getColumnName().equals(columnName)) {
|
|
|
+ String columnType = column.getColumnType();
|
|
|
+ result = getDbType(columnType);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Object castNumberValue(List<GenTableColumn> columns, String columnName, Object value){
|
|
|
+ String columnType = getColumnTypeByColumnName(columns, columnName);
|
|
|
+ if (MysqlDataTypeConst.NUMBER.contains(columnType)) {
|
|
|
+ return TypeUtils.castToLong(value);
|
|
|
+ }
|
|
|
+
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
}
|