From 05ec24956c7b626175660f3cadb093df51656aeb Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Mon, 13 May 2024 17:34:33 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=89=A9=E5=B1=95=E5=B1=9E=E6=80=A7=E9=85=8D?= =?UTF-8?q?=E7=BD=AEformExtendConfig=E6=94=BE=E5=9C=A8=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E9=85=8D=E7=BD=AEformConfig=E5=86=85=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1155818207019008]后端-表单扩展属性配置formExtendConfig放在表单配置formConfig内部 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1155818207019008 --- .../module/tenant/api/form/FormCopyApi.java | 15 ------ .../module/tenant/api/form/FormExportApi.java | 14 ++---- .../module/tenant/api/form/FormImportApi.java | 1 + .../module/tenant/api/form/FormSaveApi.java | 47 +++---------------- .../tenant/api/form/FormVersionExportApi.java | 9 +--- .../tenant/api/form/FormVersionImportApi.java | 1 + .../tenant/api/util/JavascriptTestApi.java | 6 +-- 7 files changed, 15 insertions(+), 78 deletions(-) diff --git a/src/main/java/neatlogic/module/tenant/api/form/FormCopyApi.java b/src/main/java/neatlogic/module/tenant/api/form/FormCopyApi.java index 09d6aabe..cfdd240e 100644 --- a/src/main/java/neatlogic/module/tenant/api/form/FormCopyApi.java +++ b/src/main/java/neatlogic/module/tenant/api/form/FormCopyApi.java @@ -89,8 +89,6 @@ public class FormCopyApi extends PrivateApiComponentBase { newFrom.setIsActive(formVo.getIsActive()); Map formAttributeOldUuid2NewUuidMap = new HashMap<>(); FormVersionVo newFormVersion = copyFormVersion(formVersionVo, newFrom.getUuid(), formAttributeOldUuid2NewUuidMap); - List formVersionExtendAttributeList = copyFormVersionExtendAttributeList(formVersionVo.getFormUuid(), formVersionVo.getUuid(), newFormVersion.getFormUuid(), newFormVersion.getUuid(), formAttributeOldUuid2NewUuidMap); - newFormVersion.setFormExtendAttributeList(formVersionExtendAttributeList); newFormVersionList.add(newFormVersion); } else if(StringUtils.isNotBlank(uuid)) { FormVo formVo = formMapper.getFormByUuid(uuid); @@ -102,8 +100,6 @@ public class FormCopyApi extends PrivateApiComponentBase { for (FormVersionVo formVersionVo : formVersionList) { Map formAttributeOldUuid2NewUuidMap = new HashMap<>(); FormVersionVo newFormVersion = copyFormVersion(formVersionVo, newFrom.getUuid(), formAttributeOldUuid2NewUuidMap); - List formVersionExtendAttributeList = copyFormVersionExtendAttributeList(formVersionVo.getFormUuid(), formVersionVo.getUuid(), newFormVersion.getFormUuid(), newFormVersion.getUuid(), formAttributeOldUuid2NewUuidMap); - newFormVersion.setFormExtendAttributeList(formVersionExtendAttributeList); newFormVersionList.add(newFormVersion); } } else { @@ -199,15 +195,4 @@ public class FormCopyApi extends PrivateApiComponentBase { formVersionVo.setFormConfig(JSONObject.parseObject(content)); return formVersionVo; } - - private List copyFormVersionExtendAttributeList(String oldFormUuid, String oldFormVersionUuid, String newFormUuid, String newFormVersionUuid, Map formAttributeOldUuid2NewUuidMap) { - List formExtendAttributeList = formMapper.getFormExtendAttributeListByFormUuidAndFormVersionUuid(oldFormUuid, oldFormVersionUuid); - for (FormAttributeVo formAttributeVo : formExtendAttributeList) { - String newParentUuid = formAttributeOldUuid2NewUuidMap.get(formAttributeVo.getParentUuid()); - formAttributeVo.setParentUuid(newParentUuid); - formAttributeVo.setFormUuid(newFormUuid); - formAttributeVo.setFormVersionUuid(newFormVersionUuid); - } - return formExtendAttributeList; - } } diff --git a/src/main/java/neatlogic/module/tenant/api/form/FormExportApi.java b/src/main/java/neatlogic/module/tenant/api/form/FormExportApi.java index baa66a9f..38ccbc09 100644 --- a/src/main/java/neatlogic/module/tenant/api/form/FormExportApi.java +++ b/src/main/java/neatlogic/module/tenant/api/form/FormExportApi.java @@ -15,9 +15,9 @@ along with this program. If not, see .*/ package neatlogic.module.tenant.api.form; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.form.dao.mapper.FormMapper; -import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.dto.FormVersionVo; import neatlogic.framework.form.dto.FormVo; import neatlogic.framework.form.exception.FormNotFoundException; @@ -27,8 +27,6 @@ import neatlogic.framework.restful.annotation.OperationType; import neatlogic.framework.restful.annotation.Param; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateBinaryStreamApiComponentBase; -import com.alibaba.fastjson.JSONObject; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -78,14 +76,8 @@ public class FormExportApi extends PrivateBinaryStreamApiComponentBase { throw new FormNotFoundException(uuid); } //获取表单的所有版本 - List formVersionLsit = formMapper.getFormVersionByFormUuid(uuid); - for (FormVersionVo formVersion : formVersionLsit) { - List formExtendAttributeList = formMapper.getFormExtendAttributeListByFormUuidAndFormVersionUuid(formVersion.getFormUuid(), formVersion.getUuid()); - if (CollectionUtils.isNotEmpty(formExtendAttributeList)) { - formVersion.setFormExtendAttributeList(formExtendAttributeList); - } - } - formVo.setVersionList(formVersionLsit); + List formVersionList = formMapper.getFormVersionByFormUuid(uuid); + formVo.setVersionList(formVersionList); //设置导出文件名, 表单名称_版本号 String fileNameEncode = formVo.getName() + ".form"; diff --git a/src/main/java/neatlogic/module/tenant/api/form/FormImportApi.java b/src/main/java/neatlogic/module/tenant/api/form/FormImportApi.java index 8e0a3337..0e0a2a44 100755 --- a/src/main/java/neatlogic/module/tenant/api/form/FormImportApi.java +++ b/src/main/java/neatlogic/module/tenant/api/form/FormImportApi.java @@ -133,6 +133,7 @@ public class FormImportApi extends PrivateBinaryStreamApiComponentBase { //如果导入的表单版本已存在, 且表单uuid相同, 则覆盖,反之,新增一个版本 if (existsFormVersionVo != null && existsFormVersionVo.getFormUuid().equals(formVo.getUuid())) { formMapper.updateFormVersion(formVersion); + formMapper.deleteFormExtendAttributeByFormUuidAndFormVersionUuid(formVersion.getFormUuid(), formVersion.getUuid()); resultList.add("版本" + existsFormVersionVo.getVersion() + "被覆盖"); } else { Integer version = formMapper.getMaxVersionByFormUuid(formVo.getUuid()); diff --git a/src/main/java/neatlogic/module/tenant/api/form/FormSaveApi.java b/src/main/java/neatlogic/module/tenant/api/form/FormSaveApi.java index 8b079575..167a309e 100644 --- a/src/main/java/neatlogic/module/tenant/api/form/FormSaveApi.java +++ b/src/main/java/neatlogic/module/tenant/api/form/FormSaveApi.java @@ -1,11 +1,9 @@ package neatlogic.module.tenant.api.form; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.auth.label.FORM_MODIFY; import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.crossover.CrossoverServiceFactory; import neatlogic.framework.dto.FieldValidResultVo; import neatlogic.framework.form.dao.mapper.FormMapper; import neatlogic.framework.form.dto.FormAttributeVo; @@ -14,7 +12,6 @@ import neatlogic.framework.form.dto.FormVo; import neatlogic.framework.form.exception.FormAttributeNameIsRepeatException; import neatlogic.framework.form.exception.FormNameRepeatException; import neatlogic.framework.form.exception.FormVersionNotFoundException; -import neatlogic.framework.form.service.IFormCrossoverService; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.IValid; @@ -23,7 +20,6 @@ import neatlogic.framework.util.FormUtil; import neatlogic.framework.util.RegexUtils; import neatlogic.framework.util.UuidUtil; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -61,8 +57,7 @@ public class FormSaveApi extends PrivateApiComponentBase { @Param(name = "uuid", type = ApiParamType.STRING, desc = "common.uuid", isRequired = true), @Param(name = "name", type = ApiParamType.REGEX, rule = RegexUtils.NAME, isRequired = true, maxLength = 50, desc = "common.name"), @Param(name = "currentVersionUuid", type = ApiParamType.STRING, desc = "common.versionuuid", help = "当前版本的uuid,为空代表创建一个新版本"), - @Param(name = "formConfig", type = ApiParamType.JSONOBJECT, desc = "common.config", isRequired = true), - @Param(name = "formExtendConfig", type = ApiParamType.JSONOBJECT, desc = "common.config") + @Param(name = "formConfig", type = ApiParamType.JSONOBJECT, desc = "common.config", isRequired = true) }) @Output({ @Param(name = "uuid", type = ApiParamType.STRING, desc = "common.uuid"), @@ -79,7 +74,6 @@ public class FormSaveApi extends PrivateApiComponentBase { boolean updateFormConfig = true; boolean formIsExists = false; Integer oldFormVersionIsActive = 0; - IFormCrossoverService formCrossoverService = CrossoverServiceFactory.getApi(IFormCrossoverService.class); FormVo oldFormVo = formMapper.getFormByUuid(formUuid); if (oldFormVo != null) { formIsExists = true; @@ -189,40 +183,11 @@ public class FormSaveApi extends PrivateApiComponentBase { formMapper.insertFormAttribute(formAttributeVo); } } - } - formMapper.deleteFormExtendAttributeByFormUuidAndFormVersionUuid(formUuid, formVersionVo.getUuid()); - JSONObject formExtendConfig = jsonObj.getJSONObject("formExtendConfig"); - if (MapUtils.isNotEmpty(formExtendConfig)) { - JSONArray attributeArray = formExtendConfig.getJSONArray("attributeList"); - if (CollectionUtils.isNotEmpty(attributeArray)) { - for (int i = 0; i < attributeArray.size(); i++) { - JSONObject attributeObj = attributeArray.getJSONObject(i); - if (MapUtils.isEmpty(attributeObj)) { - continue; - } - String parentUuid = attributeObj.getString("parentUuid"); - String newParentUuid = formAttributeOldUuid2NewUuidMap.get(parentUuid); - if (StringUtils.isNotBlank(newParentUuid)) { - parentUuid = newParentUuid; - } - String tag = attributeObj.getString("tag"); - String key = attributeObj.getString("key"); - String uuid = UuidUtil.getCustomUUID(parentUuid + "#" + tag + "#" + key); - String label = attributeObj.getString("label"); - String type = attributeObj.getString("type"); - String handler = attributeObj.getString("handler"); - JSONObject config = attributeObj.getJSONObject("config"); - FormAttributeVo formAttributeVo = new FormAttributeVo(); - formAttributeVo.setFormUuid(formUuid); - formAttributeVo.setFormVersionUuid(formVersionVo.getUuid()); - formAttributeVo.setParentUuid(parentUuid); - formAttributeVo.setTag(tag); - formAttributeVo.setKey(key); - formAttributeVo.setUuid(uuid); - formAttributeVo.setLabel(label); - formAttributeVo.setType(type); - formAttributeVo.setHandler(handler); - formAttributeVo.setConfig(config); + // 表单扩展属性 + formMapper.deleteFormExtendAttributeByFormUuidAndFormVersionUuid(formUuid, formVersionVo.getUuid()); + List formExtendAttributeList = formVersionVo.getFormExtendAttributeList(); + if (CollectionUtils.isNotEmpty(formExtendAttributeList)) { + for (FormAttributeVo formAttributeVo : formExtendAttributeList) { formMapper.insertFormExtendAttribute(formAttributeVo); } } diff --git a/src/main/java/neatlogic/module/tenant/api/form/FormVersionExportApi.java b/src/main/java/neatlogic/module/tenant/api/form/FormVersionExportApi.java index 5b521cee..d3971108 100644 --- a/src/main/java/neatlogic/module/tenant/api/form/FormVersionExportApi.java +++ b/src/main/java/neatlogic/module/tenant/api/form/FormVersionExportApi.java @@ -15,9 +15,9 @@ along with this program. If not, see .*/ package neatlogic.module.tenant.api.form; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.form.dao.mapper.FormMapper; -import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.dto.FormVersionVo; import neatlogic.framework.form.dto.FormVo; import neatlogic.framework.form.exception.FormNotFoundException; @@ -28,8 +28,6 @@ import neatlogic.framework.restful.annotation.OperationType; import neatlogic.framework.restful.annotation.Param; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateBinaryStreamApiComponentBase; -import com.alibaba.fastjson.JSONObject; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -41,7 +39,6 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; -import java.util.List; @Service @@ -83,10 +80,6 @@ public class FormVersionExportApi extends PrivateBinaryStreamApiComponentBase { if (formVo == null) { throw new FormNotFoundException(formVersion.getFormUuid()); } - List formExtendAttributeList = formMapper.getFormExtendAttributeListByFormUuidAndFormVersionUuid(formVersion.getFormUuid(), formVersion.getUuid()); - if (CollectionUtils.isNotEmpty(formExtendAttributeList)) { - formVersion.setFormExtendAttributeList(formExtendAttributeList); - } formVersion.setFormName(formVo.getName()); //设置导出文件名, 表单名称_版本号 String fileNameEncode = formVersion.getFormName() + "_" + formVersion.getVersion() + ".formversion"; diff --git a/src/main/java/neatlogic/module/tenant/api/form/FormVersionImportApi.java b/src/main/java/neatlogic/module/tenant/api/form/FormVersionImportApi.java index ff6e382f..0fc407c0 100755 --- a/src/main/java/neatlogic/module/tenant/api/form/FormVersionImportApi.java +++ b/src/main/java/neatlogic/module/tenant/api/form/FormVersionImportApi.java @@ -101,6 +101,7 @@ public class FormVersionImportApi extends PrivateBinaryStreamApiComponentBase { if (existsFormVersionVo != null && existsFormVersionVo.getFormUuid().equals(uuid)) { formVersionVo.setIsActive(existsFormVersionVo.getIsActive()); formMapper.updateFormVersion(formVersionVo); + formMapper.deleteFormExtendAttributeByFormUuidAndFormVersionUuid(uuid, formVersionVo.getUuid()); resultObj.put("versionUuid", formVersionVo.getUuid()); resultObj.put("result", "版本" + existsFormVersionVo.getVersion() + "被覆盖"); } else { diff --git a/src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java b/src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java index 85bcf6f7..8c66b2c6 100644 --- a/src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java +++ b/src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java @@ -34,7 +34,7 @@ public class JavascriptTestApi extends PrivateApiComponentBase { } @Input({ - @Param(name = "param", type = ApiParamType.STRING, isRequired = true, desc = "参数"), + @Param(name = "data", type = ApiParamType.STRING, isRequired = true, desc = "参数"), @Param(name = "script", type = ApiParamType.STRING, isRequired = true, desc = "脚本") }) @Output({ @@ -43,10 +43,10 @@ public class JavascriptTestApi extends PrivateApiComponentBase { @Description(desc = "") @Override public Object myDoService(JSONObject jsonObj) throws Exception { - JSONObject param = jsonObj.getJSONObject("param"); + JSONObject data = jsonObj.getJSONObject("data"); String script = jsonObj.getString("script"); JSONObject paramObj = new JSONObject(); - paramObj.put("data", param); + paramObj.put("data", data); Object returnValue = JavascriptUtil.runScript(paramObj, script); Boolean result = Boolean.parseBoolean(returnValue.toString()); JSONObject resultObj = new JSONObject(); -- Gitee