diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugFileDTO.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugFileDTO.java index 958e92b565..01f4aff466 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugFileDTO.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugFileDTO.java @@ -33,6 +33,6 @@ public class BugFileDTO { @Schema(description = "创建人") private String createUser; - @Schema(description = "是否关联") - private Boolean associated; + @Schema(description = "是否本地文件") + private Boolean local; } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentService.java index 28a5961c51..f3143fb737 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentService.java @@ -98,7 +98,7 @@ public class BugAttachmentService { if (!CollectionUtils.isEmpty(bugLocalAttachments)) { bugLocalAttachments.forEach(localFile -> { BugFileDTO localFileDTO = BugFileDTO.builder().refId(localFile.getId()).fileId(localFile.getFileId()).fileName(localFile.getFileName()).fileType(getLocalFileType(localFile.getFileName())) - .fileSize(localFile.getSize()).createTime(localFile.getCreateTime()).createUser(localFile.getCreateUser()).associated(false).build(); + .fileSize(localFile.getSize()).createTime(localFile.getCreateTime()).createUser(localFile.getCreateUser()).local(true).build(); bugFiles.add(localFileDTO); }); } @@ -112,7 +112,7 @@ public class BugAttachmentService { FileMetadata associatedFileMetadata = fileMetadataMap.get(associatedFile.getFileId()); BugFileDTO associatedFileDTO = BugFileDTO.builder().refId(associatedFile.getId()).fileId(associatedFile.getFileId()).fileName(associatedFileMetadata.getName() + "." + associatedFileMetadata.getType()) .fileType(associatedFileMetadata.getType()).fileSize(associatedFileMetadata.getSize()).createTime(associatedFileMetadata.getCreateTime()) - .createUser(associatedFileMetadata.getCreateUser()).associated(true).build(); + .createUser(associatedFileMetadata.getCreateUser()).local(false).build(); bugFiles.add(associatedFileDTO); }); } @@ -385,7 +385,7 @@ public class BugAttachmentService { List unLinkIds = new ArrayList<>(); List deleteLocalIds = new ArrayList<>(); deleteMsAttachments.forEach(deleteMsFile -> { - if (deleteMsFile.getAssociated()) { + if (!deleteMsFile.getLocal()) { unLinkIds.add(deleteMsFile.getRefId()); } else { deleteLocalIds.add(deleteMsFile.getRefId()); diff --git a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java index ce11b59f0b..8e97d9e7d1 100644 --- a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java +++ b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java @@ -139,7 +139,7 @@ public class BugAttachmentControllerTests extends BaseTest { List files = getBugFiles("default-attachment-bug-id"); files.forEach(file -> { request.setFileId(file.getFileId()); - request.setAssociated(file.getAssociated()); + request.setAssociated(!file.getLocal()); try { this.requestPostDownloadFile(BUG_ATTACHMENT_PREVIEW, null, request); this.requestPostDownloadFile(BUG_ATTACHMENT_DOWNLOAD, null, request); @@ -161,9 +161,9 @@ public class BugAttachmentControllerTests extends BaseTest { request.setFileId("not-exist-file-id"); this.requestPost(BUG_ATTACHMENT_TRANSFER, request).andExpect(status().is5xxServerError()); List files = getBugFiles("default-attachment-bug-id"); - files.stream().filter(file -> !file.getAssociated()).forEach(file -> { + files.stream().filter(BugFileDTO::getLocal).forEach(file -> { request.setFileId(file.getFileId()); - request.setAssociated(file.getAssociated()); + request.setAssociated(!file.getLocal()); try { this.requestPostWithOk(BUG_ATTACHMENT_TRANSFER, request); } catch (Exception e) { @@ -191,7 +191,7 @@ public class BugAttachmentControllerTests extends BaseTest { } }); List tapdFiles = getBugFiles("default-bug-id-tapd"); - tapdFiles.stream().filter(BugFileDTO::getAssociated).forEach(file -> { + tapdFiles.stream().filter(file -> !file.getLocal()).forEach(file -> { try { request.setBugId("default-bug-id-tapd"); request.setRefId(file.getRefId()); @@ -212,7 +212,7 @@ public class BugAttachmentControllerTests extends BaseTest { request.setBugId("default-attachment-bug-id"); request.setProjectId("default-project-for-attachment"); request.setRefId(file.getRefId()); - request.setAssociated(file.getAssociated()); + request.setAssociated(!file.getLocal()); try { this.requestPostWithOk(BUG_ATTACHMENT_DELETE, request); } catch (Exception e) { @@ -225,7 +225,7 @@ public class BugAttachmentControllerTests extends BaseTest { request.setBugId("default-bug-id-tapd"); request.setProjectId("default-project-for-attachment"); request.setRefId(file.getRefId()); - request.setAssociated(file.getAssociated()); + request.setAssociated(!file.getLocal()); try { this.requestPost(BUG_ATTACHMENT_DELETE, request).andExpect(status().is5xxServerError()); } catch (Exception e) { diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/ServiceIntegrationController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/ServiceIntegrationController.java index 005f52d622..16f48c7f94 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/ServiceIntegrationController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/ServiceIntegrationController.java @@ -1,11 +1,11 @@ package io.metersphere.system.controller; import io.metersphere.sdk.constants.PermissionConstants; -import io.metersphere.system.log.annotation.Log; -import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.domain.ServiceIntegration; import io.metersphere.system.dto.ServiceIntegrationDTO; import io.metersphere.system.dto.request.ServiceIntegrationUpdateRequest; +import io.metersphere.system.log.annotation.Log; +import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.service.ServiceIntegrationLogService; import io.metersphere.system.service.ServiceIntegrationService; import io.metersphere.validation.groups.Created; @@ -65,16 +65,17 @@ public class ServiceIntegrationController { serviceIntegrationService.delete(id); } - @PostMapping("/validate/{pluginId}") + @PostMapping("/validate/{pluginId}/{orgId}") @Operation(summary = "系统设置-组织-服务集成-校验服务集成信息") @RequiresPermissions(PermissionConstants.SYSTEM_SERVICE_INTEGRATION_UPDATE) public void validate(@PathVariable String pluginId, + @PathVariable String orgId, @Validated({Updated.class}) @RequestBody @NotEmpty @Schema(description = "配置的表单键值对", requiredMode = Schema.RequiredMode.REQUIRED) HashMap serviceIntegrationInfo) { - serviceIntegrationService.validate(pluginId, serviceIntegrationInfo); + serviceIntegrationService.validate(pluginId, orgId, serviceIntegrationInfo); } @GetMapping("/validate/{id}") diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/ServiceIntegrationService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/ServiceIntegrationService.java index 20e53620b6..6ec5f193f6 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/ServiceIntegrationService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/ServiceIntegrationService.java @@ -15,7 +15,6 @@ import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.utils.ServiceUtils; import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -127,9 +126,9 @@ public class ServiceIntegrationService { } } - public void validate(String pluginId, Map serviceIntegrationInfo) { + public void validate(String pluginId, String orgId, Map serviceIntegrationInfo) { pluginService.checkResourceExist(pluginId); - Platform platform = platformPluginService.getPlatform(pluginId, StringUtils.EMPTY, JSON.toJSONString(serviceIntegrationInfo)); + Platform platform = platformPluginService.getPlatform(pluginId, orgId, JSON.toJSONString(serviceIntegrationInfo)); platform.validateIntegrationConfig(); } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/ServiceIntegrationControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/ServiceIntegrationControllerTests.java index a808194174..a881f949f9 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/ServiceIntegrationControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/ServiceIntegrationControllerTests.java @@ -10,10 +10,10 @@ import io.metersphere.system.domain.Organization; import io.metersphere.system.domain.Plugin; import io.metersphere.system.domain.ServiceIntegration; import io.metersphere.system.dto.ServiceIntegrationDTO; +import io.metersphere.system.dto.request.ServiceIntegrationUpdateRequest; import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.mapper.PluginMapper; import io.metersphere.system.mapper.ServiceIntegrationMapper; -import io.metersphere.system.dto.request.ServiceIntegrationUpdateRequest; import io.metersphere.system.service.OrganizationService; import io.metersphere.system.service.PluginLoadService; import jakarta.annotation.Resource; @@ -48,7 +48,7 @@ public class ServiceIntegrationControllerTests extends BaseTest { private static final String BASE_PATH = "/service/integration/"; private static final String LIST = "/list/{0}"; private static final String VALIDATE_GET = "/validate/{0}"; - private static final String VALIDATE_POST = "/validate/{0}"; + private static final String VALIDATE_POST = "/validate/{0}/{1}"; private static final String SCRIPT_GET = "/script/{0}"; private static ServiceIntegration addServiceIntegration; private static Organization defaultOrg; @@ -250,22 +250,22 @@ public class ServiceIntegrationControllerTests extends BaseTest { integrationConfig.setAddress(String.format("http://%s:%s", mockServerHost, mockServerHostPort)); Map integrationConfigMap = JSON.parseMap(JSON.toJSONString(integrationConfig)); // @@请求成功 - this.requestPostWithOk(VALIDATE_POST, integrationConfigMap, plugin.getId()); + this.requestPostWithOk(VALIDATE_POST, integrationConfigMap, plugin.getId(), defaultOrg.getId()); // @@校验插件禁用 setPluginEnable(addServiceIntegration.getPluginId(), false); - assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, plugin.getId()), PLUGIN_ENABLE); + assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, plugin.getId(), defaultOrg.getId()), PLUGIN_ENABLE); setPluginEnable(addServiceIntegration.getPluginId(), true); // @@校验权限 setPluginGlobal(addServiceIntegration.getPluginId(), false); - assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, plugin.getId()), PLUGIN_PERMISSION); + assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, plugin.getId(), defaultOrg.getId()), PLUGIN_PERMISSION); setPluginGlobal(addServiceIntegration.getPluginId(), true); // @@校验 NOT_FOUND 异常 - assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, "1111"), NOT_FOUND); + assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, "1111", defaultOrg.getId()), NOT_FOUND); // @@校验权限 - requestPostPermissionTest(PermissionConstants.SYSTEM_SERVICE_INTEGRATION_UPDATE, VALIDATE_POST, integrationConfigMap, plugin.getId()); + requestPostPermissionTest(PermissionConstants.SYSTEM_SERVICE_INTEGRATION_UPDATE, VALIDATE_POST, integrationConfigMap, plugin.getId(), defaultOrg.getId()); } @Test diff --git a/frontend/src/views/setting/organization/serviceIntegration/components/configModal.vue b/frontend/src/views/setting/organization/serviceIntegration/components/configModal.vue index a0e3b0f58e..48660f2b0b 100644 --- a/frontend/src/views/setting/organization/serviceIntegration/components/configModal.vue +++ b/frontend/src/views/setting/organization/serviceIntegration/components/configModal.vue @@ -172,7 +172,7 @@ const formValue = { ...fApi.value.formData(), }; - await postValidate(formValue, pluginId.value); + await postValidate(formValue, `${pluginId.value}/${lastOrganizationId}`); if (!isConfigOrigin.value) isDisabled.value = false; Message.success(t('organization.service.successMessage')); } catch (error) { @@ -203,4 +203,4 @@ }); - + \ No newline at end of file