From 172ece732bd314b9833359433e0fe1cb7e6076e4 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 23 Apr 2024 17:27:10 +0800 Subject: [PATCH 1/2] =?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 --- .../module/tenant/api/form/FormSaveApi.java | 40 ++++++++++- .../api/form/GetFormAttributeListApi.java | 72 +++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 src/main/java/neatlogic/module/tenant/api/form/GetFormAttributeListApi.java 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 c16ef905..8f6fd5b4 100644 --- a/src/main/java/neatlogic/module/tenant/api/form/FormSaveApi.java +++ b/src/main/java/neatlogic/module/tenant/api/form/FormSaveApi.java @@ -1,5 +1,6 @@ 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; @@ -21,6 +22,7 @@ import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; 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; @@ -60,7 +62,8 @@ 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 = "formConfig", type = ApiParamType.JSONOBJECT, desc = "common.config", isRequired = true), + @Param(name = "formExtendConfig", type = ApiParamType.JSONOBJECT, desc = "common.config") }) @Output({ @Param(name = "uuid", type = ApiParamType.STRING, desc = "common.uuid"), @@ -119,6 +122,8 @@ public class FormSaveApi extends PrivateApiComponentBase { } else { formVersionVo.getUuid(); } + String mainSceneUuid = formVo.getFormConfig().getString("uuid"); + formVersionVo.setSceneUuid(mainSceneUuid); List formAttributeList = formVersionVo.getFormAttributeList(); if (CollectionUtils.isNotEmpty(formAttributeList)) { //判断组件名是否重复 @@ -185,6 +190,39 @@ public class FormSaveApi extends PrivateApiComponentBase { } } } + formMapper.deleteFormExtendAttributeByFormUuidAndFormVersionUuid(formUuid, currentVersionUuid); + 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 tag = attributeObj.getString("tag"); + String key = attributeObj.getString("key"); + String uuid = UuidUtil.getCustomUUID(parentUuid + "#" + 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(currentVersionUuid); + 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.insertFormExtendAttribute(formAttributeVo); + } + } + } return resultObj; } } diff --git a/src/main/java/neatlogic/module/tenant/api/form/GetFormAttributeListApi.java b/src/main/java/neatlogic/module/tenant/api/form/GetFormAttributeListApi.java new file mode 100644 index 00000000..c7198fe0 --- /dev/null +++ b/src/main/java/neatlogic/module/tenant/api/form/GetFormAttributeListApi.java @@ -0,0 +1,72 @@ +/* + * 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.tenant.api.form; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.form.dao.mapper.FormMapper; +import neatlogic.framework.form.dto.FormAttributeVo; +import neatlogic.framework.form.dto.FormVo; +import neatlogic.framework.form.exception.FormNotFoundException; +import neatlogic.framework.form.service.IFormCrossoverService; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service + +@OperationType(type = OperationTypeEnum.SEARCH) +public class GetFormAttributeListApi extends PrivateApiComponentBase { + + @Resource + private FormMapper formMapper; + + @Override + public String getName() { + return "nmtaf.getformattributelistapi.getname"; + } + + @Input({ + @Param(name = "formUuid", type = ApiParamType.STRING, desc = "common.uuid", isRequired = true), + @Param(name = "tag", type = ApiParamType.STRING, desc = "common.tag") + }) + @Output({ + @Param(name = "tbodyList", explode = FormAttributeVo[].class, desc = "common.tbodylist") + }) + @Description(desc = "nmtaf.getformattributelistapi.getname") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + String formUuid = paramObj.getString("formUuid"); + String tag = paramObj.getString("tag"); + FormVo form = formMapper.getFormByUuid(formUuid); + if (form == null) { + throw new FormNotFoundException(formUuid); + } + IFormCrossoverService formCrossoverService = CrossoverServiceFactory.getApi(IFormCrossoverService.class); + return formCrossoverService.getFormAttributeList(formUuid, form.getName(), tag); + } + + @Override + public String getToken() { + return "form/attribute/list"; + } +} -- Gitee From a00db09df96608db7cf6f389795ef8a9b59acfa4 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 23 Apr 2024 19:09:15 +0800 Subject: [PATCH 2/2] =?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 --- .../module/tenant/api/form/GetFormAttributeListApi.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/neatlogic/module/tenant/api/form/GetFormAttributeListApi.java b/src/main/java/neatlogic/module/tenant/api/form/GetFormAttributeListApi.java index c7198fe0..9cacd147 100644 --- a/src/main/java/neatlogic/module/tenant/api/form/GetFormAttributeListApi.java +++ b/src/main/java/neatlogic/module/tenant/api/form/GetFormAttributeListApi.java @@ -46,7 +46,7 @@ public class GetFormAttributeListApi extends PrivateApiComponentBase { } @Input({ - @Param(name = "formUuid", type = ApiParamType.STRING, desc = "common.uuid", isRequired = true), + @Param(name = "formUuid", type = ApiParamType.STRING, desc = "term.framework.formuuid", isRequired = true), @Param(name = "tag", type = ApiParamType.STRING, desc = "common.tag") }) @Output({ -- Gitee