From 4b43db005483a8a3324ba017ca87ac57cea33d8f Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 23 Apr 2024 16:48:06 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=A1=A8=E5=8D=95=E6=A0=87=E5=87=86?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1141293256769536]后端-自定义表单标准规范定义 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1141293256769536 --- .../framework/form/dao/mapper/FormMapper.java | 11 +++ .../framework/form/dao/mapper/FormMapper.xml | 84 ++++++++++++++++++- .../framework/form/dto/AttributeDataVo.java | 9 ++ .../framework/form/dto/FormAttributeVo.java | 73 ++++++++++++---- .../framework/form/dto/FormVersionVo.java | 4 +- .../form/service/IFormCrossoverService.java | 9 ++ .../attribute/handler/CascadeHandler.java | 2 +- .../attribute/handler/CheckboxHandler.java | 2 +- .../form/attribute/handler/RadioHandler.java | 2 +- .../form/attribute/handler/SelectHandler.java | 2 +- .../handler/TableInputerHandler.java | 2 +- .../handler/TableSelectorHandler.java | 2 +- .../framework/form/service/FormService.java | 9 ++ .../form/service/FormServiceImpl.java | 40 ++++++++- 14 files changed, 221 insertions(+), 30 deletions(-) diff --git a/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.java b/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.java index f21c786c6..b05212597 100644 --- a/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.java +++ b/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.java @@ -18,6 +18,7 @@ package neatlogic.framework.form.dao.mapper; import neatlogic.framework.common.dto.BasePageVo; import neatlogic.framework.common.dto.ValueTextVo; import neatlogic.framework.form.dto.*; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Component; import java.util.List; @@ -67,6 +68,8 @@ public interface FormMapper { List getFormAttributeListByFormUuidList(List formUuidList); + List getFormExtendAttributeListByFormUuidAndFormVersionUuid(@Param("formUuid") String formUuid, @Param("formVersionUuid") String formVersionUuid); + int getFormAttributeMatrixCount(); List> getFormAttributeMatrixList(BasePageVo searchVo); @@ -97,8 +100,12 @@ public interface FormMapper { int insertFormAttribute(FormAttributeVo formAttributeVo); + int insertFormExtendAttribute(FormAttributeVo formAttributeVo); + int insertFormAttributeData(AttributeDataVo attributeDataVo); + int insertFormExtendAttributeData(AttributeDataVo attributeDataVo); + int deleteFormAttributeByFormUuid(String formUuid); int deleteFormByUuid(String uuid); @@ -110,4 +117,8 @@ public interface FormMapper { void deleteFormCustomItem(Long id); int deleteFormAttributeDataByIdList(List idList); + + int deleteFormExtendAttributeDataByIdList(List idList); + + int deleteFormExtendAttributeByFormUuidAndFormVersionUuid(@Param("formUuid") String formUuid, @Param("formVersionUuid") String currentVersionUuid); } diff --git a/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.xml b/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.xml index 8d6581518..e1a623adf 100644 --- a/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.xml +++ b/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.xml @@ -277,7 +277,7 @@ along with this program. If not, see .--> a.`label`, a.`type`, a.`handler`, - a.`config`, + a.`config` AS configStr, a.`data` FROM `form_attribute` a JOIN `form_version` b ON b.`uuid`=a.`formversion_uuid` AND b.`is_active` = 1 @@ -296,7 +296,7 @@ along with this program. If not, see .--> b.`label`, b.`type`, b.`handler`, - b.`config`, + b.`config` AS configStr, b.`data` FROM `form_version` a JOIN `form_attribute` b ON b.`form_uuid` = a.`form_uuid` AND a.`uuid` = b.`formversion_uuid` @@ -307,6 +307,23 @@ along with this program. If not, see .--> + + @@ -500,10 +517,33 @@ along with this program. If not, see .--> #{label}, #{type}, #{handler}, - #{config}, + #{configStr}, #{data}) + + INSERT INTO `form_extend_attribute` (`form_uuid`, + `formversion_uuid`, + `parent_uuid`, + `tag`, + `key`, + `uuid`, + `label`, + `type`, + `handler`, + `config`) + VALUES (#{formUuid}, + #{formVersionUuid}, + #{parentUuid}, + #{tag}, + #{key}, + #{uuid}, + #{label}, + #{type}, + #{handler}, + #{configStr}) + + INSERT INTO `form_attribute_data` ( `id`, @@ -526,6 +566,30 @@ along with this program. If not, see .--> UPDATE `data` = #{data,typeHandler=CompressHandler} + + INSERT INTO `form_extend_attribute_data` ( + `id`, + `form_uuid`, + `handler`, + `tag`, + `attribute_label`, + `attribute_uuid`, + `data` + ) + VALUES + ( + #{id}, + #{formUuid}, + #{handler}, + #{tag}, + #{attributeLabel}, + #{attributeUuid}, + #{data} + ) + ON DUPLICATE KEY + UPDATE `data` = #{data,typeHandler=CompressHandler} + + DELETE FROM `form_attribute` @@ -563,4 +627,18 @@ along with this program. If not, see .--> #{id} + + + DELETE FROM `form_extend_attribute_data` + WHERE `id` IN + + #{id} + + + + + DELETE FROM `form_extend_attribute` + WHERE `form_uuid` = #{formUuid} + AND `formversion_uuid` = #{formVersionUuid} + diff --git a/src/main/java/neatlogic/framework/form/dto/AttributeDataVo.java b/src/main/java/neatlogic/framework/form/dto/AttributeDataVo.java index fe1f88d54..97340a4e7 100644 --- a/src/main/java/neatlogic/framework/form/dto/AttributeDataVo.java +++ b/src/main/java/neatlogic/framework/form/dto/AttributeDataVo.java @@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils; public class AttributeDataVo implements Comparable { private Long id; private String formUuid; + private String tag; private String attributeUuid; private String attributeLabel; private String handler; @@ -79,6 +80,14 @@ public class AttributeDataVo implements Comparable { this.handler = handler; } + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + public String getData() { return data; } diff --git a/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java b/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java index 7fbe791a3..bdb0471f5 100644 --- a/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java +++ b/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java @@ -15,7 +15,6 @@ along with this program. If not, see .*/ package neatlogic.framework.form.dto; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.annotation.JSONField; import neatlogic.framework.common.constvalue.ApiParamType; @@ -26,7 +25,6 @@ import neatlogic.framework.form.attribute.core.IFormAttributeHandler; import neatlogic.framework.form.constvalue.FormConditionModel; import neatlogic.framework.restful.annotation.EntityField; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.util.*; @@ -39,6 +37,12 @@ public class FormAttributeVo implements Serializable { private String formUuid; @EntityField(name = "表单版本uuid", type = ApiParamType.STRING) private String formVersionUuid; + @EntityField(name = "父级uuid", type = ApiParamType.STRING) + private String parentUuid; + @EntityField(name = "标签", type = ApiParamType.STRING) + private String tag; + @EntityField(name = "属性key", type = ApiParamType.STRING) + private String key; @EntityField(name = "属性标签名", type = ApiParamType.STRING) private String label; @EntityField(name = "类型", type = ApiParamType.STRING) @@ -46,7 +50,7 @@ public class FormAttributeVo implements Serializable { @EntityField(name = "处理器", type = ApiParamType.STRING) private String handler; @EntityField(name = "属性配置", type = ApiParamType.STRING) - private String config; + private JSONObject config; @EntityField(name = "属性数据", type = ApiParamType.STRING) private String data; @EntityField(name = "是否必填", type = ApiParamType.BOOLEAN) @@ -62,9 +66,6 @@ public class FormAttributeVo implements Serializable { @EntityField(name = "条件模型") private FormConditionModel conditionModel = FormConditionModel.CUSTOM; - @JSONField(serialize = false) - private JSONObject configObj; - @JSONField(serialize = false) private Set integrationUuidSet; @@ -76,6 +77,9 @@ public class FormAttributeVo implements Serializable { private FormAttributeParentVo parent; + @JSONField(serialize = false) + private String configStr; + public FormAttributeVo() { } @@ -90,7 +94,7 @@ public class FormAttributeVo implements Serializable { } public FormAttributeVo(String formUuid, String formVersionUuid, String uuid, String label, String type, - String handler, boolean isRequired, String config, String data) { + String handler, boolean isRequired, JSONObject config, String data) { this.uuid = uuid; this.formUuid = formUuid; this.formVersionUuid = formVersionUuid; @@ -158,11 +162,14 @@ public class FormAttributeVo implements Serializable { this.handler = handler; } - public String getConfig() { + public JSONObject getConfig() { + if (config == null && configStr != null) { + config = JSONObject.parseObject(configStr); + } return config; } - public void setConfig(String config) { + public void setConfig(JSONObject config) { this.config = config; } @@ -254,6 +261,9 @@ public class FormAttributeVo implements Serializable { return null; } IFormAttributeHandler formHandler = FormAttributeHandlerFactory.getHandler(handler); + if (formHandler == null) { + return null; + } return formHandler.getHandlerType(conditionModel); } @@ -262,8 +272,7 @@ public class FormAttributeVo implements Serializable { return null; } if ("formselect".equals(handler)) { - JSONObject configObj = JSON.parseObject(config); - return configObj.getBoolean("isMultiple"); + return config.getBoolean("isMultiple"); } if (conditionModel!= null && Objects.equals(conditionModel.getValue(), FormConditionModel.CUSTOM.getValue())) { @@ -284,13 +293,6 @@ public class FormAttributeVo implements Serializable { this.isUseFormConfig = isUseFormConfig; } - public JSONObject getConfigObj() { - if (configObj == null && StringUtils.isNotBlank(config)) { - configObj = JSONObject.parseObject(config); - } - return configObj; - } - public Set getIntegrationUuidSet() { return integrationUuidSet; } @@ -322,4 +324,39 @@ public class FormAttributeVo implements Serializable { public void setParent(FormAttributeParentVo parent) { this.parent = parent; } + + public String getParentUuid() { + return parentUuid; + } + + public void setParentUuid(String parentUuid) { + this.parentUuid = parentUuid; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getConfigStr() { + if (configStr == null && config != null) { + configStr = config.toJSONString(); + } + return configStr; + } + + public void setConfigStr(String configStr) { + this.configStr = configStr; + } } diff --git a/src/main/java/neatlogic/framework/form/dto/FormVersionVo.java b/src/main/java/neatlogic/framework/form/dto/FormVersionVo.java index 576e80f9d..5c0982f93 100644 --- a/src/main/java/neatlogic/framework/form/dto/FormVersionVo.java +++ b/src/main/java/neatlogic/framework/form/dto/FormVersionVo.java @@ -218,7 +218,7 @@ public class FormVersionVo extends BaseEditorVo { JSONObject controllerObj = controllerList.getJSONObject(i); JSONObject config = controllerObj.getJSONObject("config"); if (MapUtils.isNotEmpty(config)) { - formAttributeList.add(new FormAttributeVo(this.getFormUuid(), this.getUuid(), controllerObj.getString("uuid"), controllerObj.getString("label"), controllerObj.getString("type"), controllerObj.getString("handler"), config.getBooleanValue("isRequired"), controllerObj.getString("config"), config.getString("defaultValueList"))); + formAttributeList.add(new FormAttributeVo(this.getFormUuid(), this.getUuid(), controllerObj.getString("uuid"), controllerObj.getString("label"), controllerObj.getString("type"), controllerObj.getString("handler"), config.getBooleanValue("isRequired"), config, config.getString("defaultValueList"))); } } } @@ -237,7 +237,7 @@ public class FormVersionVo extends BaseEditorVo { String handler = componentObj.getString("handler"); boolean isRequired = config.getBooleanValue("isRequired"); String defaultValue = config.getString("defaultValue"); - return new FormAttributeVo(this.getFormUuid(), this.getUuid(), uuid, label, type, handler, isRequired, componentObj.getString("config"), defaultValue); + return new FormAttributeVo(this.getFormUuid(), this.getUuid(), uuid, label, type, handler, isRequired, config, defaultValue); } return null; } diff --git a/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java b/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java index 50921b09e..b6f8df4df 100644 --- a/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java +++ b/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java @@ -91,4 +91,13 @@ public interface IFormCrossoverService extends ICrossoverService { * @return */ String getFormAttributeHandler(String attributeUuid, String formConfig); + + /** + * 获取表单组件列表 + * @param formUuid 表单UUID + * @param formName 表单名 + * @param tag 标签 + * @return 组件列表 + */ + List getFormAttributeList(String formUuid, String formName, String tag); } 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 cba465d66..a0636115a 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 @@ -399,7 +399,7 @@ public class CascadeHandler extends FormHandlerBase { public void makeupFormAttribute(FormAttributeVo formAttributeVo) { Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); String dataSource = config.getString("dataSource"); if ("matrix".equals(dataSource)) { String matrixUuid = config.getString("matrixUuid"); 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 78384bae7..63d42b256 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 @@ -244,7 +244,7 @@ public class CheckboxHandler extends FormHandlerBase { public void makeupFormAttribute(FormAttributeVo formAttributeVo) { Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); String dataSource = config.getString("dataSource"); if ("matrix".equals(dataSource)) { String matrixUuid = config.getString("matrixUuid"); 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 5b2fa3c58..32b9b447c 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 @@ -241,7 +241,7 @@ public class RadioHandler extends FormHandlerBase { public void makeupFormAttribute(FormAttributeVo formAttributeVo) { Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); String dataSource = config.getString("dataSource"); if ("matrix".equals(dataSource)) { String matrixUuid = config.getString("matrixUuid"); 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 60781c6f3..608bea3cc 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 @@ -404,7 +404,7 @@ public class SelectHandler extends FormHandlerBase { public void makeupFormAttribute(FormAttributeVo formAttributeVo) { Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); String dataSource = config.getString("dataSource"); if ("matrix".equals(dataSource)) { String matrixUuid = config.getString("matrixUuid"); 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 9e1677fc8..5edaa75bd 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 @@ -690,7 +690,7 @@ public class TableInputerHandler extends FormHandlerBase { public void makeupFormAttribute(FormAttributeVo formAttributeVo) { Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); /** 扩展属性 **/ JSONArray attributeArray = config.getJSONArray("attributeList"); if (CollectionUtils.isNotEmpty(attributeArray)) { 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 215e1a342..ce69e9b22 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 @@ -539,7 +539,7 @@ public class TableSelectorHandler extends FormHandlerBase { Set integrationUuidSet = new HashSet<>(); Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); String dataSource = config.getString("dataSource"); if ("matrix".equals(dataSource)) { String matrixUuid = config.getString("matrixUuid"); diff --git a/src/main/java/neatlogic/module/framework/form/service/FormService.java b/src/main/java/neatlogic/module/framework/form/service/FormService.java index ac02865c2..985ddd843 100644 --- a/src/main/java/neatlogic/module/framework/form/service/FormService.java +++ b/src/main/java/neatlogic/module/framework/form/service/FormService.java @@ -110,4 +110,13 @@ public interface FormService { * @return */ String getFormAttributeHandler(String attributeUuid, String formConfig); + + /** + * 获取表单组件列表 + * @param formUuid 表单UUID + * @param formName 表单名 + * @param tag 标签 + * @return 组件列表 + */ + List getFormAttributeList(String formUuid, String formName, String tag); } diff --git a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java index 7454a1dea..90d7d81fb 100644 --- a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java @@ -23,11 +23,13 @@ import neatlogic.framework.dependency.core.DependencyManager; import neatlogic.framework.form.attribute.core.FormAttributeHandlerFactory; import neatlogic.framework.form.attribute.core.IFormAttributeHandler; import neatlogic.framework.form.constvalue.FormHandler; +import neatlogic.framework.form.dao.mapper.FormMapper; import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeParentVo; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.dto.FormVersionVo; import neatlogic.framework.form.exception.AttributeValidException; +import neatlogic.framework.form.exception.FormActiveVersionNotFoundExcepiton; import neatlogic.framework.form.service.IFormCrossoverService; import neatlogic.framework.matrix.constvalue.SearchExpression; import neatlogic.framework.matrix.core.IMatrixDataSourceHandler; @@ -60,6 +62,9 @@ import java.util.stream.Collectors; public class FormServiceImpl implements FormService, IFormCrossoverService { private static final Logger logger = LoggerFactory.getLogger(FormServiceImpl.class); + @Resource + private FormMapper formMapper; + @Resource private MatrixMapper matrixMapper; @@ -924,9 +929,42 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { formAttributeVo.setRequired(isRequired); String defaultValue = config.getString("defaultValue"); formAttributeVo.setData(defaultValue); - formAttributeVo.setConfig(config.toJSONString()); + formAttributeVo.setConfig(config); } formAttributeVo.setParent(parent); return formAttributeVo; } + + @Override + public List getFormAttributeList(String formUuid, String formName, String tag) { + FormVersionVo formVersion = formMapper.getActionFormVersionByFormUuid(formUuid); + if (formVersion == null) { + throw new FormActiveVersionNotFoundExcepiton(formName); + } + FormAttributeVo searchVo = new FormAttributeVo(); + searchVo.setFormUuid(formUuid); + searchVo.setFormVersionUuid(formVersion.getUuid()); + List formAttributeList = formMapper.getFormAttributeList(searchVo); + if (StringUtils.isBlank(tag)) { + return formAttributeList; + } + List resultList = new ArrayList<>(); + List parentUuidList = new ArrayList<>(); + List formExtendAttributeList = new ArrayList<>(); + List list = formMapper.getFormExtendAttributeListByFormUuidAndFormVersionUuid(formUuid, formVersion.getUuid()); + for (FormAttributeVo formAttributeVo : list) { + if (Objects.equals(formAttributeVo.getTag(), tag)) { + formExtendAttributeList.add(formAttributeVo); + parentUuidList.add(formAttributeVo.getParentUuid()); + } + } + for (FormAttributeVo formAttributeVo : formAttributeList) { + if (parentUuidList.contains(formAttributeVo.getUuid())) { + continue; + } + resultList.add(formAttributeVo); + } + resultList.addAll(formExtendAttributeList); + return resultList; + } } -- Gitee From c9b136fa291dcd2ee50b20aa7c8c02e4c1580e17 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 23 Apr 2024 17:29:37 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=A1=A8=E5=8D=95=E6=A0=87=E5=87=86?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1141293256769536]后端-自定义表单标准规范定义 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1141293256769536 --- .../form/constvalue/FormHandler.java | 3 +- .../form/attribute/handler/CustomHandler.java | 117 ++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 src/main/java/neatlogic/module/framework/form/attribute/handler/CustomHandler.java diff --git a/src/main/java/neatlogic/framework/form/constvalue/FormHandler.java b/src/main/java/neatlogic/framework/form/constvalue/FormHandler.java index a40d66c21..f63e28e82 100644 --- a/src/main/java/neatlogic/framework/form/constvalue/FormHandler.java +++ b/src/main/java/neatlogic/framework/form/constvalue/FormHandler.java @@ -40,7 +40,8 @@ public enum FormHandler implements IFormHandler { FORMRATE("formrate", "评分"), FORMTAB("formtab", "选项卡"), FORMCOLLAPSE("formcollapse", "折叠面板"), - FORMSUBASSEMBLY("formsubassembly", "子表单"); + FORMSUBASSEMBLY("formsubassembly", "子表单"), + FORMCUSTOM("formcustom", "自定义组件"); private final String handler; private final String handlerName; diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/CustomHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/CustomHandler.java new file mode 100644 index 000000000..0d2aa4cad --- /dev/null +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/CustomHandler.java @@ -0,0 +1,117 @@ +/* + * 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.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.FormHandlerBase; +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 org.springframework.stereotype.Component; + +@Component +public class CustomHandler extends FormHandlerBase { + @Override + protected JSONObject getMyDetailedData(AttributeDataVo attributeDataVo, JSONObject configObj) { + return null; + } + + @Override + public Object valueConversionText(AttributeDataVo attributeDataVo, JSONObject configObj) { + return null; + } + + @Override + public Object dataTransformationForEmail(AttributeDataVo attributeDataVo, JSONObject configObj) { + return null; + } + + @Override + public Object textConversionValue(Object text, JSONObject config) { + return null; + } + + @Override + public Object dataTransformationForExcel(AttributeDataVo attributeDataVo, JSONObject configObj) { + return null; + } + + @Override + public int getExcelHeadLength(JSONObject configObj) { + return super.getExcelHeadLength(configObj); + } + + @Override + public int getExcelRowCount(AttributeDataVo attributeDataVo, JSONObject configObj) { + return super.getExcelRowCount(attributeDataVo, configObj); + } + + @Override + public String getHandler() { + return FormHandler.FORMCUSTOM.getHandler(); + } + + @Override + public String getHandlerType(FormConditionModel model) { + return null; + } + + @Override + public ParamType getParamType() { + return null; + } + + @Override + public boolean isAudit() { + return false; + } + + @Override + public boolean isConditionable() { + return false; + } + + @Override + public boolean isProcessTaskBatchSubmissionTemplateParam() { + return false; + } + + @Override + public JSONObject valid(AttributeDataVo attributeDataVo, JSONObject configObj) throws AttributeValidException { + return null; + } + + @Override + public Object conversionDataType(Object source, String attributeLabel) { + if (source == null) { + return null; + } + if (source instanceof String) { + String sourceStr = (String) source; + if (sourceStr.startsWith("{") && sourceStr.endsWith("}")) { + return JSONObject.parse(sourceStr); + } else if (sourceStr.startsWith("[") && sourceStr.endsWith("]")) { + return JSONArray.parseArray(sourceStr); + } + } + return source; + } +} -- Gitee From 61b07465671b362b28ad12fc8f7913e980ae76a7 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 23 Apr 2024 18:03:48 +0800 Subject: [PATCH 3/4] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=A1=A8=E5=8D=95=E6=A0=87=E5=87=86?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1141293256769536]后端-自定义表单标准规范定义 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1141293256769536 --- .../framework/form/dto/FormAttributeVo.java | 34 +++++++++---------- .../restful/annotation/EntityField.java | 10 +++--- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java b/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java index bdb0471f5..ecc007a8d 100644 --- a/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java +++ b/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java @@ -31,39 +31,39 @@ import java.util.*; public class FormAttributeVo implements Serializable { private static final long serialVersionUID = 8282018124626035430L; - @EntityField(name = "属性uuid", type = ApiParamType.STRING) + @EntityField(name = "common.uuid", type = ApiParamType.STRING) private String uuid; - @EntityField(name = "表单uuid", type = ApiParamType.STRING) + @EntityField(name = "common.framework.formuuid", type = ApiParamType.STRING) private String formUuid; - @EntityField(name = "表单版本uuid", type = ApiParamType.STRING) + @EntityField(name = "common.framework.formversionuuid", type = ApiParamType.STRING) private String formVersionUuid; - @EntityField(name = "父级uuid", type = ApiParamType.STRING) + @EntityField(name = "common.parentuuid", type = ApiParamType.STRING) private String parentUuid; - @EntityField(name = "标签", type = ApiParamType.STRING) + @EntityField(name = "common.tag", type = ApiParamType.STRING) private String tag; - @EntityField(name = "属性key", type = ApiParamType.STRING) + @EntityField(name = "common.key", type = ApiParamType.STRING) private String key; - @EntityField(name = "属性标签名", type = ApiParamType.STRING) + @EntityField(name = "common.name", type = ApiParamType.STRING) private String label; - @EntityField(name = "类型", type = ApiParamType.STRING) + @EntityField(name = "common.type", type = ApiParamType.STRING) private String type; - @EntityField(name = "处理器", type = ApiParamType.STRING) + @EntityField(name = "common.handler", type = ApiParamType.STRING) private String handler; - @EntityField(name = "属性配置", type = ApiParamType.STRING) + @EntityField(name = "common.config", type = ApiParamType.STRING) private JSONObject config; - @EntityField(name = "属性数据", type = ApiParamType.STRING) + @EntityField(name = "common.data", type = ApiParamType.STRING) private String data; - @EntityField(name = "是否必填", type = ApiParamType.BOOLEAN) + @EntityField(name = "common.isrequired", type = ApiParamType.BOOLEAN) private boolean isRequired; - @EntityField(name = "表达式列表", type = ApiParamType.JSONARRAY) + @EntityField(name = "common.expressionlist", type = ApiParamType.JSONARRAY) List expressionList; - @EntityField(name = "默认表达式", type = ApiParamType.JSONOBJECT) + @EntityField(name = "common.defaultexpression", type = ApiParamType.JSONOBJECT) ExpressionVo defaultExpression; - @EntityField(name = "供前端渲染时判断,如果为false则前端页面需使用默认config,true则使用表单管理编辑保存的config", type = ApiParamType.BOOLEAN) + @EntityField(name = "common.framework.isuseformconfig", type = ApiParamType.BOOLEAN) private boolean isUseFormConfig; - @EntityField(name = "服务uuid,当表单属性作为工单中心搜索条件时需要使用此属性进行对应", type = ApiParamType.STRING) + @EntityField(name = "term.itsm.channeluuid", type = ApiParamType.STRING, help = "当表单属性作为工单中心搜索条件时需要使用此属性进行对应") private String channelUuid; - @EntityField(name = "条件模型") + @EntityField(name = "common.framework.formconditionmodel") private FormConditionModel conditionModel = FormConditionModel.CUSTOM; @JSONField(serialize = false) diff --git a/src/main/java/neatlogic/framework/restful/annotation/EntityField.java b/src/main/java/neatlogic/framework/restful/annotation/EntityField.java index 905cfc531..41021d2b8 100755 --- a/src/main/java/neatlogic/framework/restful/annotation/EntityField.java +++ b/src/main/java/neatlogic/framework/restful/annotation/EntityField.java @@ -1,13 +1,9 @@ package neatlogic.framework.restful.annotation; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - import neatlogic.framework.common.constvalue.ApiParamType; +import java.lang.annotation.*; + @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) @Documented @@ -19,4 +15,6 @@ public @interface EntityField { Class member() default NotDefined.class;// 值成员 + String help() default ""; + } -- Gitee From c3973d1540d0e1db5d1a435a9f03ece3e3c1b03b Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 23 Apr 2024 19:08:30 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=A1=A8=E5=8D=95=E6=A0=87=E5=87=86?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1141293256769536]后端-自定义表单标准规范定义 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1141293256769536 --- .../neatlogic/framework/form/dto/FormAttributeVo.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java b/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java index ecc007a8d..e420eac30 100644 --- a/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java +++ b/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java @@ -33,9 +33,9 @@ public class FormAttributeVo implements Serializable { private static final long serialVersionUID = 8282018124626035430L; @EntityField(name = "common.uuid", type = ApiParamType.STRING) private String uuid; - @EntityField(name = "common.framework.formuuid", type = ApiParamType.STRING) + @EntityField(name = "term.framework.formuuid", type = ApiParamType.STRING) private String formUuid; - @EntityField(name = "common.framework.formversionuuid", type = ApiParamType.STRING) + @EntityField(name = "term.framework.formversionuuid", type = ApiParamType.STRING) private String formVersionUuid; @EntityField(name = "common.parentuuid", type = ApiParamType.STRING) private String parentUuid; @@ -59,11 +59,11 @@ public class FormAttributeVo implements Serializable { List expressionList; @EntityField(name = "common.defaultexpression", type = ApiParamType.JSONOBJECT) ExpressionVo defaultExpression; - @EntityField(name = "common.framework.isuseformconfig", type = ApiParamType.BOOLEAN) + @EntityField(name = "nffd.formattributevo.entityfield.name", type = ApiParamType.BOOLEAN) private boolean isUseFormConfig; @EntityField(name = "term.itsm.channeluuid", type = ApiParamType.STRING, help = "当表单属性作为工单中心搜索条件时需要使用此属性进行对应") private String channelUuid; - @EntityField(name = "common.framework.formconditionmodel") + @EntityField(name = "term.framework.conditionmodel") private FormConditionModel conditionModel = FormConditionModel.CUSTOM; @JSONField(serialize = false) -- Gitee