|
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.TypeReference;
|
|
|
import com.boman.common.core.constant.GenConstants;
|
|
|
import com.boman.common.core.utils.DateUtils;
|
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
|
+import com.boman.common.core.utils.array.ArrayUtils;
|
|
|
import com.boman.common.core.utils.collection.CollectionUtils;
|
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
|
import com.boman.common.core.web.domain.AjaxResult;
|
|
@@ -88,6 +89,8 @@ public class TableServiceCmdService {
|
|
|
checkColumn(commitData, context.getColumns());
|
|
|
// 必填项
|
|
|
handlerRequired(commitData, context.getColumns());
|
|
|
+ // 处理输入类型
|
|
|
+ handlerInputType(commitData, context.getColumns());
|
|
|
|
|
|
// 新增
|
|
|
if (ActionType.INSERT.equals(context.getActionType())) {
|
|
@@ -114,6 +117,20 @@ public class TableServiceCmdService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void handlerInputType(JSONObject commitData, List<GenTableColumn> columns) {
|
|
|
+ for (Map.Entry<String, Object> entry : commitData.entrySet()) {
|
|
|
+ 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)) {
|
|
|
+ throw new IllegalArgumentException(column.getColumnComment() + "只能输入数字");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void handlerRequired(JSONObject commitData, List<GenTableColumn> columns) {
|
|
|
for (GenTableColumn column : columns) {
|
|
|
if (GenTableColumn.IS_REQUIRED.equalsIgnoreCase(column.getIsRequired())) {
|