refactor(项目管理): 环境组可以保存为空的数据
This commit is contained in:
parent
1301433836
commit
ce6c994386
|
@ -3,7 +3,6 @@ package io.metersphere.project.dto.environment;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -22,6 +21,5 @@ public class EnvironmentGroupRequest {
|
||||||
@Schema(description = "环境组描述")
|
@Schema(description = "环境组描述")
|
||||||
private String description;
|
private String description;
|
||||||
@Schema(description = "环境组id")
|
@Schema(description = "环境组id")
|
||||||
@NotEmpty
|
|
||||||
private List<EnvironmentGroupProjectDTO> envGroupProject;
|
private List<EnvironmentGroupProjectDTO> envGroupProject;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,6 @@ public class Host implements Serializable {
|
||||||
private String domain;
|
private String domain;
|
||||||
@Schema(description = "描述")
|
@Schema(description = "描述")
|
||||||
private String description;
|
private String description;
|
||||||
@Schema(description = "id")
|
|
||||||
private String uuid;
|
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class CreateEnvironmentResourceService implements CreateProjectResourceSe
|
||||||
if (StringUtils.isNotEmpty(baseUrl)) {
|
if (StringUtils.isNotEmpty(baseUrl)) {
|
||||||
if (CollectionUtils.isEmpty(httpConfigs)) {
|
if (CollectionUtils.isEmpty(httpConfigs)) {
|
||||||
HttpConfig httpConfig = new HttpConfig();
|
HttpConfig httpConfig = new HttpConfig();
|
||||||
httpConfig.setHostname(StringUtils.join(baseUrl, MOCK_EVN_SOCKET, "100001"));
|
httpConfig.setHostname(StringUtils.join(baseUrl, MOCK_EVN_SOCKET, project.getNum()));
|
||||||
httpConfigs.add(httpConfig);
|
httpConfigs.add(httpConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,9 @@ public class EnvironmentGroupService {
|
||||||
environmentGroup.setPos(getNextOrder(request.getProjectId()));
|
environmentGroup.setPos(getNextOrder(request.getProjectId()));
|
||||||
environmentGroupMapper.insertSelective(environmentGroup);
|
environmentGroupMapper.insertSelective(environmentGroup);
|
||||||
request.setId(environmentGroup.getId());
|
request.setId(environmentGroup.getId());
|
||||||
|
if (CollectionUtils.isNotEmpty(request.getEnvGroupProject())) {
|
||||||
this.insertGroupProject(request);
|
this.insertGroupProject(request);
|
||||||
|
}
|
||||||
|
|
||||||
return environmentGroup;
|
return environmentGroup;
|
||||||
}
|
}
|
||||||
|
@ -157,8 +159,13 @@ public class EnvironmentGroupService {
|
||||||
environmentGroup.setUpdateUser(userId);
|
environmentGroup.setUpdateUser(userId);
|
||||||
environmentGroup.setDescription(request.getDescription());
|
environmentGroup.setDescription(request.getDescription());
|
||||||
environmentGroupMapper.updateByPrimaryKeySelective(environmentGroup);
|
environmentGroupMapper.updateByPrimaryKeySelective(environmentGroup);
|
||||||
|
if (CollectionUtils.isNotEmpty(request.getEnvGroupProject())) {
|
||||||
this.insertGroupProject(request);
|
this.insertGroupProject(request);
|
||||||
|
} else {
|
||||||
|
EnvironmentGroupRelationExample example = new EnvironmentGroupRelationExample();
|
||||||
|
example.createCriteria().andEnvironmentGroupIdEqualTo(request.getId());
|
||||||
|
environmentGroupRelationMapper.deleteByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
return environmentGroup;
|
return environmentGroup;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +210,7 @@ public class EnvironmentGroupService {
|
||||||
EnvironmentConfig environmentConfig = JSON.parseObject(new String(environmentBlob.getConfig()), EnvironmentConfig.class);
|
EnvironmentConfig environmentConfig = JSON.parseObject(new String(environmentBlob.getConfig()), EnvironmentConfig.class);
|
||||||
dto.setDomain(ObjectUtils.isNotEmpty(environmentConfig) ? environmentConfig.getHttpConfig() : new ArrayList<>());
|
dto.setDomain(ObjectUtils.isNotEmpty(environmentConfig) ? environmentConfig.getHttpConfig() : new ArrayList<>());
|
||||||
}
|
}
|
||||||
if (environment !=null && BooleanUtils.isTrue(environment.getMock())) {
|
if (environment != null && BooleanUtils.isTrue(environment.getMock())) {
|
||||||
SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class);
|
SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class);
|
||||||
if (systemParameterService != null) {
|
if (systemParameterService != null) {
|
||||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||||
|
|
|
@ -272,7 +272,6 @@ public class EnvironmentControllerTests extends BaseTest {
|
||||||
HostConfig hostConfig = new HostConfig();
|
HostConfig hostConfig = new HostConfig();
|
||||||
hostConfig.setEnable(true);
|
hostConfig.setEnable(true);
|
||||||
Host host = new Host();
|
Host host = new Host();
|
||||||
host.setUuid("uuid");
|
|
||||||
host.setDomain("domain");
|
host.setDomain("domain");
|
||||||
host.setDescription("description");
|
host.setDescription("description");
|
||||||
host.setIp("ip");
|
host.setIp("ip");
|
||||||
|
|
|
@ -249,6 +249,8 @@ public class EnvironmentGroupControllerTests extends BaseTest {
|
||||||
Assertions.assertEquals(groupResponse.getId(), environmentGroup.getId());
|
Assertions.assertEquals(groupResponse.getId(), environmentGroup.getId());
|
||||||
Assertions.assertEquals(groupResponse.getName(), environmentGroup.getName());
|
Assertions.assertEquals(groupResponse.getName(), environmentGroup.getName());
|
||||||
checkLog(environmentGroup.getId(), OperationLogType.ADD);
|
checkLog(environmentGroup.getId(), OperationLogType.ADD);
|
||||||
|
groupRequest.setEnvGroupProject(new ArrayList<>());
|
||||||
|
requestPost(update, groupRequest);
|
||||||
groupRequest.setEnvGroupProject(List.of(environmentGroupProjectDTO, environmentGroupProjectDTO));
|
groupRequest.setEnvGroupProject(List.of(environmentGroupProjectDTO, environmentGroupProjectDTO));
|
||||||
requestPost(update, groupRequest, ERROR_REQUEST_MATCHER);
|
requestPost(update, groupRequest, ERROR_REQUEST_MATCHER);
|
||||||
//校验权限
|
//校验权限
|
||||||
|
|
Loading…
Reference in New Issue