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 jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -22,6 +21,5 @@ public class EnvironmentGroupRequest {
|
|||
@Schema(description = "环境组描述")
|
||||
private String description;
|
||||
@Schema(description = "环境组id")
|
||||
@NotEmpty
|
||||
private List<EnvironmentGroupProjectDTO> envGroupProject;
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@ public class Host implements Serializable {
|
|||
private String domain;
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
@Schema(description = "id")
|
||||
private String uuid;
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
@ -62,7 +62,7 @@ public class CreateEnvironmentResourceService implements CreateProjectResourceSe
|
|||
if (StringUtils.isNotEmpty(baseUrl)) {
|
||||
if (CollectionUtils.isEmpty(httpConfigs)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,9 @@ public class EnvironmentGroupService {
|
|||
environmentGroup.setPos(getNextOrder(request.getProjectId()));
|
||||
environmentGroupMapper.insertSelective(environmentGroup);
|
||||
request.setId(environmentGroup.getId());
|
||||
if (CollectionUtils.isNotEmpty(request.getEnvGroupProject())) {
|
||||
this.insertGroupProject(request);
|
||||
}
|
||||
|
||||
return environmentGroup;
|
||||
}
|
||||
|
@ -157,8 +159,13 @@ public class EnvironmentGroupService {
|
|||
environmentGroup.setUpdateUser(userId);
|
||||
environmentGroup.setDescription(request.getDescription());
|
||||
environmentGroupMapper.updateByPrimaryKeySelective(environmentGroup);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(request.getEnvGroupProject())) {
|
||||
this.insertGroupProject(request);
|
||||
} else {
|
||||
EnvironmentGroupRelationExample example = new EnvironmentGroupRelationExample();
|
||||
example.createCriteria().andEnvironmentGroupIdEqualTo(request.getId());
|
||||
environmentGroupRelationMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
return environmentGroup;
|
||||
}
|
||||
|
|
|
@ -272,7 +272,6 @@ public class EnvironmentControllerTests extends BaseTest {
|
|||
HostConfig hostConfig = new HostConfig();
|
||||
hostConfig.setEnable(true);
|
||||
Host host = new Host();
|
||||
host.setUuid("uuid");
|
||||
host.setDomain("domain");
|
||||
host.setDescription("description");
|
||||
host.setIp("ip");
|
||||
|
|
|
@ -249,6 +249,8 @@ public class EnvironmentGroupControllerTests extends BaseTest {
|
|||
Assertions.assertEquals(groupResponse.getId(), environmentGroup.getId());
|
||||
Assertions.assertEquals(groupResponse.getName(), environmentGroup.getName());
|
||||
checkLog(environmentGroup.getId(), OperationLogType.ADD);
|
||||
groupRequest.setEnvGroupProject(new ArrayList<>());
|
||||
requestPost(update, groupRequest);
|
||||
groupRequest.setEnvGroupProject(List.of(environmentGroupProjectDTO, environmentGroupProjectDTO));
|
||||
requestPost(update, groupRequest, ERROR_REQUEST_MATCHER);
|
||||
//校验权限
|
||||
|
|
Loading…
Reference in New Issue