删除资源池前进行检查
This commit is contained in:
parent
781effee73
commit
20a0fa0fcc
|
@ -1,12 +1,11 @@
|
|||
package io.metersphere.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.metersphere.base.domain.TestResource;
|
||||
import io.metersphere.base.domain.TestResourceExample;
|
||||
import io.metersphere.base.domain.TestResourcePool;
|
||||
import io.metersphere.base.domain.TestResourcePoolExample;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.LoadTestMapper;
|
||||
import io.metersphere.base.mapper.TestResourceMapper;
|
||||
import io.metersphere.base.mapper.TestResourcePoolMapper;
|
||||
import io.metersphere.commons.constants.PerformanceTestStatus;
|
||||
import io.metersphere.commons.constants.ResourceStatusEnum;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
|
@ -27,6 +26,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -49,6 +49,8 @@ public class TestResourcePoolService {
|
|||
private TestResourceMapper testResourceMapper;
|
||||
@Resource
|
||||
private RestTemplate restTemplate;
|
||||
@Resource
|
||||
private LoadTestMapper loadTestMapper;
|
||||
|
||||
public TestResourcePoolDTO addTestResourcePool(TestResourcePoolDTO testResourcePool) {
|
||||
checkTestResourcePool(testResourcePool);
|
||||
|
@ -62,10 +64,23 @@ public class TestResourcePoolService {
|
|||
}
|
||||
|
||||
public void deleteTestResourcePool(String testResourcePoolId) {
|
||||
// check test is Running Starting Error
|
||||
checkTestStatus(testResourcePoolId);
|
||||
deleteTestResource(testResourcePoolId);
|
||||
testResourcePoolMapper.deleteByPrimaryKey(testResourcePoolId);
|
||||
}
|
||||
|
||||
public void checkTestStatus(String testResourcePoolId) {
|
||||
List list = Arrays.asList(PerformanceTestStatus.Running, PerformanceTestStatus.Starting, PerformanceTestStatus.Error);
|
||||
LoadTestExample example = new LoadTestExample();
|
||||
example.createCriteria()
|
||||
.andTestResourcePoolIdEqualTo(testResourcePoolId)
|
||||
.andStatusIn(list);
|
||||
if (loadTestMapper.countByExample(example) > 0) {
|
||||
MSException.throwException(Translator.get("test_resource_pool_is_use"));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTestResourcePool(TestResourcePoolDTO testResourcePool) {
|
||||
checkTestResourcePool(testResourcePool);
|
||||
testResourcePool.setUpdateTime(System.currentTimeMillis());
|
||||
|
|
|
@ -47,6 +47,7 @@ workspace_not_exists=Workspace is not exists
|
|||
test_resource_pool_id_is_null=Test Resource Pool ID cannot be null
|
||||
test_resource_pool_name_is_null=Test Resource Pool name cannot be null
|
||||
test_resource_pool_name_already_exists=The test resource pool name already exists
|
||||
test_resource_pool_is_use=The test resource pool is in use and cannot be deleted
|
||||
#project
|
||||
project_name_is_null=Project name cannot be null
|
||||
project_name_already_exists=The project name already exists
|
||||
|
|
|
@ -47,6 +47,7 @@ workspace_not_exists=工作空间不存在
|
|||
test_resource_pool_id_is_null=资源池ID不能为空
|
||||
test_resource_pool_name_is_null=资源池名称不能为空
|
||||
test_resource_pool_name_already_exists=资源池名称已存在
|
||||
test_resource_pool_is_use=资源池正在使用中,无法删除
|
||||
#project
|
||||
project_name_is_null=项目名称不能为空
|
||||
project_name_already_exists=项目名称已存在
|
||||
|
|
|
@ -47,6 +47,7 @@ workspace_not_exists=工作空間不存在
|
|||
test_resource_pool_id_is_null=資源池ID不能為空
|
||||
test_resource_pool_name_is_null=資源池名稱不能為空
|
||||
test_resource_pool_name_already_exists=資源池名稱已存在
|
||||
test_resource_pool_is_use=資源池正在使用中,無法刪除
|
||||
#project
|
||||
project_name_is_null=項目名稱不能為空
|
||||
project_name_already_exists=項目名稱已存在
|
||||
|
|
|
@ -294,10 +294,10 @@
|
|||
cancelButtonText: this.$t('commons.cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.result = this.$get(`/testresourcepool/delete/${row.id}`).then(() => {
|
||||
this.result = this.$get(`/testresourcepool/delete/${row.id}`,() => {
|
||||
this.initTableData();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
});
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
}).catch(() => {
|
||||
this.$info(this.$t('commons.delete_cancel'));
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue