This commit is contained in:
fit2-zhao 2021-01-26 18:30:02 +08:00
commit dcd30a1fb7
14 changed files with 91 additions and 26 deletions

View File

@ -124,6 +124,12 @@ public class ApiAutomationService {
apiScenarioMapper.deleteByExample(example);
}
public void removeToGcByIds(List<String> nodeIds) {
ApiScenarioExample example = new ApiScenarioExample();
example.createCriteria().andApiScenarioModuleIdIn(nodeIds);
extApiScenarioMapper.removeToGcByExample(example);
}
public ApiScenario create(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles) {
request.setId(UUID.randomUUID().toString());
checkNameExist(request);

View File

@ -240,7 +240,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
public int deleteNode(List<String> nodeIds) {
ApiDefinitionExample apiDefinitionExample = new ApiDefinitionExample();
apiDefinitionExample.createCriteria().andModuleIdIn(nodeIds);
apiDefinitionMapper.deleteByExample(apiDefinitionExample);
extApiDefinitionMapper.removeToGcByExample(apiDefinitionExample); // 删除模块则模块下的接口放入回收站
ApiModuleExample apiDefinitionNodeExample = new ApiModuleExample();
apiDefinitionNodeExample.createCriteria().andIdIn(nodeIds);

View File

@ -194,7 +194,7 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
}
public int deleteNode(List<String> nodeIds) {
apiAutomationService.deleteByIds(nodeIds);
apiAutomationService.removeToGcByIds(nodeIds);
ApiScenarioModuleExample apiScenarioModuleExample = new ApiScenarioModuleExample();
apiScenarioModuleExample.createCriteria().andIdIn(nodeIds);

View File

@ -6,6 +6,8 @@ import io.metersphere.api.dto.definition.ApiDefinitionRequest;
import io.metersphere.api.dto.definition.ApiDefinitionResult;
import io.metersphere.api.dto.definition.ApiSwaggerUrlDTO;
import io.metersphere.base.domain.ApiDefinition;
import io.metersphere.base.domain.ApiDefinitionExample;
import io.metersphere.base.domain.ApiModuleExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -19,6 +21,8 @@ public interface ExtApiDefinitionMapper {
int removeToGc(@Param("ids") List<String> ids);
int removeToGcByExample(ApiDefinitionExample example);
int reduction(@Param("ids") List<String> ids);
List<ApiDataCountResult> countProtocolByProjectID(String projectId);

View File

@ -311,6 +311,15 @@
</foreach>
</update>
<update id="removeToGcByExample" parameterType="io.metersphere.base.domain.ApiDefinitionExample">
update api_definition
set
status = 'Trash', module_path = null, module_id = null
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</update>
<update id="reduction">
update api_definition
set

View File

@ -4,6 +4,7 @@ import io.metersphere.api.dto.automation.ApiScenarioDTO;
import io.metersphere.api.dto.automation.ApiScenarioRequest;
import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.base.domain.ApiScenario;
import io.metersphere.base.domain.ApiScenarioExample;
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
import org.apache.ibatis.annotations.Param;
@ -20,6 +21,8 @@ public interface ExtApiScenarioMapper {
int removeToGc(@Param("ids") List<String> ids);
int removeToGcByExample(ApiScenarioExample example);
int reduction(@Param("ids") List<String> ids);
long countByProjectID(String projectId);

View File

@ -7,6 +7,35 @@
<result column="project_name" property="projectName"/>
<result column="user_name" property="userName"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="condition">
<choose>
<when test='${object}.operator == "like"'>
@ -243,6 +272,15 @@
</foreach>
</update>
<update id="removeToGcByExample" parameterType="io.metersphere.base.domain.ApiScenarioExample">
update api_scenario
set
status = 'Trash', module_path = null, api_scenario_module_id = null
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</update>
<update id="reduction">
update api_scenario
set

View File

@ -12,6 +12,7 @@ import io.metersphere.dto.TestResourcePoolDTO;
import io.metersphere.i18n.Translator;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@ -39,29 +40,16 @@ public class NodeResourcePoolService {
}
deleteTestResource(testResourcePool.getId());
List<String> nodeIps = testResourcePool.getResources().stream()
List<ImmutablePair> Ip_Port = testResourcePool.getResources().stream()
.map(resource -> {
NodeDTO nodeDTO = JSON.parseObject(resource.getConfiguration(), NodeDTO.class);
return nodeDTO.getIp();
return new ImmutablePair(nodeDTO.getIp(), nodeDTO.getPort());
})
.distinct()
.collect(Collectors.toList());
List<Integer> nodePorts = testResourcePool.getResources().stream()
.map(resource -> {
NodeDTO nodeDTO = JSON.parseObject(resource.getConfiguration(), NodeDTO.class);
return nodeDTO.getPort();
})
.distinct()
.collect(Collectors.toList());
if (nodeIps.size() < testResourcePool.getResources().size() && nodePorts.size() < testResourcePool.getResources().size()) {
if (Ip_Port.size() < testResourcePool.getResources().size()) {
MSException.throwException(Translator.get("duplicate_node_ip_port"));
}
else if (nodeIps.size() < testResourcePool.getResources().size()) {
MSException.throwException(Translator.get("duplicate_node_ip"));
}
else if (nodePorts.size() < testResourcePool.getResources().size()) {
MSException.throwException(Translator.get("duplicate_node_port"));
}
testResourcePool.setStatus(VALID.name());
boolean isValid = true;
for (TestResource resource : testResourcePool.getResources()) {

View File

@ -50,7 +50,7 @@ public class TestPlanController {
QueryTestPlanRequest request = new QueryTestPlanRequest();
request.setWorkspaceId(workspaceId);
request.setProjectId(projectId);
return testPlanService.listTestPlan(request);
return testPlanService.listTestPlanByProject(request);
}
@PostMapping("/list/all")

View File

@ -28,7 +28,13 @@
<el-table-column prop="num" label="ID"
sortable="custom"
show-overflow-tooltip/>
show-overflow-tooltip>
<template slot-scope="scope">
<el-tooltip content="编辑">
<a style="cursor:pointer" @click="edit(scope.row)"> {{ scope.row.num }} </a>
</el-tooltip>
</template>
</el-table-column>
<el-table-column prop="name"
sortable="custom"
:label="$t('api_test.automation.scenario_name')"

View File

@ -31,7 +31,13 @@
</template>
</el-table-column>
<el-table-column prop="num" label="ID" show-overflow-tooltip/>
<el-table-column prop="num" label="ID" show-overflow-tooltip>
<template slot-scope="scope">
<el-tooltip content="编辑">
<a style="cursor:pointer" @click="handleTestCase(scope.row)"> {{ scope.row.num }} </a>
</el-tooltip>
</template>
</el-table-column>
<el-table-column prop="name" :label="$t('test_track.case.name')" show-overflow-tooltip/>
<el-table-column

View File

@ -31,7 +31,13 @@
</el-table-column>
<el-table-column prop="num" label="ID" show-overflow-tooltip
sortable="custom"/>
sortable="custom">
<template slot-scope="scope">
<el-tooltip content="编辑">
<a style="cursor:pointer" @click="editApi(scope.row)"> {{ scope.row.num }} </a>
</el-tooltip>
</template>
</el-table-column>
<el-table-column prop="name" :label="$t('api_test.definition.api_name')"
show-overflow-tooltip
sortable="custom" min-width="120px"/>

View File

@ -1,7 +1,6 @@
import Vue from "vue";
import VueRouter from 'vue-router'
import RouterSidebar from "./RouterSidebar";
import axios from "axios";
import Setting from "@/business/components/settings/router";
import API from "@/business/components/api/router";
import Performance from "@/business/components/performance/router";
@ -31,8 +30,8 @@ router.beforeEach((to, from, next) => {
//解决localStorage清空cookie没失效导致的卡死问题
if (!localStorage.getItem('Admin-Token')) {
axios.get("/signout");
console.log("signout");
// axios.get("/signout");
// console.log("signout");
localStorage.setItem('Admin-Token', "{}");
window.location.href = "/login";
next();

View File

@ -32,7 +32,7 @@
@cell-mouse-enter="showPopover"
row-key="id"
class="test-content adjust-table ms-select-all"
ref="table">
ref="table" @row-click="handleEdit">
<el-table-column
width="50"