diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserPlatformAccountController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserPlatformAccountController.java index 5b7536dd89..721837d97b 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserPlatformAccountController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserPlatformAccountController.java @@ -1,16 +1,16 @@ package io.metersphere.system.controller; -import io.metersphere.system.service.*; +import io.metersphere.system.service.UserPlatformAccountService; import io.metersphere.system.utils.SessionUtils; -import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import jakarta.validation.constraints.NotEmpty; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.util.HashMap; + import java.util.Map; @RestController @@ -26,15 +26,18 @@ public class UserPlatformAccountController { return userPlatformAccountService.getAccountInfoList(); } - @PostMapping("/validate/{pluginId}") - @Operation(summary = "系统设置-个人中心-校验服务集成信息") - public void validate(@PathVariable String pluginId, - @Validated({Updated.class}) + @PostMapping("/validate/{pluginId}/{orgId}") + @Operation(summary = "系统设置-个人中心-校验用户集成信息") + @Parameters({ + @Parameter(name = "pluginId", description = "插件ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)), + @Parameter(name = "orgId", description = "组织ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)) + }) + public void validate(@PathVariable String pluginId, @PathVariable String orgId, @RequestBody @NotEmpty - @Schema(description = "配置的表单键值对", requiredMode = Schema.RequiredMode.REQUIRED) - HashMap serviceIntegrationInfo) { - userPlatformAccountService.validate(pluginId, serviceIntegrationInfo); + @Schema(description = "用户配置集成信息", requiredMode = Schema.RequiredMode.REQUIRED) + Map userPlatformConfig) { + userPlatformAccountService.validate(pluginId, orgId, userPlatformConfig); } @PostMapping("/save") diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserPlatformAccountService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserPlatformAccountService.java index f387f5e2fc..708a15cac7 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserPlatformAccountService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserPlatformAccountService.java @@ -15,7 +15,6 @@ import io.metersphere.system.log.dto.LogDTO; import io.metersphere.system.log.service.OperationLogService; import io.metersphere.system.mapper.UserExtendMapper; import jakarta.annotation.Resource; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -56,9 +55,10 @@ public class UserPlatformAccountService { return pluginLoadService.getPluginScriptContent(pluginId, platformPlugin.getAccountScriptId()); } - public void validate(String pluginId, Map serviceIntegrationInfo) { - Platform platform = platformPluginService.getPlatform(pluginId, StringUtils.EMPTY, JSON.toJSONString(serviceIntegrationInfo)); - platform.validateIntegrationConfig(); + public void validate(String pluginId, String orgId, Map userPlatformConfig) { + // 获取组织服务集成信息 + Platform platform = platformPluginService.getPlatform(pluginId, orgId); + platform.validateUserConfig(JSON.toJSONString(userPlatformConfig)); } public void save(Map platformInfo, String userId) { diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserPlatformAccountControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserPlatformAccountControllerTests.java index 6ead3735d5..1d757e9f95 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserPlatformAccountControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserPlatformAccountControllerTests.java @@ -34,7 +34,7 @@ public class UserPlatformAccountControllerTests extends BaseTest { private int mockServerHostPort; @Resource private MockServerClient mockServerClient; - private static final String VALIDATE_POST = "/user/platform/validate/{0}"; + private static final String VALIDATE_POST = "/user/platform/validate/{0}/{1}"; private static final String SAVE_POST = "/user/platform/save"; public static T parseObjectFromMvcResult(MvcResult mvcResult, Class parseClass) { try { @@ -78,7 +78,7 @@ public class UserPlatformAccountControllerTests 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(), "100001"); } @Test diff --git a/backend/services/system-setting/src/test/resources/file/metersphere-jira-plugin-3.x.jar b/backend/services/system-setting/src/test/resources/file/metersphere-jira-plugin-3.x.jar index 5c6378ec3f..d9554865a5 100644 Binary files a/backend/services/system-setting/src/test/resources/file/metersphere-jira-plugin-3.x.jar and b/backend/services/system-setting/src/test/resources/file/metersphere-jira-plugin-3.x.jar differ