From 35b235c0518a6eb754ade8f23c8bf27d3e0f1827 Mon Sep 17 00:00:00 2001 From: sunhongfei01 Date: Thu, 27 Feb 2025 16:32:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E6=A8=A1=E5=9E=8B=E6=9D=83=E9=99=90=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 实现视图模型权限的加载/保存接口及DTO定义 - 集成安全权限服务,支持功能权限与数据权限管理 - 新增权限操作相关REST端点(/loadViewModel,/saveViewModel) - 修复权限ID校验正则表达式问题 - 添加权限操作失败的错误码及异常处理 - 更新pom依赖引入caf安全框架组件 --- pom.xml | 7 + .../viewobject_model_designtime.en.properties | 1 + .../viewobject_model_designtime.properties | 1 + ...wobject_model_designtime.zh-CHT.properties | 1 + view-object-api/pom.xml | 4 + .../formserver/vmapi/ViewModelService.java | 51 ++++++ .../vmapi/dto/ViewModelAuthInfoDto.java | 55 ++++++ .../vmapi/dto/ViewModelAuthSecurityDto.java | 52 ++++++ .../vmapi/dto/ViewModelExtendDto.java | 35 ++++ .../vmapi/dto/ViewModelHelpInfoDto.java | 34 ++++ view-object-manager/pom.xml | 9 + .../vmmanager/BffMetadataEventListener.java | 18 +- .../vmmanager/config/VMManagerConfig.java | 24 +++ .../exception/VoManagerErrorCodes.java | 4 + .../service/ViewModelServiceImpl.java | 172 ++++++++++++++++++ .../service/WebControllerService.java | 18 +- .../viewmodel/dto/SaveViewModelDto.java | 43 +++++ .../webapi/BffWebApiServiceConfig.java | 29 ++- .../viewmodel/webapi/ViewModelController.java | 81 ++++++--- 19 files changed, 600 insertions(+), 39 deletions(-) create mode 100644 view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/ViewModelService.java create mode 100644 view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelAuthInfoDto.java create mode 100644 view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelAuthSecurityDto.java create mode 100644 view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelExtendDto.java create mode 100644 view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelHelpInfoDto.java create mode 100644 view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/ViewModelServiceImpl.java create mode 100644 view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/dto/SaveViewModelDto.java diff --git a/pom.xml b/pom.xml index 0157175..4cc2c2a 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,7 @@ 0.1.0 0.1.9 0.3.5 + 0.2.55 @@ -266,6 +267,12 @@ wf-bizprocess-api ${wf-bizprocess-server.version} + + + io.iec.edp + caf-framework-securityentry-api + ${caf-runtime-framework.version} + diff --git a/resources/en/viewobject_model_designtime.en.properties b/resources/en/viewobject_model_designtime.en.properties index 69a5f99..6cb0ac1 100644 --- a/resources/en/viewobject_model_designtime.en.properties +++ b/resources/en/viewobject_model_designtime.en.properties @@ -106,6 +106,7 @@ GSP_VIEWOBJECT_MANAGER_0107=The field [{1}] on the object [{0}] has no mapped fi GSP_VIEWOBJECT_MANAGER_0108=The [length] of the field [{1}] on the object [{0}] cannot be greater than the length of the field on the business entity [{2}]. GSP_VIEWOBJECT_MANAGER_0109=The [precision] of the field [{1}] on the object [{0}] cannot be greater than the precision of the field on the business entity [{2}]. GSP_VIEWOBJECT_MANAGER_0110=The operation [{0}] has no mapped operation on the business entity, the ID of the custom operation on the business entity is [{1}], please check if it has been deleted. +GSP_VIEWOBJECT_MANAGER_0111=View Object [{0}] save failed GSP_VIEWOBJECT_MANAGER_MESSAGE_0001=View object [{0}:{1}] synchronization code check for operation [{2}:{3}] # view-object-model GSP_VIEWOBJECT_MODEL_1001=View operations on view object are currently not supported for clone operation diff --git a/resources/viewobject_model_designtime.properties b/resources/viewobject_model_designtime.properties index a620301..6b86dc4 100644 --- a/resources/viewobject_model_designtime.properties +++ b/resources/viewobject_model_designtime.properties @@ -106,6 +106,7 @@ GSP_VIEWOBJECT_MANAGER_0107=\u5BF9\u8C61[{0}]\u4E0A\u7684\u5B57\u6BB5[{1}]\u5728 GSP_VIEWOBJECT_MANAGER_0108=\u5BF9\u8C61[{0}]\u4E0A\u7684\u5B57\u6BB5[{1}]\u7684[\u957F\u5EA6]\u4E0D\u80FD\u5927\u4E8E\u4E1A\u52A1\u5B9E\u4F53\u4E0A\u5B57\u6BB5\u957F\u5EA6[{2}]\u3002 GSP_VIEWOBJECT_MANAGER_0109=\u5BF9\u8C61[{0}]\u4E0A\u7684\u5B57\u6BB5[{1}]\u7684[\u7CBE\u5EA6]\u4E0D\u80FD\u5927\u4E8E\u4E1A\u52A1\u5B9E\u4F53\u4E0A\u5B57\u6BB5\u7CBE\u5EA6[{2}]\u3002 GSP_VIEWOBJECT_MANAGER_0110=\u64CD\u4F5C[{0}]\u5728\u4E1A\u52A1\u5B9E\u4F53\u4E0A\u65E0\u6620\u5C04\u64CD\u4F5C\uFF0C\u4E1A\u52A1\u5B9E\u4F53\u81EA\u5B9A\u4E49\u64CD\u4F5C\u7684ID=[{1}],\u8BF7\u68C0\u67E5\u662F\u5426\u5DF2\u5220\u9664\u3002 +GSP_VIEWOBJECT_MANAGER_0111=\u89C6\u56FE\u5BF9\u8C61[{0}]\u4FDD\u5B58\u5931\u8D25 GSP_VIEWOBJECT_MANAGER_MESSAGE_0001=\u89C6\u56FE\u5BF9\u8C61[{0}:{1}]\u4E0A\u64CD\u4F5C[{2}:{3}]\u540C\u6B65\u4EE3\u7801\u68C0\u67E5 # view-object-model GSP_VIEWOBJECT_MODEL_1001=\u89C6\u56FE\u5BF9\u8C61\u4E0A\u7684\u89C6\u56FE\u64CD\u4F5C\u6682\u4E0D\u652F\u6301\u62F7\u8D1D\u64CD\u4F5C diff --git a/resources/zh-CHT/viewobject_model_designtime.zh-CHT.properties b/resources/zh-CHT/viewobject_model_designtime.zh-CHT.properties index 5b67ae0..387b8ae 100644 --- a/resources/zh-CHT/viewobject_model_designtime.zh-CHT.properties +++ b/resources/zh-CHT/viewobject_model_designtime.zh-CHT.properties @@ -106,6 +106,7 @@ GSP_VIEWOBJECT_MANAGER_0107=\u5C0D\u8C61[{0}]\u4E0A\u7684\u5B57\u6BB5[{1}]\u5728 GSP_VIEWOBJECT_MANAGER_0108=\u5C0D\u8C61[{0}]\u4E0A\u7684\u5B57\u6BB5[{1}]\u7684[\u9577\u5EA6]\u4E0D\u80FD\u5927\u65BC\u696D\u52D9\u5BE6\u9AD4\u4E0A\u5B57\u6BB5\u9577\u5EA6[{2}]\u3002 GSP_VIEWOBJECT_MANAGER_0109=\u5C0D\u8C61[{0}]\u4E0A\u7684\u5B57\u6BB5[{1}]\u7684[\u7CBE\u5EA6]\u4E0D\u80FD\u5927\u65BC\u696D\u52D9\u5BE6\u9AD4\u4E0A\u5B57\u6BB5\u7CBE\u5EA6[{2}]\u3002 GSP_VIEWOBJECT_MANAGER_0110=\u64CD\u4F5C[{0}]\u5728\u696D\u52D9\u5BE6\u9AD4\u4E0A\u7121\u6620\u5C04\u64CD\u4F5C\uFF0C\u696D\u52D9\u5BE6\u9AD4\u81EA\u5B9A\u7FA9\u64CD\u4F5C\u7684ID=[{1}],\u8ACB\u6AA2\u67E5\u662F\u5426\u5DF2\u522A\u9664\u3002 +GSP_VIEWOBJECT_MANAGER_0111=\u8996\u5716\u5C0D\u8C61[{0}]\u4FDD\u5B58\u5931\u6557 GSP_VIEWOBJECT_MANAGER_MESSAGE_0001=\u8996\u5716\u5C0D\u8C61[{0}:{1}]\u4E0A\u64CD\u4F5C[{2}:{3}]\u540C\u6B65\u4EE3\u78BC\u6AA2\u67E5 # view-object-model GSP_VIEWOBJECT_MODEL_1001=\u8996\u5716\u5C0D\u8C61\u4E0A\u7684\u8996\u5716\u64CD\u4F5C\u66AB\u4E0D\u652F\u6301\u62F7\u8C9D\u64CD\u4F5C diff --git a/view-object-api/pom.xml b/view-object-api/pom.xml index 5bae2b5..4be6bb5 100644 --- a/view-object-api/pom.xml +++ b/view-object-api/pom.xml @@ -32,6 +32,10 @@ compile ${project.version} + + io.iec.edp + caf-framework-securityentry-api + \ No newline at end of file diff --git a/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/ViewModelService.java b/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/ViewModelService.java new file mode 100644 index 0000000..cfa06e5 --- /dev/null +++ b/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/ViewModelService.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.formserver.vmapi; + +import com.inspur.edp.formserver.vmapi.dto.ViewModelAuthInfoDto; +import com.inspur.edp.formserver.vmapi.dto.ViewModelExtendDto; + +import java.util.Set; + +/** + * 视图模型服务 + * @author sunhongfei01 + * @since 2025-02-26 + */ +public interface ViewModelService { + /** + * 加载视图模型扩展信息 + * @param viewModelId 视图模型id + * @return 视图模型扩展信息 + */ + ViewModelExtendDto getViewModelExtendInfo(String viewModelId); + + /** + * 保存视图模型扩展信息 + * @param viewModelId 视图模型id + * @param viewModelExtendInfo 待保存的视图模型扩展信息 + * @param authIdsToDelete 待删除的权限id集合 + */ + void saveViewModelExtendInfo(String viewModelId, ViewModelExtendDto viewModelExtendInfo, Set authIdsToDelete); + + /** + * 获取视图模型权限信息 + * @param viewModelId 视图模型id + * @return 视图模型权限信息 + */ + ViewModelAuthInfoDto loadViewModelAuthInfo(String viewModelId); +} diff --git a/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelAuthInfoDto.java b/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelAuthInfoDto.java new file mode 100644 index 0000000..7d3a6b4 --- /dev/null +++ b/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelAuthInfoDto.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.formserver.vmapi.dto; + +import io.iec.edp.caf.securityentry.api.data.SecurityEntry; +import io.iec.edp.caf.securityentry.api.data.SecurityEntry4RuleDTO; +import lombok.Getter; +import lombok.Setter; + +import java.util.HashMap; +import java.util.Map; + +/** + * 视图模型权限信息DTO + * @author sunhongfei01 + * @since 2025-02-26 + */ +@Getter +@Setter +public class ViewModelAuthInfoDto { + // 功能权限 + private SecurityEntry funcSecurity; + // 数据权限, key为节点编码路径 + private Map authSecurityMap = new HashMap<>(); + // 列权限, key为节点编码路径 + private SecurityEntry columnSecurity; + + /** + * 添加数据权限 + * @param code 数据权限归属的节点编码 + * @param securityEntry 数据权限 + * @param entry4RuleDTO 规则权限 + */ + public void addAuthSecurityEntry(String code, SecurityEntry securityEntry, SecurityEntry4RuleDTO entry4RuleDTO) { + // 如果数据权限和规则权限都为空,则不添加 + if (securityEntry == null && entry4RuleDTO == null) { + return; + } + authSecurityMap.put(code, new ViewModelAuthSecurityDto(securityEntry, entry4RuleDTO)); + } +} diff --git a/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelAuthSecurityDto.java b/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelAuthSecurityDto.java new file mode 100644 index 0000000..66fd072 --- /dev/null +++ b/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelAuthSecurityDto.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.formserver.vmapi.dto; + +import io.iec.edp.caf.securityentry.api.data.SecurityEntry; +import io.iec.edp.caf.securityentry.api.data.SecurityEntry4RuleDTO; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * 视图模型数据权限信息DTO + * @author sunhongfei01 + * @since 2025-02-26 + */ +@Getter +@Setter +@NoArgsConstructor +public class ViewModelAuthSecurityDto { + // 是否使用规则权限 + private boolean permRule; + // 普通数据权限 + private SecurityEntry authSecurityEntry; + // 规则权限 + private SecurityEntry4RuleDTO permSecurityEntry; + + /** + * 构造函数 + * @param securityEntry 数据权限 + * @param entry4RuleDTO 规则权限 + */ + public ViewModelAuthSecurityDto(SecurityEntry securityEntry, SecurityEntry4RuleDTO entry4RuleDTO) { + this.authSecurityEntry = securityEntry; + this.permSecurityEntry = entry4RuleDTO; + // 是否使用规则权限: 如果规则权限不为空,则使用规则权限 + this.permRule = entry4RuleDTO != null; + } +} diff --git a/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelExtendDto.java b/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelExtendDto.java new file mode 100644 index 0000000..21f1eb0 --- /dev/null +++ b/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelExtendDto.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.formserver.vmapi.dto; + +import lombok.Getter; +import lombok.Setter; + +/** + * 视图模型扩展信息DTO + * @author sunhongfei01 + * @since 2025-02-26 + */ +@Getter +@Setter +public class ViewModelExtendDto { + // 权限信息 + private ViewModelAuthInfoDto authInfo; + // 帮助信息 + private ViewModelHelpInfoDto helpInfo; +} + diff --git a/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelHelpInfoDto.java b/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelHelpInfoDto.java new file mode 100644 index 0000000..d46fef0 --- /dev/null +++ b/view-object-api/src/main/java/com/inspur/edp/formserver/vmapi/dto/ViewModelHelpInfoDto.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.formserver.vmapi.dto; + +import io.iec.edp.caf.securityentry.api.data.SecurityEntry; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; +/** + * 视图模型帮助信息DTO + * @author sunhongfei01 + * @since 2025-02-26 + */ +@Getter +@Setter +public class ViewModelHelpInfoDto { + // 帮助权限集合 + private List helpSecurityEntries; +} diff --git a/view-object-manager/pom.xml b/view-object-manager/pom.xml index 7512825..d167808 100644 --- a/view-object-manager/pom.xml +++ b/view-object-manager/pom.xml @@ -27,6 +27,10 @@ view-object-manager + + com.inspur.edp + view-object-api + com.inspur.edp view-object-model @@ -141,5 +145,10 @@ com.inspur.edp lcm-mimic-api + + + io.iec.edp + caf-framework-securityentry-api + diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/BffMetadataEventListener.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/BffMetadataEventListener.java index ff76e95..e2b6bef 100644 --- a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/BffMetadataEventListener.java +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/BffMetadataEventListener.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.inspur.edp.formserver.vmmanager; @@ -22,7 +38,7 @@ public class BffMetadataEventListener implements MetadataEventListener { return; } - GspViewModel vm = (GspViewModel) ((e.getMetadata().getContent() instanceof GspViewModel) ? e.getMetadata().getContent() : null); + GspViewModel vm = (GspViewModel) e.getMetadata().getContent(); //保存前校验 ViewModelValidator validator = new ViewModelValidator(); diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/config/VMManagerConfig.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/config/VMManagerConfig.java index 459c637..569666e 100644 --- a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/config/VMManagerConfig.java +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/config/VMManagerConfig.java @@ -1,7 +1,26 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.inspur.edp.formserver.vmmanager.config; import com.inspur.edp.caf.cef.dt.spi.CommonStructureSchemaExtension; +import com.inspur.edp.formserver.vmapi.ViewModelService; import com.inspur.edp.formserver.vmmanager.commonstructure.VMComStructureSchemaExtension; +import com.inspur.edp.formserver.vmmanager.service.ViewModelServiceImpl; +import io.iec.edp.caf.securityentry.api.manager.SecurityEntryService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -12,5 +31,10 @@ public class VMManagerConfig { return new VMComStructureSchemaExtension(); } + @Bean("com.inspur.edp.formserver.vmmanager.service.ViewModelServiceImpl") + public ViewModelService getViewModelService(SecurityEntryService securityEntryService) { + return new ViewModelServiceImpl(securityEntryService); + } + } diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/exception/VoManagerErrorCodes.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/exception/VoManagerErrorCodes.java index 42a9b9d..72e0202 100644 --- a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/exception/VoManagerErrorCodes.java +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/exception/VoManagerErrorCodes.java @@ -129,4 +129,8 @@ public class VoManagerErrorCodes { * 操作[{0}]在业务实体上无映射操作,业务实体自定义操作的ID=[{1}],请检查是否已删除。 */ public static final String GSP_VIEWOBJECT_MANAGER_0110 = "GSP_VIEWOBJECT_MANAGER_0110"; + /** + * 视图对象[{0}]保存失败 + */ + public static final String GSP_VIEWOBJECT_MANAGER_0111 = "GSP_VIEWOBJECT_MANAGER_0111"; } diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/ViewModelServiceImpl.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/ViewModelServiceImpl.java new file mode 100644 index 0000000..649cdf4 --- /dev/null +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/ViewModelServiceImpl.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.formserver.vmmanager.service; + +import com.inspur.edp.formserver.viewmodel.exception.ViewModelException; +import com.inspur.edp.formserver.vmapi.ViewModelService; +import com.inspur.edp.formserver.vmapi.dto.ViewModelAuthInfoDto; +import com.inspur.edp.formserver.vmapi.dto.ViewModelAuthSecurityDto; +import com.inspur.edp.formserver.vmapi.dto.ViewModelExtendDto; +import com.inspur.edp.formserver.vmmanager.exception.VoManagerErrorCodes; +import io.iec.edp.caf.commons.transaction.JpaTransaction; +import io.iec.edp.caf.commons.utils.CollectionUtils; +import io.iec.edp.caf.securityentry.api.common.AuthType; +import io.iec.edp.caf.securityentry.api.data.SecurityEntry; +import io.iec.edp.caf.securityentry.api.data.SecurityEntry4RuleDTO; +import io.iec.edp.caf.securityentry.api.manager.SecurityEntryService; +import org.apache.commons.lang3.StringUtils; + +import java.util.Map; +import java.util.Set; + +/** + * 视图对象服务实现类 + */ +public class ViewModelServiceImpl implements ViewModelService { + // 功能权限extType + private static final String FUNC_SECURITY_EXTTYPE = "VM"; + // 权限规则extType + private static final String PERMRULE_AUTH_SECURITY_EXTTYPE = "VMRule"; + // 数据权限extType + private static final String AUTH_SECURITY_EXTTYPE = "VM"; + // 权限服务 + private final SecurityEntryService securityEntryService; + + public ViewModelServiceImpl(SecurityEntryService securityEntryService) { + this.securityEntryService = securityEntryService; + } + + /** + * 获取视图对象扩展信息(非元数据内容, 目前主要为权限信息) + * + * @param viewModelId 视图对象id + * @return 视图对象扩展信息 + */ + @Override + public ViewModelExtendDto getViewModelExtendInfo(String viewModelId) { + // 组织返回数据结构 + ViewModelExtendDto viewModelExtendDto = new ViewModelExtendDto(); + // 加载权限信息 + viewModelExtendDto.setAuthInfo(this.loadViewModelAuthInfo(viewModelId)); + return viewModelExtendDto; + } + + /** + * 保存视图对象的扩展信息 + * + * @param viewModelId 待保存的视图对象ID + * @param viewModelExtendInfo 待保存的扩展信息 + * @param authIdsToDelete 需要删除的权限ID + */ + @Override + public void saveViewModelExtendInfo(String viewModelId, ViewModelExtendDto viewModelExtendInfo, + Set authIdsToDelete) { + // 获取权限信息 + ViewModelAuthInfoDto authInfo = viewModelExtendInfo.getAuthInfo(); + JpaTransaction tran = JpaTransaction.getTransaction(); + try { + // 事务开始 + tran.begin(); + // 保存功能权限 + SecurityEntry funcSecurity = authInfo.getFuncSecurity(); + // 若权限ID不为空且待删除的权限ID集合中包含当前权限ID时应将其移除不做保存 + if (funcSecurity != null && (StringUtils.isBlank(funcSecurity.getId()) || !authIdsToDelete.contains(funcSecurity.getId()))) { + funcSecurity.setEx1(viewModelId); + funcSecurity.setExtType(FUNC_SECURITY_EXTTYPE); + securityEntryService.saveFuncSecurityEntry(funcSecurity); + } + + // 保存数据权限信息 + Map authSecurityMap = authInfo.getAuthSecurityMap(); + if (!CollectionUtils.isEmpty(authSecurityMap)) { + for (ViewModelAuthSecurityDto value : authSecurityMap.values()) { + if (value == null) { + continue; + } + // 判断是否为权限规则 + if (value.isPermRule()) { + // 保存权限规则 + SecurityEntry4RuleDTO permSecurityEntry = value.getPermSecurityEntry(); + // 若权限ID不为空且待删除的权限ID集合中包含当前权限ID时应将其移除不做保存 + if (permSecurityEntry != null + && (StringUtils.isBlank(permSecurityEntry.getId()) + || !authIdsToDelete.contains(permSecurityEntry.getId()))) { + permSecurityEntry.setEx1(viewModelId); + permSecurityEntry.setExtType(PERMRULE_AUTH_SECURITY_EXTTYPE); + securityEntryService.saveAuthRuleSecurityEntryDTO(permSecurityEntry); + } + } else { + // 保存数据权限 + SecurityEntry authSecurityEntry = value.getAuthSecurityEntry(); + // 若权限ID不为空且待删除的权限ID集合中包含当前权限ID时应将其移除不做保存 + if (authSecurityEntry != null && (StringUtils.isBlank(authSecurityEntry.getId()) + || !authIdsToDelete.contains(authSecurityEntry.getId()))) { + authSecurityEntry.setEx1(viewModelId); + authSecurityEntry.setExtType(AUTH_SECURITY_EXTTYPE); + securityEntryService.saveAuthSecurityEntry(authSecurityEntry); + } + } + } + } + + // 删除权限 + if (!CollectionUtils.isEmpty(authIdsToDelete)) { + for (String authId : authIdsToDelete) { + securityEntryService.deleteById(authId); + } + } + + // 保存帮助信息 + if (viewModelExtendInfo.getHelpInfo() != null + && !CollectionUtils.isEmpty(viewModelExtendInfo.getHelpInfo().getHelpSecurityEntries())) { + viewModelExtendInfo.getHelpInfo().getHelpSecurityEntries().forEach(securityEntryService::saveAuthSecurityEntry); + } + tran.commit(); + } catch (Throwable t) { + tran.rollback(); + throw new ViewModelException(VoManagerErrorCodes.GSP_VIEWOBJECT_MANAGER_0111, t, viewModelId); + } + } + + @Override + public ViewModelAuthInfoDto loadViewModelAuthInfo(String viewModelId) { + ViewModelAuthInfoDto authInfo = new ViewModelAuthInfoDto(); + // 组织视图对象的权限信息 + SecurityEntry funcSecuritySelect = new SecurityEntry(); + + // 查询视图对象的功能权限 + funcSecuritySelect.setEx1(viewModelId); + funcSecuritySelect.setExtType(FUNC_SECURITY_EXTTYPE); + funcSecuritySelect.setAuthType(AuthType.Func); + SecurityEntry funcSecurityEntry = securityEntryService.getFuncSecurityEntry(funcSecuritySelect); + authInfo.setFuncSecurity(funcSecurityEntry); + + // 查询视图对象的数据权限 + SecurityEntry4RuleDTO permAuthSecuritySelect = new SecurityEntry4RuleDTO(); + permAuthSecuritySelect.setEx1(viewModelId); + permAuthSecuritySelect.setExtType(PERMRULE_AUTH_SECURITY_EXTTYPE); + SecurityEntry4RuleDTO permRuleSecurityEntry = securityEntryService.getAuthRuleSecurityEntryDTO(permAuthSecuritySelect); + + SecurityEntry authSecuritySelect = new SecurityEntry(); + authSecuritySelect.setEx1(viewModelId); + authSecuritySelect.setExtType(AUTH_SECURITY_EXTTYPE); + authSecuritySelect.setAuthType(AuthType.Auth); + SecurityEntry authSecurityEntry = securityEntryService.getAuthSecurityEntry(authSecuritySelect); + authInfo.addAuthSecurityEntry(viewModelId, authSecurityEntry, permRuleSecurityEntry); + return authInfo; + } +} diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/WebControllerService.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/WebControllerService.java index cf157f8..8c4cb89 100644 --- a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/WebControllerService.java +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/WebControllerService.java @@ -77,11 +77,7 @@ import java.util.regex.Pattern; import static com.inspur.edp.formserver.viewmodel.common.ConvertUtils.toElement; -; - public class WebControllerService { - private String EXCEPTIONCODE = "WebControllerService"; - public static WebControllerService getInstance() { return new WebControllerService(); } @@ -94,9 +90,7 @@ public class WebControllerService { module.addSerializer(IGspCommonDataType.class, new BizObjectSerializer()); mapper.registerModule(module); try { - - String objJson = mapper.writeValueAsString(bebject); - return objJson; + return mapper.writeValueAsString(bebject); } catch (JsonProcessingException e) { throw new ViewModelException(VoManagerErrorCodes.GSP_VIEWOBJECT_MANAGER_0048, e); } @@ -105,14 +99,14 @@ public class WebControllerService { /** * 检查关键字 * - * @param jsonObject + * @param jsonObject 视图对象Json结构 */ public void checkKeywords(String jsonObject) { if (jsonObject == null || jsonObject.isEmpty()) { throw new ViewModelException(VoManagerErrorCodes.GSP_VIEWOBJECT_MANAGER_0049, null); } ObjectMapper mapper = new ObjectMapper(); - GspViewModel viewModel = null; + GspViewModel viewModel; try { viewModel = mapper.readValue(jsonObject, GspViewModel.class); } catch (JsonProcessingException e) { @@ -124,8 +118,8 @@ public class WebControllerService { /** * 获取虚拟vo关联 * - * @param info - * @return + * @param info 待获取关联信息结构 + * @return 虚拟vo关联字段信息 */ public String getVirtualVoAsso(String info, EntityFunction func) { ObjectMapper mapper = new ObjectMapper(); @@ -230,7 +224,7 @@ public class WebControllerService { throw new ViewModelException(VoManagerErrorCodes.GSP_VIEWOBJECT_MANAGER_0101,null); } else { // LabelID在表单和报表中用作XML的标签,要限制非法字符 - String regex = "\"^[A-Za-z_][A-Za-z_\\d-.]*$\""; + String regex = "^[A-Za-z_][A-Za-z_\\d-.]*$"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(voElementLabelId.trim()); boolean isMatch = matcher.matches(); diff --git a/view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/dto/SaveViewModelDto.java b/view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/dto/SaveViewModelDto.java new file mode 100644 index 0000000..717065c --- /dev/null +++ b/view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/dto/SaveViewModelDto.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.formserver.viewmodel.dto; + +import com.inspur.edp.formserver.vmapi.dto.ViewModelExtendDto; +import lombok.Getter; +import lombok.Setter; + +import java.util.Set; + +/** + * 保存视图模型请求DTO + */ +@Getter +@Setter +public class SaveViewModelDto { + /** + * 视图模型ID + */ + private String viewModelId; + /** + * 待保存的视图模型扩展信息 + */ + private ViewModelExtendDto viewModelExtendInfo; + /** + * 需要删除的权限ID集合 + */ + private Set authIdsToDelete; +} \ No newline at end of file diff --git a/view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/webapi/BffWebApiServiceConfig.java b/view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/webapi/BffWebApiServiceConfig.java index 5cbe260..d4a4496 100644 --- a/view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/webapi/BffWebApiServiceConfig.java +++ b/view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/webapi/BffWebApiServiceConfig.java @@ -1,5 +1,26 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.inspur.edp.formserver.viewmodel.webapi; +import com.inspur.edp.formserver.vmapi.ViewModelService; +import com.inspur.edp.lcm.metadata.api.service.FileService; +import com.inspur.edp.lcm.metadata.api.service.MetadataProjectService; +import com.inspur.edp.lcm.metadata.api.service.MetadataService; +import com.inspur.edp.lcm.metadata.api.service.RefCommonService; import io.iec.edp.caf.rest.RESTEndpoint; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -7,8 +28,12 @@ import org.springframework.context.annotation.Configuration; @Configuration public class BffWebApiServiceConfig { @Bean - public ViewModelController getBffWebApi() { - return new ViewModelController(); + public ViewModelController getBffWebApi(MetadataService metadataService, + RefCommonService refCommonService, + MetadataProjectService metadataProjectService, + FileService fileService, + ViewModelService viewModelService) { + return new ViewModelController(metadataService, refCommonService, metadataProjectService, fileService, viewModelService); } @Bean diff --git a/view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/webapi/ViewModelController.java b/view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/webapi/ViewModelController.java index ef030a4..70d4319 100644 --- a/view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/webapi/ViewModelController.java +++ b/view-object-webapi/src/main/java/com/inspur/edp/formserver/viewmodel/webapi/ViewModelController.java @@ -53,6 +53,7 @@ import com.inspur.edp.formserver.viewmodel.common.MappingType; import com.inspur.edp.formserver.viewmodel.common.mapping.GspVoElementMapping; import com.inspur.edp.formserver.viewmodel.common.mapping.GspVoElementSourceType; import com.inspur.edp.formserver.viewmodel.common.mapping.GspVoObjectSourceType; +import com.inspur.edp.formserver.viewmodel.dto.SaveViewModelDto; import com.inspur.edp.formserver.viewmodel.exception.ViewModelException; import com.inspur.edp.formserver.viewmodel.i18n.VMI8nResourceUtil; import com.inspur.edp.formserver.viewmodel.i18n.names.VoResourceKeyNames; @@ -61,6 +62,8 @@ import com.inspur.edp.formserver.viewmodel.json.model.ViewModelDeserializer; import com.inspur.edp.formserver.viewmodel.json.model.ViewModelSerializer; import com.inspur.edp.formserver.viewmodel.json.operation.VmActionCollectionSerializer; import com.inspur.edp.formserver.viewmodel.util.ViewModelUtils; +import com.inspur.edp.formserver.vmapi.ViewModelService; +import com.inspur.edp.formserver.vmapi.dto.ViewModelExtendDto; import com.inspur.edp.formserver.vmmanager.compcodebutton.CompButton; import com.inspur.edp.formserver.vmmanager.service.UpdateVariableWithUdtService; import com.inspur.edp.formserver.vmmanager.service.UpdateVirtualVoElementWithUdtService; @@ -78,10 +81,10 @@ import com.inspur.edp.lcm.metadata.api.service.MetadataService; import com.inspur.edp.lcm.metadata.api.service.RefCommonService; import com.inspur.edp.web.help.metadata.HelpMetadataContent; import io.iec.edp.caf.commons.utils.CollectionUtils; -import io.iec.edp.caf.commons.utils.SpringBeanUtils; import lombok.var; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -94,22 +97,41 @@ import java.util.List; import java.util.UUID; import java.util.regex.Matcher; import java.util.stream.Collectors; + import static com.inspur.edp.formserver.viewmodel.common.ConvertUtils.toElement; import static com.inspur.edp.formserver.viewmodel.common.ConvertUtils.toObject; @Path("") @Produces(MediaType.APPLICATION_JSON) public class ViewModelController { - - private final String EXCEPTIONCODE = "vmWebApi"; - + // 元数据服务 + private final MetadataService metadataService; + // 元数据依赖服务 + private final RefCommonService refCommonService; + // 元数据工程服务 + private final MetadataProjectService metadataProjectService; + // 文件服务 + private final FileService fileService; + // 元数据视图模型服务 + private final ViewModelService viewModelService; + + public ViewModelController(MetadataService metadataService, + RefCommonService refCommonService, + MetadataProjectService metadataProjectService, + FileService fileService, + ViewModelService viewModelService) { + this.metadataService = metadataService; + this.refCommonService = refCommonService; + this.metadataProjectService = metadataProjectService; + this.fileService = fileService; + this.viewModelService = viewModelService; + } @Path("sysn") @PUT @Produces(MediaType.APPLICATION_JSON) public void saveAndSysn(String metadataInfo) { ObjectMapper mapper = getViewModelMapper(); - MetadataService service = SpringBeanUtils.getBean(MetadataService.class); try { JsonNode node = mapper.readTree(metadataInfo); @@ -119,7 +141,7 @@ public class ViewModelController { if (!CheckInfoUtil.checkNull(node.get("name"))) { metadataName = node.get("name").textValue(); } - GspMetadata metadata = service.loadMetadata(metadataName, path); + GspMetadata metadata = metadataService.loadMetadata(metadataName, path); //生成构件元数据 ArrayList list = VmManagerService.generateComponent(metadata, path, true); //构件代码模板 @@ -154,8 +176,7 @@ public class ViewModelController { String metadataAssembly = node.get("metadataAssembly").textValue(); GspViewModel vm = InitVoUtil .BuildVirtualVo(metadataID, metadataName, metadataCode, metadataAssembly); - String vmJson = mapper.writeValueAsString(vm); - return vmJson; + return mapper.writeValueAsString(vm); } catch (Exception e) { throw new ViewModelException(VoWebApiErrorCodes.GSP_VIEWOBJECT_WEBAPI_1002, e); } @@ -307,15 +328,14 @@ public class ViewModelController { try { JsonNode node = mapper.readTree(convertBeInfo); String helperId = node.get("helperId").textValue(); - RefCommonService service = SpringBeanUtils.getBean(RefCommonService.class); MetadataURI targetHelpURI = new MetadataURI(); targetHelpURI.setId(helperId); - GspMetadata helpMetadata = service.getRefMetadata(targetHelpURI, null, ""); + GspMetadata helpMetadata = refCommonService.getRefMetadata(targetHelpURI, null, ""); HelpMetadataContent helpMetadataContent = (HelpMetadataContent) helpMetadata.getContent(); String voId = helpMetadataContent.getDataSource().getVoSourceId(); MetadataURI targetVOURI = new MetadataURI(); targetVOURI.setId(voId); - GspMetadata refVOMetadata = service.getRefMetadata(targetVOURI, null, ""); + GspMetadata refVOMetadata = refCommonService.getRefMetadata(targetVOURI, null, ""); GspViewModel helpVo = (GspViewModel) refVOMetadata.getContent(); if (helpVo == null) { throw new ViewModelException(VoWebApiErrorCodes.GSP_VIEWOBJECT_WEBAPI_1010, null, @@ -661,7 +681,7 @@ public class ViewModelController { if (ViewModelUtils.checkNull(beId)) { throw new ViewModelException(VoWebApiErrorCodes.GSP_VIEWOBJECT_WEBAPI_1024, null); } - GspMetadata metadata = SpringBeanUtils.getBean(RefCommonService.class).getRefMetadata(beId); + GspMetadata metadata = refCommonService.getRefMetadata(beId); if (!(metadata.getContent() instanceof GspBusinessEntity)) { throw new ViewModelException(VoWebApiErrorCodes.GSP_VIEWOBJECT_WEBAPI_1025, null, beId); } @@ -684,11 +704,11 @@ public class ViewModelController { String action = info.get("actionCode").textValue(); ArrayList actionList = new ArrayList<>(); actionList.add(action); - GspMetadata metadata = SpringBeanUtils.getBean(MetadataService.class).loadMetadataByMetadataId(id, projectpath); + GspMetadata metadata = metadataService.loadMetadataByMetadataId(id, projectpath); GspViewModel vo = (GspViewModel) metadata.getContent(); String relativePath = metadata.getRelativePath(); - GspProject metadataProj = SpringBeanUtils.getBean(MetadataService.class).getGspProjectInfo(relativePath); + GspProject metadataProj = metadataService.getGspProjectInfo(relativePath); String compAssemblyName = metadataProj.getProjectNameSpace(); CompButton button = new CompButton(); @@ -717,10 +737,10 @@ public class ViewModelController { String action = info.get("actionCode").textValue(); ArrayList actionList = new ArrayList<>(); actionList.add(action); - GspMetadata metadata = SpringBeanUtils.getBean(MetadataService.class).loadMetadataByMetadataId(id, projectpath); + GspMetadata metadata = metadataService.loadMetadataByMetadataId(id, projectpath); GspViewModel vo = (GspViewModel) metadata.getContent(); String relativePath = metadata.getRelativePath(); - GspProject metadataProj = SpringBeanUtils.getBean(MetadataService.class).getGspProjectInfo(relativePath); + GspProject metadataProj = metadataService.getGspProjectInfo(relativePath); String compAssemblyName = metadataProj.getProjectNameSpace(); CompButton button = new CompButton(); @@ -746,8 +766,7 @@ public class ViewModelController { } String path = info.get("path").textValue(); String metadataFileName = info.get("metadataFileName").textValue(); - MetadataService service = SpringBeanUtils.getBean(com.inspur.edp.lcm.metadata.api.service.MetadataService.class); - return service.isMetadataExist(path, metadataFileName); + return metadataService.isMetadataExist(path, metadataFileName); } private void isMetadataCodeExist(JsonNode info) { @@ -757,15 +776,14 @@ public class ViewModelController { String metadataName = info.get("name").textValue(); String projectPath = info.get("path").textValue(); - GspMetadata metadata = SpringBeanUtils.getBean(MetadataService.class).loadMetadata(metadataName, projectPath); + GspMetadata metadata = metadataService.loadMetadata(metadataName, projectPath); GspViewModel vo = (GspViewModel) metadata.getContent(); List checkInfo = new ArrayList<>(); CompButton button = new CompButton(); button.getNewActions(vo, checkInfo); String relativePath = metadata.getRelativePath(); - MetadataProjectService service = SpringBeanUtils.getBean(MetadataProjectService.class); - String compModulePath = service.getJavaCompProjectPath(relativePath); - GspProject metadataProj = SpringBeanUtils.getBean(MetadataService.class).getGspProjectInfo(relativePath); + String compModulePath = metadataProjectService.getJavaCompProjectPath(relativePath); + GspProject metadataProj = metadataService.getGspProjectInfo(relativePath); String compAssemblyName = metadataProj.getProjectNameSpace(); if (checkInfo.size() <= 0) { return; @@ -777,8 +795,7 @@ public class ViewModelController { String filePath = button.getFilePath(vo, checkComUtil, compModulePath, compAssemblyName); filePath.replaceAll("\\\\", Matcher.quoteReplacement(File.separator)); filePath.replaceAll("/", Matcher.quoteReplacement(File.separator)); - FileService fsService = SpringBeanUtils.getBean(FileService.class); - if (fsService.isFileExist(filePath)) { + if (fileService.isFileExist(filePath)) { String fileName = ""; if (!"VarDeterminations".equals(checkComUtil.getType())) { fileName = checkComUtil.getAction() + "VOAction.java"; @@ -789,4 +806,20 @@ public class ViewModelController { } } } + + @Path("loadViewModel") + @GET + @Produces(MediaType.APPLICATION_JSON) + public ViewModelExtendDto loadViewModel(@QueryParam(value = "viewModelId")String viewModelId) { + return viewModelService.getViewModelExtendInfo(viewModelId); + } + @Path("saveViewModel") + @POST + @Produces(MediaType.APPLICATION_JSON) + public void saveViewModel(SaveViewModelDto saveViewModelAuthInfo) { + viewModelService.saveViewModelExtendInfo( + saveViewModelAuthInfo.getViewModelId(), + saveViewModelAuthInfo.getViewModelExtendInfo(), + saveViewModelAuthInfo.getAuthIdsToDelete()); + } } -- Gitee From c1926c4a09efc9e13ae2441a3512353db270028a Mon Sep 17 00:00:00 2001 From: sunhongfei01 Date: Mon, 31 Mar 2025 16:07:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20voElementLabelId?= =?UTF-8?q?=20=E7=9A=84=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 if (isMatch)改为 if (!isMatch),以确保在匹配成功时继续执行,而不是抛出异常 - 这个修改修复了 voElementLabelId 的验证逻辑,使其符合预期行为 --- .../edp/formserver/vmmanager/service/WebControllerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/WebControllerService.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/WebControllerService.java index 8c4cb89..b88e462 100644 --- a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/WebControllerService.java +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/service/WebControllerService.java @@ -228,7 +228,7 @@ public class WebControllerService { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(voElementLabelId.trim()); boolean isMatch = matcher.matches(); - if (isMatch) { + if (!isMatch) { throw new ViewModelException(VoManagerErrorCodes.GSP_VIEWOBJECT_MANAGER_0102,null); } } -- Gitee