fix(个人中心): 修改平台账号校验逻辑
This commit is contained in:
parent
f380c3defc
commit
7edeaa06c4
|
@ -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<String, String> serviceIntegrationInfo) {
|
||||
userPlatformAccountService.validate(pluginId, serviceIntegrationInfo);
|
||||
@Schema(description = "用户配置集成信息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
Map<String, String> userPlatformConfig) {
|
||||
userPlatformAccountService.validate(pluginId, orgId, userPlatformConfig);
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
|
|
|
@ -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<String, String> serviceIntegrationInfo) {
|
||||
Platform platform = platformPluginService.getPlatform(pluginId, StringUtils.EMPTY, JSON.toJSONString(serviceIntegrationInfo));
|
||||
platform.validateIntegrationConfig();
|
||||
public void validate(String pluginId, String orgId, Map<String, String> userPlatformConfig) {
|
||||
// 获取组织服务集成信息
|
||||
Platform platform = platformPluginService.getPlatform(pluginId, orgId);
|
||||
platform.validateUserConfig(JSON.toJSONString(userPlatformConfig));
|
||||
}
|
||||
|
||||
public void save(Map<String, Object> platformInfo, String userId) {
|
||||
|
|
|
@ -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> T parseObjectFromMvcResult(MvcResult mvcResult, Class<T> parseClass) {
|
||||
try {
|
||||
|
@ -78,7 +78,7 @@ public class UserPlatformAccountControllerTests extends BaseTest {
|
|||
integrationConfig.setAddress(String.format("http://%s:%s", mockServerHost, mockServerHostPort));
|
||||
Map<String, Object> integrationConfigMap = JSON.parseMap(JSON.toJSONString(integrationConfig));
|
||||
// @@请求成功
|
||||
this.requestPostWithOk(VALIDATE_POST, integrationConfigMap, plugin.getId());
|
||||
this.requestPostWithOk(VALIDATE_POST, integrationConfigMap, plugin.getId(), "100001");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue