|
@@ -269,15 +269,22 @@ public class ColumnUtils {
|
|
|
*/
|
|
|
public static void handleInputType(JSONObject commitData, List<GenTableColumn> columns) {
|
|
|
for (Map.Entry<String, Object> entry : commitData.entrySet()) {
|
|
|
- Object value =entry.getValue();
|
|
|
+ Object value = entry.getValue();
|
|
|
for (GenTableColumn column : columns) {
|
|
|
- if (entry.getKey().equals(column.getColumnName())
|
|
|
- && ArrayUtils.arraysContains(GenConstants.COLUMNTYPE_NUMBER, getDbType(column.getColumnType()))) {
|
|
|
- if ((value instanceof Number)) {
|
|
|
- // ignore 这里的if不能删掉,因为else if有一个强转
|
|
|
- } else if (!NumberUtils.isCreatable(((String) value))) {
|
|
|
- throw new IllegalArgumentException(column.getColumnComment() + "只能输入数字");
|
|
|
- }
|
|
|
+ // 对必填项做校验, 非必填项不管他
|
|
|
+ if (!GenTableColumn.IS_REQUIRED.equalsIgnoreCase(column.getIsRequired())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!entry.getKey().equals(column.getColumnName())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!ArrayUtils.arraysContains(GenConstants.COLUMNTYPE_NUMBER, getDbType(column.getColumnType()))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((value instanceof String) && !NumberUtils.isCreatable(((String) value))) {
|
|
|
+ throw new IllegalArgumentException(column.getColumnComment() + "只能输入数字");
|
|
|
}
|
|
|
}
|
|
|
}
|