From 40ae8716bbde6a3a78cc9fda59b51b4cda125671 Mon Sep 17 00:00:00 2001
From: "1437892690@qq.com" <1437892690@qq.com>
Date: Thu, 22 Aug 2024 18:14:04 +0800
Subject: [PATCH 1/3] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E8=A1=A8=E5=8D=95?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=A9=E5=B1=95=E6=95=B0=E6=8D=AE=E6=97=B6?=
=?UTF-8?q?=E9=9C=80=E8=A6=81=E6=A0=A1=E9=AA=8C=E6=89=A9=E5=B1=95=E5=B1=9E?=
=?UTF-8?q?=E6=80=A7=E9=85=8D=E7=BD=AE=E6=98=AF=E5=90=A6=E6=AD=A3=E7=A1=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
关联 #[1214304177586176]表单添加扩展数据时需要校验扩展属性配置是否正确 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1214304177586176
---
.../attribute/core/ControlHandlerBase.java | 5 ++
.../form/attribute/core/FormHandlerBase.java | 12 ++++
.../attribute/core/IFormAttributeHandler.java | 2 +
...ExtendAttributeConfigIllegalException.java | 31 ++++++++++
.../attribute/handler/CascadeHandler.java | 12 ++++
.../attribute/handler/CheckboxHandler.java | 49 +++++++++++++++
.../form/attribute/handler/CubeHandler.java | 19 ++++++
.../form/attribute/handler/DateHandler.java | 19 ++++++
.../form/attribute/handler/LinkHandler.java | 20 +++++++
.../form/attribute/handler/RadioHandler.java | 49 +++++++++++++++
.../form/attribute/handler/RateHandler.java | 12 ++++
.../form/attribute/handler/SelectHandler.java | 49 +++++++++++++++
.../handler/TableInputerHandler.java | 58 +++++++++++++++++-
.../handler/TableSelectorHandler.java | 60 ++++++++++++++++++-
.../form/attribute/handler/TextHandler.java | 4 ++
.../form/attribute/handler/TimeHandler.java | 13 ++++
.../attribute/handler/TreeSelectHandler.java | 44 ++++++++++++++
.../form/attribute/handler/UploadHandler.java | 13 ++++
.../attribute/handler/UserSelectHandler.java | 16 +++++
19 files changed, 481 insertions(+), 6 deletions(-)
create mode 100644 src/main/java/neatlogic/framework/form/exception/FormExtendAttributeConfigIllegalException.java
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 95dbe9c63..b0ce89a4b 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 fa64dec75..72ba229ce 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 adf7fb047..d7165d508 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,6 @@ public interface IFormAttributeHandler {
default void makeupFormAttribute(FormAttributeVo formAttributeVo) {
}
+
+ 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 000000000..61257a818
--- /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("表单扩展数据中,{0}类型属性{1}的配置中缺少{2}字段", handler, key, field);
+ }
+
+ public FormExtendAttributeConfigIllegalException(String handler, String key, String field, String value) {
+ super("表单扩展数据中,{0}类型属性{1}的配置中{2}字段值为{3}不合法", 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 a0636115a..3f8d46f57 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 be3a160ea..5b02ed6b4 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 7dcc799a1..c13bffba6 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 a2dfa688c..b140cb84a 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 de1a0e06d..c4685acd2 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 e40ea9eda..6cb46bc09 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 2564f6d71..4ae6255ba 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 4dd93df14..ebdb8f60b 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 5edaa75bd..45d2e5458 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 ce69e9b22..ae1592782 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 689b74e73..b6ba623b5 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 74515c0d6..313676dd6 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 f68d7d527..6258b2263 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 6a3d6824a..be62d716d 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 e00cf6181..137a73fb0 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", "[]");
+ }
+ }
}
--
Gitee
From 1f2ace0d1181c961c8b8dd9e9e8cd4706763e573 Mon Sep 17 00:00:00 2001
From: "1437892690@qq.com" <1437892690@qq.com>
Date: Thu, 22 Aug 2024 18:18:08 +0800
Subject: [PATCH 2/3] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E8=A1=A8=E5=8D=95?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=A9=E5=B1=95=E6=95=B0=E6=8D=AE=E6=97=B6?=
=?UTF-8?q?=E9=9C=80=E8=A6=81=E6=A0=A1=E9=AA=8C=E6=89=A9=E5=B1=95=E5=B1=9E?=
=?UTF-8?q?=E6=80=A7=E9=85=8D=E7=BD=AE=E6=98=AF=E5=90=A6=E6=AD=A3=E7=A1=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
关联 #[1214304177586176]表单添加扩展数据时需要校验扩展属性配置是否正确 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1214304177586176
---
.../exception/FormExtendAttributeConfigIllegalException.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/neatlogic/framework/form/exception/FormExtendAttributeConfigIllegalException.java b/src/main/java/neatlogic/framework/form/exception/FormExtendAttributeConfigIllegalException.java
index 61257a818..c61ed97d7 100644
--- a/src/main/java/neatlogic/framework/form/exception/FormExtendAttributeConfigIllegalException.java
+++ b/src/main/java/neatlogic/framework/form/exception/FormExtendAttributeConfigIllegalException.java
@@ -22,10 +22,10 @@ import neatlogic.framework.exception.core.ApiRuntimeException;
public class FormExtendAttributeConfigIllegalException extends ApiRuntimeException {
public FormExtendAttributeConfigIllegalException(String handler, String key, String field) {
- super("表单扩展数据中,{0}类型属性{1}的配置中缺少{2}字段", handler, key, field);
+ super("nffe.formextendattributeconfigillegalexception.formextendattributeconfigillegalexception_a", handler, key, field);
}
public FormExtendAttributeConfigIllegalException(String handler, String key, String field, String value) {
- super("表单扩展数据中,{0}类型属性{1}的配置中{2}字段值为{3}不合法", handler, key, field, value);
+ super("nffe.formextendattributeconfigillegalexception.formextendattributeconfigillegalexception_b", handler, key, field, value);
}
}
--
Gitee
From 8dfc0d205ee8094449169185691ee05d78cd009a Mon Sep 17 00:00:00 2001
From: "1437892690@qq.com" <1437892690@qq.com>
Date: Thu, 22 Aug 2024 18:20:59 +0800
Subject: [PATCH 3/3] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E8=A1=A8=E5=8D=95?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=A9=E5=B1=95=E6=95=B0=E6=8D=AE=E6=97=B6?=
=?UTF-8?q?=E9=9C=80=E8=A6=81=E6=A0=A1=E9=AA=8C=E6=89=A9=E5=B1=95=E5=B1=9E?=
=?UTF-8?q?=E6=80=A7=E9=85=8D=E7=BD=AE=E6=98=AF=E5=90=A6=E6=AD=A3=E7=A1=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
关联 #[1214304177586176]表单添加扩展数据时需要校验扩展属性配置是否正确 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1214304177586176
---
.../framework/form/attribute/core/IFormAttributeHandler.java | 5 +++++
1 file changed, 5 insertions(+)
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 d7165d508..69ea7d350 100644
--- a/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeHandler.java
+++ b/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeHandler.java
@@ -230,5 +230,10 @@ public interface IFormAttributeHandler {
}
+ /**
+ * 校验扩展属性配置是否正确
+ * @param key
+ * @param config
+ */
void validateExtendAttributeConfig(String key, JSONObject config);
}
--
Gitee