feat (接口自动化): 场景生成依赖关系
This commit is contained in:
parent
50cbaa3d7c
commit
6c90ff32c6
|
@ -0,0 +1,8 @@
|
||||||
|
package io.metersphere.api.service;
|
||||||
|
|
||||||
|
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||||
|
|
||||||
|
public interface ApiAutomationRelationshipEdgeService {
|
||||||
|
// 初始化引用关系
|
||||||
|
public void initRelationshipEdge(ApiScenarioWithBLOBs before, ApiScenarioWithBLOBs now);
|
||||||
|
}
|
|
@ -256,7 +256,11 @@ public class ApiAutomationService {
|
||||||
|
|
||||||
apiScenarioMapper.insert(scenario);
|
apiScenarioMapper.insert(scenario);
|
||||||
apiScenarioReferenceIdService.saveByApiScenario(scenario);
|
apiScenarioReferenceIdService.saveByApiScenario(scenario);
|
||||||
|
// 存储依赖关系
|
||||||
|
ApiAutomationRelationshipEdgeService relationshipEdgeService = CommonBeanFactory.getBean(ApiAutomationRelationshipEdgeService.class);
|
||||||
|
if (relationshipEdgeService != null) {
|
||||||
|
relationshipEdgeService.initRelationshipEdge(null, scenario);
|
||||||
|
}
|
||||||
uploadFiles(request, bodyFiles, scenarioFiles);
|
uploadFiles(request, bodyFiles, scenarioFiles);
|
||||||
|
|
||||||
return scenario;
|
return scenario;
|
||||||
|
@ -340,7 +344,8 @@ public class ApiAutomationService {
|
||||||
|
|
||||||
final ApiScenarioWithBLOBs scenario = buildSaveScenario(request);
|
final ApiScenarioWithBLOBs scenario = buildSaveScenario(request);
|
||||||
|
|
||||||
Integer version = apiScenarioMapper.selectByPrimaryKey(request.getId()).getVersion();
|
ApiScenarioWithBLOBs beforeScenario = apiScenarioMapper.selectByPrimaryKey(request.getId());
|
||||||
|
Integer version = beforeScenario.getVersion();
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
scenario.setVersion(0);
|
scenario.setVersion(0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -354,6 +359,12 @@ public class ApiAutomationService {
|
||||||
apiScenarioReferenceIdService.saveByApiScenario(scenario);
|
apiScenarioReferenceIdService.saveByApiScenario(scenario);
|
||||||
extScheduleMapper.updateNameByResourceID(request.getId(), request.getName());// 修改场景name,同步到修改首页定时任务
|
extScheduleMapper.updateNameByResourceID(request.getId(), request.getName());// 修改场景name,同步到修改首页定时任务
|
||||||
uploadFiles(request, bodyFiles, scenarioFiles);
|
uploadFiles(request, bodyFiles, scenarioFiles);
|
||||||
|
|
||||||
|
// 存储依赖关系
|
||||||
|
ApiAutomationRelationshipEdgeService relationshipEdgeService = CommonBeanFactory.getBean(ApiAutomationRelationshipEdgeService.class);
|
||||||
|
if (relationshipEdgeService != null) {
|
||||||
|
relationshipEdgeService.initRelationshipEdge(beforeScenario, scenario);
|
||||||
|
}
|
||||||
return scenario;
|
return scenario;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1888,6 +1899,12 @@ public class ApiAutomationService {
|
||||||
scenarioWithBLOBs.setOrder(getImportNextOrder(request.getProjectId()));
|
scenarioWithBLOBs.setOrder(getImportNextOrder(request.getProjectId()));
|
||||||
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
|
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
|
||||||
batchMapper.insert(scenarioWithBLOBs);
|
batchMapper.insert(scenarioWithBLOBs);
|
||||||
|
|
||||||
|
// 存储依赖关系
|
||||||
|
ApiAutomationRelationshipEdgeService relationshipEdgeService = CommonBeanFactory.getBean(ApiAutomationRelationshipEdgeService.class);
|
||||||
|
if (relationshipEdgeService != null) {
|
||||||
|
relationshipEdgeService.initRelationshipEdge(null, scenarioWithBLOBs);
|
||||||
|
}
|
||||||
apiScenarioReferenceIdService.saveByApiScenario(scenarioWithBLOBs);
|
apiScenarioReferenceIdService.saveByApiScenario(scenarioWithBLOBs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,14 @@ import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
||||||
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
||||||
import io.metersphere.api.dto.datacount.ApiDataCountResult;
|
import io.metersphere.api.dto.datacount.ApiDataCountResult;
|
||||||
import io.metersphere.base.domain.ApiScenario;
|
import io.metersphere.base.domain.ApiScenario;
|
||||||
import io.metersphere.base.domain.ApiScenarioExample;
|
|
||||||
import io.metersphere.base.domain.ApiScenarioExampleWithOperation;
|
import io.metersphere.base.domain.ApiScenarioExampleWithOperation;
|
||||||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||||
|
import io.metersphere.dto.RelationshipGraphData;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public interface ExtApiScenarioMapper {
|
public interface ExtApiScenarioMapper {
|
||||||
List<ApiScenarioDTO> list(@Param("request") ApiScenarioRequest request);
|
List<ApiScenarioDTO> list(@Param("request") ApiScenarioRequest request);
|
||||||
|
@ -80,4 +81,6 @@ public interface ExtApiScenarioMapper {
|
||||||
Long getPreOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
Long getPreOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
||||||
|
|
||||||
Long getLastOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
Long getLastOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
||||||
|
|
||||||
|
List<RelationshipGraphData.Node> getTestCaseForGraph(@Param("ids") Set<String> ids);
|
||||||
}
|
}
|
||||||
|
|
|
@ -582,5 +582,13 @@
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
<select id="getTestCaseForGraph" resultType="io.metersphere.dto.RelationshipGraphData$Node">
|
||||||
|
select id,num,custom_num,`name`
|
||||||
|
from api_scenario
|
||||||
|
where id in
|
||||||
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
and api_scenario.status != 'Trash';
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 98bc55c1045fb8abc2ca0131bedaf9be69be4919
|
Subproject commit 77d0367751b0a996a32f1c4b6b18bee9becfc4e3
|
|
@ -238,15 +238,17 @@
|
||||||
<ms-run :debug="true" :environment="projectEnvMap" @runRefresh="runRefresh" :reportId="reportId" :saved="true"
|
<ms-run :debug="true" :environment="projectEnvMap" @runRefresh="runRefresh" :reportId="reportId" :saved="true"
|
||||||
:run-data="debugData" ref="runTest"/>
|
:run-data="debugData" ref="runTest"/>
|
||||||
<ms-task-center ref="taskCenter"/>
|
<ms-task-center ref="taskCenter"/>
|
||||||
|
<relationship-graph-drawer :graph-data="graphData" ref="relationshipGraph"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {downloadFile, getCurrentProjectID, getUUID, strMapToObj} from "@/common/js/utils";
|
import {downloadFile, getCurrentProjectID, getUUID, setDefaultTheme, strMapToObj} from "@/common/js/utils";
|
||||||
import {API_SCENARIO_CONFIGS} from "@/business/components/common/components/search/search-components";
|
import {API_SCENARIO_CONFIGS} from "@/business/components/common/components/search/search-components";
|
||||||
import {API_SCENARIO_LIST} from "../../../../../common/js/constants";
|
import {API_SCENARIO_LIST, ORIGIN_COLOR} from "../../../../../common/js/constants";
|
||||||
|
|
||||||
import {getCustomTableHeader, getCustomTableWidth, getLastTableSortField} from "@/common/js/tableUtils";
|
import {buildBatchParam, getCustomTableHeader, getCustomTableWidth, getLastTableSortField} from "@/common/js/tableUtils";
|
||||||
import {API_SCENARIO_FILTERS} from "@/common/js/table-constants";
|
import {API_SCENARIO_FILTERS} from "@/common/js/table-constants";
|
||||||
import {scenario} from "@/business/components/track/plan/event-bus";
|
import {scenario} from "@/business/components/track/plan/event-bus";
|
||||||
import MsTable from "@/business/components/common/components/table/MsTable";
|
import MsTable from "@/business/components/common/components/table/MsTable";
|
||||||
|
@ -255,7 +257,9 @@ import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOpe
|
||||||
import {editApiScenarioCaseOrder} from "@/business/components/api/automation/api-automation";
|
import {editApiScenarioCaseOrder} from "@/business/components/api/automation/api-automation";
|
||||||
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {error} from "@/common/js/message";
|
import RelationshipGraphDrawer from "@/business/components/xpack/graph/RelationshipGraphDrawer";
|
||||||
|
import {getGraphByCondition} from "@/network/graph";
|
||||||
|
import {hasLicense} from "@/common/js/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiScenarioList",
|
name: "MsApiScenarioList",
|
||||||
|
@ -263,6 +267,7 @@ export default {
|
||||||
MsTable,
|
MsTable,
|
||||||
MsTableColumn,
|
MsTableColumn,
|
||||||
HeaderLabelOperate,
|
HeaderLabelOperate,
|
||||||
|
RelationshipGraphDrawer,
|
||||||
HeaderCustom: () => import("@/business/components/common/head/HeaderCustom"),
|
HeaderCustom: () => import("@/business/components/common/head/HeaderCustom"),
|
||||||
BatchMove: () => import("../../../track/case/components/BatchMove"),
|
BatchMove: () => import("../../../track/case/components/BatchMove"),
|
||||||
EnvironmentSelect: () => import("../../definition/components/environment/EnvironmentSelect"),
|
EnvironmentSelect: () => import("../../definition/components/environment/EnvironmentSelect"),
|
||||||
|
@ -438,6 +443,11 @@ export default {
|
||||||
handleClick: this.handleDeleteBatch,
|
handleClick: this.handleDeleteBatch,
|
||||||
permissions: ['PROJECT_API_SCENARIO:READ+DELETE']
|
permissions: ['PROJECT_API_SCENARIO:READ+DELETE']
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "生成依赖关系",
|
||||||
|
handleClick: this.generateGraph,
|
||||||
|
permissions: ['PROJECT_API_SCENARIO:READ+MOVE_BATCH']
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: this.$t('api_test.automation.batch_add_plan'),
|
name: this.$t('api_test.automation.batch_add_plan'),
|
||||||
handleClick: this.handleBatchAddCase,
|
handleClick: this.handleBatchAddCase,
|
||||||
|
@ -478,9 +488,13 @@ export default {
|
||||||
projectEnv: [],
|
projectEnv: [],
|
||||||
projectId: ''
|
projectId: ''
|
||||||
},
|
},
|
||||||
|
graphData: {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
if (!hasLicense()) {
|
||||||
|
this.unTrashButtons.splice(5,1);
|
||||||
|
}
|
||||||
scenario.$on('hide', id => {
|
scenario.$on('hide', id => {
|
||||||
this.hideStopBtn(id);
|
this.hideStopBtn(id);
|
||||||
});
|
});
|
||||||
|
@ -559,6 +573,12 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
generateGraph() {
|
||||||
|
getGraphByCondition('API_SCENARIO', buildBatchParam(this, this.$refs.scenarioTable.selectIds),(data) => {
|
||||||
|
this.graphData = data;
|
||||||
|
this.$refs.relationshipGraph.open();
|
||||||
|
});
|
||||||
|
},
|
||||||
getProjectName() {
|
getProjectName() {
|
||||||
this.$get('project/get/' + this.projectId, response => {
|
this.$get('project/get/' + this.projectId, response => {
|
||||||
let project = response.data;
|
let project = response.data;
|
||||||
|
|
Loading…
Reference in New Issue