diff --git a/src/main/java/neatlogic/framework/form/attribute/core/ControlHandlerBase.java b/src/main/java/neatlogic/framework/form/attribute/core/ControlHandlerBase.java
index 95dbe9c63b94523bbb538bc8436578da93033aa2..b0ce89a4b1f0b2c7443790ff8466a1eff0c2dc07 100644
--- a/src/main/java/neatlogic/framework/form/attribute/core/ControlHandlerBase.java
+++ b/src/main/java/neatlogic/framework/form/attribute/core/ControlHandlerBase.java
@@ -15,6 +15,7 @@ along with this program. If not, see .*/
package neatlogic.framework.form.attribute.core;
+import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections4.CollectionUtils;
import java.util.Collections;
@@ -48,4 +49,8 @@ public abstract class ControlHandlerBase implements IFormAttributeHandler {
public Boolean isUseFormConfig() {
return true;
}
+
+ @Override
+ public void validateExtendAttributeConfig(String key, JSONObject config) {
+ }
}
diff --git a/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java b/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java
index fa64dec756424e91e52dd50f577e9bab020e904b..72ba229ce9c0299071680eb62d16dde3a120d790 100644
--- a/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java
+++ b/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java
@@ -20,6 +20,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import neatlogic.framework.matrix.dao.mapper.MatrixMapper;
import neatlogic.framework.util.$;
import org.apache.commons.collections4.CollectionUtils;
@@ -172,4 +173,15 @@ public abstract class FormHandlerBase implements IFormAttributeHandler, IFormAtt
}
throw new AttributeValidException(attributeLabel);
}
+
+ @Override
+ public void validateExtendAttributeConfig(String key, JSONObject config) {
+ if (config == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config");
+ }
+ myValidateExtendAttributeConfig(key, config);
+ }
+
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ }
}
diff --git a/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeHandler.java b/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeHandler.java
index adf7fb047a4175cd80c260f224785071d2f3a358..69ea7d35087d5c6db81b59567a1a3efa4e159bea 100644
--- a/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeHandler.java
+++ b/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeHandler.java
@@ -229,4 +229,11 @@ public interface IFormAttributeHandler {
default void makeupFormAttribute(FormAttributeVo formAttributeVo) {
}
+
+ /**
+ * 校验扩展属性配置是否正确
+ * @param key
+ * @param config
+ */
+ void validateExtendAttributeConfig(String key, JSONObject config);
}
diff --git a/src/main/java/neatlogic/framework/form/exception/FormExtendAttributeConfigIllegalException.java b/src/main/java/neatlogic/framework/form/exception/FormExtendAttributeConfigIllegalException.java
new file mode 100644
index 0000000000000000000000000000000000000000..c61ed97d71d005df5d773ef452e82ed603ee0776
--- /dev/null
+++ b/src/main/java/neatlogic/framework/form/exception/FormExtendAttributeConfigIllegalException.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.framework.form.exception;
+
+import neatlogic.framework.exception.core.ApiRuntimeException;
+
+public class FormExtendAttributeConfigIllegalException extends ApiRuntimeException {
+
+ public FormExtendAttributeConfigIllegalException(String handler, String key, String field) {
+ super("nffe.formextendattributeconfigillegalexception.formextendattributeconfigillegalexception_a", handler, key, field);
+ }
+
+ public FormExtendAttributeConfigIllegalException(String handler, String key, String field, String value) {
+ super("nffe.formextendattributeconfigillegalexception.formextendattributeconfigillegalexception_b", handler, key, field, value);
+ }
+}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java
index a0636115aec5842ec259f660cf3ccde48d338ae0..3f8d46f57a710335ba73e2efff71472754b7b605 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java
@@ -24,6 +24,7 @@ import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.dto.FormAttributeVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
@@ -429,4 +430,15 @@ public class CascadeHandler extends FormHandlerBase {
formAttributeVo.setMatrixUuidSet(matrixUuidSet);
formAttributeVo.setMatrixUuidAttributeUuidSetMap(matrixUuidAttributeUuidSetMap);
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ JSONArray dataList = config.getJSONArray("dataList");
+ if (dataList == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataList");
+ }
+ if (dataList.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataList", "[]");
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java
index be3a160ea1b41b7e99a3e9e30c8e9c0a0a587cf7..5b02ed6b4c2359e4d576459ae01fa5b56c41da36 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java
@@ -24,6 +24,7 @@ import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.dto.FormAttributeVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import neatlogic.framework.util.FormUtil;
import neatlogic.module.framework.form.service.FormService;
import org.apache.commons.collections4.CollectionUtils;
@@ -305,4 +306,52 @@ public class CheckboxHandler extends FormHandlerBase {
}
return null;
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ String dataSource = config.getString("dataSource");
+ if (dataSource == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataSource");
+ }
+ if (Objects.equals(dataSource, "static")) {
+ JSONArray dataList = config.getJSONArray("dataList");
+ if (dataList == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataList");
+ }
+ if (dataList.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataList", "[]");
+ }
+ } else if (Objects.equals(dataSource, "matrix")) {
+ String matrixUuid = config.getString("matrixUuid");
+ if (matrixUuid == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.matrixUuid");
+ }
+ if (StringUtils.isBlank(matrixUuid)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.matrixUuid", matrixUuid);
+ }
+ JSONObject mapping = config.getJSONObject("mapping");
+ if (mapping == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping");
+ }
+ if (mapping.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping", "{}");
+ }
+ String value = mapping.getString("value");
+ if (value == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.value");
+ }
+ if (StringUtils.isBlank(value)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.value", value);
+ }
+ String text = mapping.getString("text");
+ if (text == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.text");
+ }
+ if (StringUtils.isBlank(text)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.text", text);
+ }
+ } else {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataSource", dataSource);
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/CubeHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/CubeHandler.java
index 7dcc799a192d417e88e3c691606ccee588655c1e..c13bffba6c8c3d859edaabe9f29d1232d52ec353 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/CubeHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/CubeHandler.java
@@ -24,6 +24,7 @@ import neatlogic.framework.form.constvalue.FormConditionModel;
import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
@@ -249,4 +250,22 @@ public class CubeHandler extends FormHandlerBase {
}
return null;
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ JSONArray typeList = config.getJSONArray("typeList");
+ if (typeList == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.typeList");
+ }
+ if (typeList.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.typeList", "[]");
+ }
+ JSONArray optionList = config.getJSONArray("optionList");
+ if (optionList == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.optionList");
+ }
+ if (optionList.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.optionList", "[]");
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/DateHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/DateHandler.java
index a2dfa688c35366eb06c7c04552da8a2487a751d7..b140cb84ab75f87dbc31cfad12a512810e7d97d2 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/DateHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/DateHandler.java
@@ -25,6 +25,7 @@ import neatlogic.framework.form.constvalue.FormConditionModel;
import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import neatlogic.framework.worktime.dao.mapper.WorktimeMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
@@ -313,4 +314,22 @@ public class DateHandler extends FormHandlerBase {
public Object dataTransformationForExcel(AttributeDataVo attributeDataVo, JSONObject configObj) {
return attributeDataVo.getDataObj();
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ String format = config.getString("format");
+ if (format == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.format");
+ }
+ if (StringUtils.isBlank(format)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.format", format);
+ }
+// String styleType = config.getString("styleType");
+// if (styleType == null) {
+// throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.styleType");
+// }
+// if (StringUtils.isBlank(styleType)) {
+// throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.styleType", styleType);
+// }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/LinkHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/LinkHandler.java
index de1a0e06d5c07b20471bc74752ccb733df94c002..c4685acd2eeb6f2640da592569a32ddd285eeb68 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/LinkHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/LinkHandler.java
@@ -22,6 +22,8 @@ import neatlogic.framework.form.constvalue.FormConditionModel;
import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
@Component
@@ -185,4 +187,22 @@ public class LinkHandler extends FormHandlerBase {
public Object dataTransformationForExcel(AttributeDataVo attributeDataVo, JSONObject configObj) {
return configObj.getString("value");
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ String value = config.getString("value");
+ if (value == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config.value");
+ }
+ if (StringUtils.isBlank(value)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config.value", value);
+ }
+ String text = config.getString("text");
+ if (text == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config.text");
+ }
+ if (StringUtils.isBlank(text)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config.text", text);
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java
index e40ea9eda896139be136d8d8a08a96077213a5c9..6cb46bc0905cdd33fafb03c868b9ecea801afe2e 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java
@@ -24,6 +24,7 @@ import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.dto.FormAttributeVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import neatlogic.framework.util.FormUtil;
import neatlogic.module.framework.form.service.FormService;
import org.apache.commons.collections4.CollectionUtils;
@@ -302,4 +303,52 @@ public class RadioHandler extends FormHandlerBase {
}
return null;
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ String dataSource = config.getString("dataSource");
+ if (dataSource == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataSource");
+ }
+ if (Objects.equals(dataSource, "static")) {
+ JSONArray dataList = config.getJSONArray("dataList");
+ if (dataList == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataList");
+ }
+ if (dataList.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataList", "[]");
+ }
+ } else if (Objects.equals(dataSource, "matrix")) {
+ String matrixUuid = config.getString("matrixUuid");
+ if (matrixUuid == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.matrixUuid");
+ }
+ if (StringUtils.isBlank(matrixUuid)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.matrixUuid", matrixUuid);
+ }
+ JSONObject mapping = config.getJSONObject("mapping");
+ if (mapping == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping");
+ }
+ if (mapping.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping", "{}");
+ }
+ String value = mapping.getString("value");
+ if (value == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.value");
+ }
+ if (StringUtils.isBlank(value)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.value", value);
+ }
+ String text = mapping.getString("text");
+ if (text == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.text");
+ }
+ if (StringUtils.isBlank(text)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.text", text);
+ }
+ } else {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataSource", dataSource);
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/RateHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/RateHandler.java
index 2564f6d7154f240fe1392ce15928bcef46b157f3..4ae6255ba5df60385e7ec71a622820844077c400 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/RateHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/RateHandler.java
@@ -22,6 +22,7 @@ import neatlogic.framework.form.constvalue.FormConditionModel;
import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import org.springframework.stereotype.Component;
@Component
@@ -148,4 +149,15 @@ public class RateHandler extends FormHandlerBase {
public Object dataTransformationForExcel(AttributeDataVo attributeDataVo, JSONObject configObj) {
return attributeDataVo.getDataObj();
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ Integer count = config.getInteger("count");
+ if (count == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.count");
+ }
+ if (count < 1 || count > 10) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.count", count.toString());
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java
index 4dd93df14e85514c5bfd70af98d5ad3885699b35..ebdb8f60b1145fdeffd1601b529f229ccb27bcbf 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java
@@ -25,6 +25,7 @@ import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.dto.FormAttributeVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import neatlogic.framework.util.FormUtil;
import neatlogic.module.framework.form.service.FormService;
import org.apache.commons.collections4.CollectionUtils;
@@ -466,4 +467,52 @@ public class SelectHandler extends FormHandlerBase {
}
return null;
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ String dataSource = config.getString("dataSource");
+ if (dataSource == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataSource");
+ }
+ if (Objects.equals(dataSource, "static")) {
+ JSONArray dataList = config.getJSONArray("dataList");
+ if (dataList == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataList");
+ }
+ if (dataList.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataList", "[]");
+ }
+ } else if (Objects.equals(dataSource, "matrix")) {
+ String matrixUuid = config.getString("matrixUuid");
+ if (matrixUuid == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.matrixUuid");
+ }
+ if (StringUtils.isBlank(matrixUuid)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.matrixUuid", matrixUuid);
+ }
+ JSONObject mapping = config.getJSONObject("mapping");
+ if (mapping == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping");
+ }
+ if (mapping.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping", "{}");
+ }
+ String value = mapping.getString("value");
+ if (value == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.value");
+ }
+ if (StringUtils.isBlank(value)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.value", value);
+ }
+ String text = mapping.getString("text");
+ if (text == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.text");
+ }
+ if (StringUtils.isBlank(text)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.mapping.text", text);
+ }
+ } else {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataSource", dataSource);
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java
index 5edaa75bd8215c1063f64edf406c30b5173d919e..45d2e5458ecd005611a452ef8d560a61d1b49b3e 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java
@@ -18,14 +18,13 @@ package neatlogic.module.framework.form.attribute.handler;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import neatlogic.framework.common.constvalue.ParamType;
-import neatlogic.framework.form.attribute.core.FormAttributeDataConversionHandlerFactory;
-import neatlogic.framework.form.attribute.core.FormHandlerBase;
-import neatlogic.framework.form.attribute.core.IFormAttributeDataConversionHandler;
+import neatlogic.framework.form.attribute.core.*;
import neatlogic.framework.form.constvalue.FormConditionModel;
import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.dto.FormAttributeVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import neatlogic.framework.util.TableResultUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
@@ -799,4 +798,57 @@ public class TableInputerHandler extends FormHandlerBase {
}
}
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ JSONArray dataConfig = config.getJSONArray("dataConfig");
+ if (dataConfig == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataConfig");
+ }
+ if (dataConfig.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataConfig", "[]");
+ }
+ for (int i = 0; i < dataConfig.size(); i++) {
+ JSONObject dataObj = dataConfig.getJSONObject(i);
+ String field = "config.dataConfig.[" + i + "]";
+ if (dataObj == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field, "null");
+ }
+ if (dataObj.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field, "{}");
+ }
+ String key1 = dataObj.getString("key");
+ if (key1 == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".key");
+ }
+ if (StringUtils.isBlank(key1)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".key", key1);
+ }
+ String label = dataObj.getString("label");
+ if (label == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".label");
+ }
+ if (StringUtils.isBlank(label)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".label", label);
+ }
+ String handler = dataObj.getString("handler");
+ if (handler == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".handler");
+ }
+ if (StringUtils.isBlank(handler)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".handler", handler);
+ }
+ if (Objects.equals(handler, "formtable")) {
+ JSONObject config1 = dataObj.getJSONObject("config");
+ this.validateExtendAttributeConfig(key + "." + key1, config1);
+ } else {
+ IFormAttributeHandler formAttributeHandler = FormAttributeHandlerFactory.getHandler(handler);
+ if (formAttributeHandler == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".handler", handler);
+ }
+ JSONObject config1 = dataObj.getJSONObject("config");
+ formAttributeHandler.validateExtendAttributeConfig(key + "." + key1, config1);
+ }
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java
index ce69e9b2272110a426096d15553c43dcd04a9988..ae159278207389a5dac99aa7c4e5dac7bf2cb21a 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java
@@ -18,14 +18,13 @@ package neatlogic.module.framework.form.attribute.handler;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import neatlogic.framework.common.constvalue.ParamType;
-import neatlogic.framework.form.attribute.core.FormAttributeDataConversionHandlerFactory;
-import neatlogic.framework.form.attribute.core.FormHandlerBase;
-import neatlogic.framework.form.attribute.core.IFormAttributeDataConversionHandler;
+import neatlogic.framework.form.attribute.core.*;
import neatlogic.framework.form.constvalue.FormConditionModel;
import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.dto.FormAttributeVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import neatlogic.framework.util.TableResultUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
@@ -662,4 +661,59 @@ public class TableSelectorHandler extends FormHandlerBase {
}
return 1;
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ String matrixUuid = config.getString("matrixUuid");
+ if (matrixUuid == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.matrixUuid");
+ }
+ if (StringUtils.isBlank(matrixUuid)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.matrixUuid", matrixUuid);
+ }
+ JSONArray dataConfig = config.getJSONArray("dataConfig");
+ if (dataConfig == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataConfig");
+ }
+ if (dataConfig.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataConfig", "[]");
+ }
+ for (int i = 0; i < dataConfig.size(); i++) {
+ JSONObject dataObj = dataConfig.getJSONObject(i);
+ String field = "config.dataConfig.[" + i + "]";
+ if (dataObj == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field, "null");
+ }
+ if (dataObj.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field, "{}");
+ }
+ String key1 = dataObj.getString("key");
+ if (key1 == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".key");
+ }
+ if (StringUtils.isBlank(key1)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".key", key1);
+ }
+ String label = dataObj.getString("label");
+ if (label == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".label");
+ }
+ if (StringUtils.isBlank(label)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".label", label);
+ }
+ String handler = dataObj.getString("handler");
+ if (handler == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".handler");
+ }
+ if (StringUtils.isBlank(handler)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".handler", handler);
+ }
+ IFormAttributeHandler formAttributeHandler = FormAttributeHandlerFactory.getHandler(handler);
+ if (formAttributeHandler == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, field + ".handler", handler);
+ }
+ JSONObject config1 = dataObj.getJSONObject("config");
+ formAttributeHandler.validateExtendAttributeConfig(key + "." + key1, config1);
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TextHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TextHandler.java
index 689b74e73cc81804e287366e352cbf4453311506..b6ba623b5d6b2c405300e346f3099fb0ef764f91 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TextHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TextHandler.java
@@ -143,4 +143,8 @@ public class TextHandler extends FormHandlerBase {
public Object dataTransformationForExcel(AttributeDataVo attributeDataVo, JSONObject configObj) {
return attributeDataVo.getDataObj();
}
+
+ @Override
+ public void validateExtendAttributeConfig(String key, JSONObject config) {
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TimeHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TimeHandler.java
index 74515c0d6e6fa6d5d396ceff5c0652b4890c9f76..313676dd64c726eb2ab8d39c27be60266051a0ef 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TimeHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TimeHandler.java
@@ -22,6 +22,8 @@ import neatlogic.framework.form.constvalue.FormConditionModel;
import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
@Component
@@ -188,4 +190,15 @@ public class TimeHandler extends FormHandlerBase {
public Object dataTransformationForExcel(AttributeDataVo attributeDataVo, JSONObject configObj) {
return attributeDataVo.getDataObj();
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ String format = config.getString("format");
+ if (format == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.format");
+ }
+ if (StringUtils.isBlank(format)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.format", format);
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TreeSelectHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TreeSelectHandler.java
index f68d7d5277502c5d6decbe566c45ef5e33155234..6258b226381a9bab10f71f3ed20cb36335898f04 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TreeSelectHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TreeSelectHandler.java
@@ -23,6 +23,7 @@ import neatlogic.framework.form.constvalue.FormConditionModel;
import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import neatlogic.framework.form.treeselect.core.ITreeSelectDataSourceHandler;
import neatlogic.framework.form.treeselect.core.TreeSelectDataSourceFactory;
import org.apache.commons.collections4.CollectionUtils;
@@ -242,4 +243,47 @@ public class TreeSelectHandler extends FormHandlerBase {
}
return resultObj.get("value");
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ String dataSource = config.getString("dataSource");
+ if (dataSource == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.dataSource");
+ }
+ String url = config.getString("url");
+ if (url == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.url");
+ }
+ if (StringUtils.isBlank(url)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.url", url);
+ }
+ JSONObject config2 = config.getJSONObject("config");
+ if (config2 == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config");
+ }
+ if (config2.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config", "{}");
+ }
+ String valueName = config2.getString("valueName");
+ if (valueName == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config.valueName");
+ }
+ if (StringUtils.isBlank(valueName)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config.valueName", valueName);
+ }
+ String textName = config2.getString("textName");
+ if (textName == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config.textName");
+ }
+ if (StringUtils.isBlank(textName)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config.textName", textName);
+ }
+ String url2 = config2.getString("url");
+ if (url2 == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config.url");
+ }
+ if (StringUtils.isBlank(url2)) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.config.url", url2);
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/UploadHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/UploadHandler.java
index 6a3d6824a792a052038264bcbca5c8b185584603..be62d716d14312b506aff8e95a22f1806c9fdab3 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/UploadHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/UploadHandler.java
@@ -24,6 +24,7 @@ import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.dto.FormAttributeVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
@@ -31,6 +32,7 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
@Component
public class UploadHandler extends FormHandlerBase {
@@ -298,4 +300,15 @@ public class UploadHandler extends FormHandlerBase {
public Object dataTransformationForExcel(AttributeDataVo attributeDataVo, JSONObject configObj) {
return null;
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ String uploadType = config.getString("uploadType");
+ if (uploadType == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.uploadType");
+ }
+ if (!Objects.equals(uploadType, "one") && !Objects.equals(uploadType, "more")) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.uploadType", uploadType);
+ }
+ }
}
diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/UserSelectHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/UserSelectHandler.java
index e00cf6181bd081c23c88b77f1af63d876cf948fc..137a73fb0b1edbef6c76006acd8db29c1b8c50f7 100644
--- a/src/main/java/neatlogic/module/framework/form/attribute/handler/UserSelectHandler.java
+++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/UserSelectHandler.java
@@ -32,6 +32,7 @@ import neatlogic.framework.form.constvalue.FormConditionModel;
import neatlogic.framework.form.constvalue.FormHandler;
import neatlogic.framework.form.dto.AttributeDataVo;
import neatlogic.framework.form.exception.AttributeValidException;
+import neatlogic.framework.form.exception.FormExtendAttributeConfigIllegalException;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
@@ -488,4 +489,19 @@ public class UserSelectHandler extends FormHandlerBase {
}
return null;
}
+
+ @Override
+ protected void myValidateExtendAttributeConfig(String key, JSONObject config) {
+ Boolean isMultiple = config.getBoolean("isMultiple");
+ if (isMultiple == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.isMultiple");
+ }
+ JSONArray groupList = config.getJSONArray("groupList");
+ if (groupList == null) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.groupList");
+ }
+ if (groupList.isEmpty()) {
+ throw new FormExtendAttributeConfigIllegalException(this.getHandler(), key, "config.groupList", "[]");
+ }
+ }
}