fix(项目管理): 查询环境插件脚本报错
This commit is contained in:
parent
ee28959658
commit
f7fcd8b690
|
@ -3,12 +3,12 @@ package io.metersphere.project.controller;
|
||||||
import io.metersphere.project.service.ProjectStatusFlowSettingLogService;
|
import io.metersphere.project.service.ProjectStatusFlowSettingLogService;
|
||||||
import io.metersphere.project.service.ProjectStatusFlowSettingService;
|
import io.metersphere.project.service.ProjectStatusFlowSettingService;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
|
import io.metersphere.system.domain.StatusItem;
|
||||||
|
import io.metersphere.system.dto.StatusItemDTO;
|
||||||
import io.metersphere.system.dto.sdk.request.StatusDefinitionUpdateRequest;
|
import io.metersphere.system.dto.sdk.request.StatusDefinitionUpdateRequest;
|
||||||
import io.metersphere.system.dto.sdk.request.StatusFlowUpdateRequest;
|
import io.metersphere.system.dto.sdk.request.StatusFlowUpdateRequest;
|
||||||
import io.metersphere.system.dto.sdk.request.StatusItemAddRequest;
|
import io.metersphere.system.dto.sdk.request.StatusItemAddRequest;
|
||||||
import io.metersphere.system.dto.sdk.request.StatusItemUpdateRequest;
|
import io.metersphere.system.dto.sdk.request.StatusItemUpdateRequest;
|
||||||
import io.metersphere.system.domain.StatusItem;
|
|
||||||
import io.metersphere.system.dto.StatusItemDTO;
|
|
||||||
import io.metersphere.system.log.annotation.Log;
|
import io.metersphere.system.log.annotation.Log;
|
||||||
import io.metersphere.system.log.constants.OperationLogType;
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
@ -17,6 +17,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -47,7 +48,7 @@ public class ProjectStatusFlowSettingController {
|
||||||
@Operation(summary = "项目管理-模板-状态流设置-设置状态定义,即起始状态,结束状态")
|
@Operation(summary = "项目管理-模板-状态流设置-设置状态定义,即起始状态,结束状态")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_UPDATE)
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusDefinitionLog(#request)", msClass = ProjectStatusFlowSettingLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusDefinitionLog(#request)", msClass = ProjectStatusFlowSettingLogService.class)
|
||||||
public void updateStatusDefinition(@RequestBody StatusDefinitionUpdateRequest request) {
|
public void updateStatusDefinition(@Validated @RequestBody StatusDefinitionUpdateRequest request) {
|
||||||
projectStatusFlowSettingService.updateStatusDefinition(request);
|
projectStatusFlowSettingService.updateStatusDefinition(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ public class ProjectStatusFlowSettingController {
|
||||||
@Operation(summary = "项目管理-模板-状态流设置-添加状态项")
|
@Operation(summary = "项目管理-模板-状态流设置-添加状态项")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_UPDATE)
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.addStatusItemLog(#request)", msClass = ProjectStatusFlowSettingLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.addStatusItemLog(#request)", msClass = ProjectStatusFlowSettingLogService.class)
|
||||||
public StatusItem addStatusItem(@RequestBody StatusItemAddRequest request) {
|
public StatusItem addStatusItem(@Validated @RequestBody StatusItemAddRequest request) {
|
||||||
return projectStatusFlowSettingService.addStatusItem(request);
|
return projectStatusFlowSettingService.addStatusItem(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ public class ProjectStatusFlowSettingController {
|
||||||
@Operation(summary = "项目管理-模板-状态流设置-修改状态项")
|
@Operation(summary = "项目管理-模板-状态流设置-修改状态项")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_UPDATE)
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusItemLog(#request)", msClass = ProjectStatusFlowSettingLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusItemLog(#request)", msClass = ProjectStatusFlowSettingLogService.class)
|
||||||
public StatusItem addStatusItem(@RequestBody StatusItemUpdateRequest request) {
|
public StatusItem addStatusItem(@Validated @RequestBody StatusItemUpdateRequest request) {
|
||||||
return projectStatusFlowSettingService.updateStatusItem(request);
|
return projectStatusFlowSettingService.updateStatusItem(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ public class ProjectStatusFlowSettingController {
|
||||||
@Operation(summary = "项目管理-模板-状态流设置-设置状态流转")
|
@Operation(summary = "项目管理-模板-状态流设置-设置状态流转")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_UPDATE)
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusFlowLog(#request)", msClass = ProjectStatusFlowSettingLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusFlowLog(#request)", msClass = ProjectStatusFlowSettingLogService.class)
|
||||||
public void updateStatusFlow(@RequestBody StatusFlowUpdateRequest request) {
|
public void updateStatusFlow(@Validated @RequestBody StatusFlowUpdateRequest request) {
|
||||||
projectStatusFlowSettingService.updateStatusFlow(request);
|
projectStatusFlowSettingService.updateStatusFlow(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -398,7 +398,8 @@ public class EnvironmentService {
|
||||||
orgApiPluginWrappers.stream().forEach(wrapper -> {
|
orgApiPluginWrappers.stream().forEach(wrapper -> {
|
||||||
Plugin plugin = wrapper.getPlugin();
|
Plugin plugin = wrapper.getPlugin();
|
||||||
if (plugin instanceof AbstractProtocolPlugin protocolPlugin) {
|
if (plugin instanceof AbstractProtocolPlugin protocolPlugin) {
|
||||||
pluginScripts.add(pluginScriptService.get(wrapper.getPluginId(), protocolPlugin.getEnvProtocolScriptId()));
|
Optional.ofNullable(pluginScriptService.get(wrapper.getPluginId(), protocolPlugin.getEnvProtocolScriptId()))
|
||||||
|
.ifPresent(pluginScripts::add);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ import io.metersphere.system.dto.sdk.OptionDTO;
|
||||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||||
import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
||||||
import io.metersphere.system.log.constants.OperationLogType;
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
|
import io.metersphere.system.mapper.PluginScriptMapper;
|
||||||
import io.metersphere.system.service.PluginService;
|
import io.metersphere.system.service.PluginService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -108,6 +109,8 @@ public class EnvironmentControllerTests extends BaseTest {
|
||||||
private EnvironmentBlobMapper environmentBlobMapper;
|
private EnvironmentBlobMapper environmentBlobMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private PluginService pluginService;
|
private PluginService pluginService;
|
||||||
|
@Resource
|
||||||
|
private PluginScriptMapper pluginScriptMapper;
|
||||||
@Value("${spring.datasource.url}")
|
@Value("${spring.datasource.url}")
|
||||||
private String dburl;
|
private String dburl;
|
||||||
@Value("${spring.datasource.username}")
|
@Value("${spring.datasource.username}")
|
||||||
|
@ -1183,6 +1186,12 @@ public class EnvironmentControllerTests extends BaseTest {
|
||||||
Assertions.assertEquals(envScripts.get(0).getPluginId(), "tcp-sampler");
|
Assertions.assertEquals(envScripts.get(0).getPluginId(), "tcp-sampler");
|
||||||
Assertions.assertEquals(((Map) envScripts.get(0).getScript()).get("id"), "environment");
|
Assertions.assertEquals(((Map) envScripts.get(0).getScript()).get("id"), "environment");
|
||||||
|
|
||||||
|
// 删除环境脚本,测试是否正常执行
|
||||||
|
pluginScriptMapper.deleteByPrimaryKey(plugin.getId(), "environment");
|
||||||
|
mvcResult = requestGetWithOkAndReturn(SCRIPTS, DEFAULT_PROJECT_ID);
|
||||||
|
envScripts = getResultDataArray(mvcResult, EnvironmentPluginScriptDTO.class);
|
||||||
|
Assertions.assertEquals(envScripts.size(), 0);
|
||||||
|
|
||||||
pluginService.delete(plugin.getId());
|
pluginService.delete(plugin.getId());
|
||||||
requestGetPermissionTest(PROJECT_ENVIRONMENT_READ, SCRIPTS, DEFAULT_PROJECT_ID);
|
requestGetPermissionTest(PROJECT_ENVIRONMENT_READ, SCRIPTS, DEFAULT_PROJECT_ID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package io.metersphere.system.controller;
|
package io.metersphere.system.controller;
|
||||||
|
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
|
import io.metersphere.system.domain.StatusItem;
|
||||||
|
import io.metersphere.system.dto.StatusItemDTO;
|
||||||
import io.metersphere.system.dto.sdk.request.StatusDefinitionUpdateRequest;
|
import io.metersphere.system.dto.sdk.request.StatusDefinitionUpdateRequest;
|
||||||
import io.metersphere.system.dto.sdk.request.StatusFlowUpdateRequest;
|
import io.metersphere.system.dto.sdk.request.StatusFlowUpdateRequest;
|
||||||
import io.metersphere.system.dto.sdk.request.StatusItemAddRequest;
|
import io.metersphere.system.dto.sdk.request.StatusItemAddRequest;
|
||||||
import io.metersphere.system.dto.sdk.request.StatusItemUpdateRequest;
|
import io.metersphere.system.dto.sdk.request.StatusItemUpdateRequest;
|
||||||
import io.metersphere.system.domain.StatusItem;
|
|
||||||
import io.metersphere.system.dto.StatusItemDTO;
|
|
||||||
import io.metersphere.system.log.annotation.Log;
|
import io.metersphere.system.log.annotation.Log;
|
||||||
import io.metersphere.system.log.constants.OperationLogType;
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.metersphere.system.service.OrganizationStatusFlowSettingLogService;
|
import io.metersphere.system.service.OrganizationStatusFlowSettingLogService;
|
||||||
|
@ -17,6 +17,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -47,7 +48,7 @@ public class OrganizationStatusFlowSettingController {
|
||||||
@Operation(summary = "系统设置-组织-状态流设置-设置状态定义,即起始状态,结束状态")
|
@Operation(summary = "系统设置-组织-状态流设置-设置状态定义,即起始状态,结束状态")
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_TEMPLATE_UPDATE)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_TEMPLATE_UPDATE)
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusDefinitionLog(#request)", msClass = OrganizationStatusFlowSettingLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusDefinitionLog(#request)", msClass = OrganizationStatusFlowSettingLogService.class)
|
||||||
public void updateStatusDefinition(@RequestBody StatusDefinitionUpdateRequest request) {
|
public void updateStatusDefinition(@Validated @RequestBody StatusDefinitionUpdateRequest request) {
|
||||||
organizationStatusFlowSettingService.updateStatusDefinition(request);
|
organizationStatusFlowSettingService.updateStatusDefinition(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public class OrganizationStatusFlowSettingController {
|
||||||
@Operation(summary = "系统设置-组织-状态流设置-添加状态项")
|
@Operation(summary = "系统设置-组织-状态流设置-添加状态项")
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_TEMPLATE_UPDATE)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_TEMPLATE_UPDATE)
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.addStatusItemLog(#request)", msClass = OrganizationStatusFlowSettingLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.addStatusItemLog(#request)", msClass = OrganizationStatusFlowSettingLogService.class)
|
||||||
public StatusItem addStatusItem(@RequestBody StatusItemAddRequest request) {
|
public StatusItem addStatusItem(@Validated @RequestBody StatusItemAddRequest request) {
|
||||||
return organizationStatusFlowSettingService.addStatusItem(request);
|
return organizationStatusFlowSettingService.addStatusItem(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ public class OrganizationStatusFlowSettingController {
|
||||||
@Operation(summary = "系统设置-组织-状态流设置-修改状态项")
|
@Operation(summary = "系统设置-组织-状态流设置-修改状态项")
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_TEMPLATE_UPDATE)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_TEMPLATE_UPDATE)
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusItemLog(#request)", msClass = OrganizationStatusFlowSettingLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusItemLog(#request)", msClass = OrganizationStatusFlowSettingLogService.class)
|
||||||
public StatusItem updateStatusItem(@RequestBody StatusItemUpdateRequest request) {
|
public StatusItem updateStatusItem(@Validated @RequestBody StatusItemUpdateRequest request) {
|
||||||
return organizationStatusFlowSettingService.updateStatusItem(request);
|
return organizationStatusFlowSettingService.updateStatusItem(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ public class OrganizationStatusFlowSettingController {
|
||||||
@Operation(summary = "系统设置-组织-状态流设置-设置状态流转")
|
@Operation(summary = "系统设置-组织-状态流设置-设置状态流转")
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_TEMPLATE_UPDATE)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_TEMPLATE_UPDATE)
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusFlowLog(#request)", msClass = OrganizationStatusFlowSettingLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateStatusFlowLog(#request)", msClass = OrganizationStatusFlowSettingLogService.class)
|
||||||
public void updateStatusFlow(@RequestBody StatusFlowUpdateRequest request) {
|
public void updateStatusFlow(@Validated @RequestBody StatusFlowUpdateRequest request) {
|
||||||
organizationStatusFlowSettingService.updateStatusFlow(request);
|
organizationStatusFlowSettingService.updateStatusFlow(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,11 +18,6 @@ public class StatusItemAddRequest implements Serializable {
|
||||||
@Size(min = 1, max = 50)
|
@Size(min = 1, max = 50)
|
||||||
private String scopeId;
|
private String scopeId;
|
||||||
|
|
||||||
@Schema(description = "状态ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@NotBlank(message = "{status_item.id.not_blank}")
|
|
||||||
@Size(min = 1, max = 50, message = "{status_item.id.length_range}")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotBlank(message = "{status_item.name.not_blank}")
|
@NotBlank(message = "{status_item.name.not_blank}")
|
||||||
@Size(min = 1, max = 255, message = "{status_item.name.length_range}")
|
@Size(min = 1, max = 255, message = "{status_item.name.length_range}")
|
||||||
|
|
|
@ -17,7 +17,6 @@ public class StatusItemUpdateRequest implements Serializable {
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotBlank(message = "{status_item.name.not_blank}")
|
|
||||||
@Size(min = 1, max = 255, message = "{status_item.name.length_range}")
|
@Size(min = 1, max = 255, message = "{status_item.name.length_range}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue