refactor(项目管理): 删除环境及联删除环境组的关系
This commit is contained in:
parent
ac0e994a41
commit
858f9bd16d
|
@ -106,7 +106,7 @@ public class EnvironmentController {
|
|||
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ_IMPORT)
|
||||
@Operation(summary = "项目管理-环境-环境目录-导入")
|
||||
public void create(@RequestPart(value = "request") EnvironmentImportRequest request, @RequestPart(value = "file") MultipartFile file) {
|
||||
public void create(@RequestPart(value = "request") EnvironmentImportRequest request, @RequestPart(value = "file", required = false) MultipartFile file) {
|
||||
environmentService.create(request, file, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId());
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class GlobalParamsController {
|
|||
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ_IMPORT)
|
||||
@Operation(summary = "项目管理-环境-全局参数-导入")
|
||||
public void create(@RequestPart(value = "file") MultipartFile file) {
|
||||
public void create(@RequestPart(value = "file", required = false) MultipartFile file) {
|
||||
globalParamsService.importData(file, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId());
|
||||
}
|
||||
|
||||
|
|
|
@ -10,14 +10,12 @@ import io.metersphere.project.mapper.ExtEnvironmentMapper;
|
|||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.DefaultRepositoryDir;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.domain.EnvironmentBlob;
|
||||
import io.metersphere.sdk.domain.EnvironmentBlobExample;
|
||||
import io.metersphere.sdk.domain.EnvironmentExample;
|
||||
import io.metersphere.sdk.domain.*;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.file.FileRequest;
|
||||
import io.metersphere.sdk.file.MinioRepository;
|
||||
import io.metersphere.sdk.mapper.EnvironmentBlobMapper;
|
||||
import io.metersphere.sdk.mapper.EnvironmentGroupRelationMapper;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
import io.metersphere.sdk.util.*;
|
||||
import io.metersphere.system.domain.PluginScript;
|
||||
|
@ -80,6 +78,8 @@ public class EnvironmentService {
|
|||
private PluginScriptService pluginScriptService;
|
||||
@Resource
|
||||
private SystemParameterService systemParameterService;
|
||||
@Resource
|
||||
private EnvironmentGroupRelationMapper environmentGroupRelationMapper;
|
||||
public static final Long ORDER_STEP = 5000L;
|
||||
|
||||
private static final String USERNAME = "user";
|
||||
|
@ -124,6 +124,10 @@ public class EnvironmentService {
|
|||
}
|
||||
environmentMapper.deleteByPrimaryKey(id);
|
||||
environmentBlobMapper.deleteByPrimaryKey(id);
|
||||
//删除环境组及联关系
|
||||
EnvironmentGroupRelationExample environmentGroupRelationExample = new EnvironmentGroupRelationExample();
|
||||
environmentGroupRelationExample.createCriteria().andEnvironmentIdEqualTo(id);
|
||||
environmentGroupRelationMapper.deleteByExample(environmentGroupRelationExample);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -470,9 +470,12 @@ public class GlobalParamsControllerTests extends BaseTest {
|
|||
paramMap.add("file", List.of(file));
|
||||
requestMultipartWithOk(importUrl, paramMap);
|
||||
paramMap.clear();
|
||||
paramMap.add("file", List.of(new File(
|
||||
inputStream = new FileInputStream(new File(
|
||||
this.getClass().getClassLoader().getResource("file/huanj.json")
|
||||
.getPath())));
|
||||
.getPath()));
|
||||
|
||||
file = new MockMultipartFile("file", "huanj.json", MediaType.APPLICATION_OCTET_STREAM_VALUE, inputStream);
|
||||
paramMap.add("file", List.of(file));
|
||||
|
||||
this.requestMultipart(importUrl, paramMap, status().is5xxServerError());
|
||||
|
||||
|
|
Loading…
Reference in New Issue