refactor: 创建新接口版本时同步备注和依赖关系
This commit is contained in:
parent
4780eb2f05
commit
feee6e323b
|
@ -60,4 +60,8 @@ public class SaveApiDefinitionRequest {
|
||||||
private String esbDataStruct;
|
private String esbDataStruct;
|
||||||
private String backEsbDataStruct;
|
private String backEsbDataStruct;
|
||||||
private String backScript;
|
private String backScript;
|
||||||
|
|
||||||
|
// 创建新版本时用到的
|
||||||
|
private boolean newVersionRemark;
|
||||||
|
private boolean newVersionDeps;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.json.JSONSchemaToDocumentUtils;
|
import io.metersphere.commons.json.JSONSchemaToDocumentUtils;
|
||||||
import io.metersphere.commons.json.JSONToDocumentUtils;
|
import io.metersphere.commons.json.JSONToDocumentUtils;
|
||||||
import io.metersphere.commons.utils.*;
|
import io.metersphere.commons.utils.*;
|
||||||
|
import io.metersphere.controller.request.RelationshipEdgeRequest;
|
||||||
import io.metersphere.controller.request.ResetOrderRequest;
|
import io.metersphere.controller.request.ResetOrderRequest;
|
||||||
import io.metersphere.controller.request.ScheduleRequest;
|
import io.metersphere.controller.request.ScheduleRequest;
|
||||||
import io.metersphere.dto.MsExecResponseDTO;
|
import io.metersphere.dto.MsExecResponseDTO;
|
||||||
|
@ -554,7 +555,30 @@ public class ApiDefinitionService {
|
||||||
test.setCreateUser(SessionUtils.getUserId());
|
test.setCreateUser(SessionUtils.getUserId());
|
||||||
test.setOrder(oldApi.getOrder());
|
test.setOrder(oldApi.getOrder());
|
||||||
test.setRefId(oldApi.getRefId());
|
test.setRefId(oldApi.getRefId());
|
||||||
|
// 创建新版是否关联备注
|
||||||
|
if (!request.isNewVersionRemark()) {
|
||||||
|
test.setRemark(null);
|
||||||
|
}
|
||||||
apiDefinitionMapper.insertSelective(test);
|
apiDefinitionMapper.insertSelective(test);
|
||||||
|
|
||||||
|
// 创建新版是否关联依赖关系
|
||||||
|
if (request.isNewVersionDeps()) {
|
||||||
|
List<RelationshipEdgeDTO> pre = this.getRelationshipApi(oldApi.getId(), "PRE");
|
||||||
|
List<String> targetIds = pre.stream().map(RelationshipEdgeKey::getTargetId).collect(Collectors.toList());
|
||||||
|
RelationshipEdgeRequest req = new RelationshipEdgeRequest();
|
||||||
|
req.setSourceIds(targetIds);
|
||||||
|
req.setType("API");
|
||||||
|
req.setId(test.getId());
|
||||||
|
relationshipEdgeService.saveBatch(req);
|
||||||
|
|
||||||
|
List<RelationshipEdgeDTO> post = this.getRelationshipApi(oldApi.getId(), "POST");
|
||||||
|
List<String> sourceIds = post.stream().map(RelationshipEdgeKey::getSourceId).collect(Collectors.toList());
|
||||||
|
RelationshipEdgeRequest req2 = new RelationshipEdgeRequest();
|
||||||
|
req2.setSourceIds(sourceIds);
|
||||||
|
req2.setType("API");
|
||||||
|
req2.setId(test.getId());
|
||||||
|
relationshipEdgeService.saveBatch(req2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同步修改用例路径
|
// 同步修改用例路径
|
||||||
|
@ -1719,6 +1743,7 @@ public class ApiDefinitionService {
|
||||||
relationshipEdgeDTO.setCreator(apiDefinition.getUserId());
|
relationshipEdgeDTO.setCreator(apiDefinition.getUserId());
|
||||||
relationshipEdgeDTO.setTargetNum(apiDefinition.getNum());
|
relationshipEdgeDTO.setTargetNum(apiDefinition.getNum());
|
||||||
relationshipEdgeDTO.setStatus(apiDefinition.getStatus());
|
relationshipEdgeDTO.setStatus(apiDefinition.getStatus());
|
||||||
|
relationshipEdgeDTO.setVersionId(apiDefinition.getVersionId());
|
||||||
results.add(relationshipEdgeDTO);
|
results.add(relationshipEdgeDTO);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
|
|
|
@ -10,4 +10,5 @@ public class RelationshipEdgeDTO extends RelationshipEdge {
|
||||||
private String targetCustomNum;
|
private String targetCustomNum;
|
||||||
private String status;
|
private String status;
|
||||||
private String creator;
|
private String creator;
|
||||||
|
private String versionId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<ms-table
|
<ms-table
|
||||||
v-loading="result.loading"
|
v-loading="result.loading"
|
||||||
:show-select-all="false"
|
:show-select-all="false"
|
||||||
:data="data"
|
:data="data"
|
||||||
|
@ -20,22 +20,33 @@
|
||||||
:label="$t('commons.name')"
|
:label="$t('commons.name')"
|
||||||
min-width="120"/>
|
min-width="120"/>
|
||||||
|
|
||||||
|
<ms-table-column
|
||||||
|
v-xpack
|
||||||
|
v-if="versionEnable"
|
||||||
|
prop="versionName"
|
||||||
|
:label="$t('project.version.name')"
|
||||||
|
>
|
||||||
|
<template v-slot:default="scope">
|
||||||
|
{{ versionOptions[scope.row.versionId] }}
|
||||||
|
</template>
|
||||||
|
</ms-table-column>
|
||||||
|
|
||||||
<ms-table-column
|
<ms-table-column
|
||||||
prop="creator"
|
prop="creator"
|
||||||
:label="$t('commons.create_user')"
|
:label="$t('commons.create_user')"
|
||||||
min-width="120">
|
min-width="120">
|
||||||
</ms-table-column>
|
</ms-table-column>
|
||||||
|
|
||||||
<ms-table-column
|
<ms-table-column
|
||||||
prop="status"
|
prop="status"
|
||||||
min-width="120px"
|
min-width="120px"
|
||||||
:label="$t('api_test.definition.api_status')">
|
:label="$t('api_test.definition.api_status')">
|
||||||
<template v-slot:default="scope">
|
<template v-slot:default="scope">
|
||||||
<span class="el-dropdown-link">
|
<span class="el-dropdown-link">
|
||||||
<api-status :value="scope.row.status"/>
|
<api-status :value="scope.row.status"/>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</ms-table-column>
|
</ms-table-column>
|
||||||
|
|
||||||
</ms-table>
|
</ms-table>
|
||||||
|
|
||||||
|
@ -58,11 +69,14 @@ import {getRelationshipApi} from "@/network/api";
|
||||||
import ApiRelationshipRelevance
|
import ApiRelationshipRelevance
|
||||||
from "@/business/components/api/definition/components/complete/ApiRelationshipRelevance";
|
from "@/business/components/api/definition/components/complete/ApiRelationshipRelevance";
|
||||||
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
|
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
|
||||||
|
import {getCurrentProjectID} from "@/common/js/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiRelationshipList",
|
name: "ApiRelationshipList",
|
||||||
components: {
|
components: {
|
||||||
ApiStatus,
|
ApiStatus,
|
||||||
ApiRelationshipRelevance, RelationshipFunctionalRelevance, MsTableSearchBar, MsTableColumn, MsTable},
|
ApiRelationshipRelevance, RelationshipFunctionalRelevance, MsTableSearchBar, MsTableColumn, MsTable
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
result: {},
|
result: {},
|
||||||
|
@ -76,14 +90,22 @@ export default {
|
||||||
],
|
],
|
||||||
condition: {},
|
condition: {},
|
||||||
options: [],
|
options: [],
|
||||||
value: ''
|
value: '',
|
||||||
}
|
versionOptions: {},
|
||||||
|
versionEnable: false,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
apiDefinitionId: String,
|
apiDefinitionId: String,
|
||||||
readOnly: Boolean,
|
readOnly: Boolean,
|
||||||
relationshipType: String,
|
relationshipType: String,
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.getProjectVersions();
|
||||||
|
this.$get('/project/version/enable/' + getCurrentProjectID(), response => {
|
||||||
|
this.versionEnable = response.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getTableData() {
|
getTableData() {
|
||||||
getRelationshipApi(this.apiDefinitionId, this.relationshipType, (data) => {
|
getRelationshipApi(this.apiDefinitionId, this.relationshipType, (data) => {
|
||||||
|
@ -97,8 +119,16 @@ export default {
|
||||||
handleDelete(item) {
|
handleDelete(item) {
|
||||||
this.$emit('deleteRelationship', item.sourceId, item.targetId);
|
this.$emit('deleteRelationship', item.sourceId, item.targetId);
|
||||||
},
|
},
|
||||||
|
getProjectVersions() {
|
||||||
|
this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => {
|
||||||
|
this.versionOptions = response.data.reduce((result, next) => {
|
||||||
|
result[next.id] = next.name;
|
||||||
|
return result;
|
||||||
|
}, {});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
<ms-form-divider :title="$t('api_test.definition.request.res_param')"/>
|
<ms-form-divider :title="$t('api_test.definition.request.res_param')"/>
|
||||||
<ms-response-text :response="response"/>
|
<ms-response-text :response="response"/>
|
||||||
|
|
||||||
<api-other-info :api="httpForm"/>
|
<api-other-info :api="httpForm" ref="apiOtherInfo"/>
|
||||||
|
|
||||||
<ms-change-history ref="changeHistory"/>
|
<ms-change-history ref="changeHistory"/>
|
||||||
|
|
||||||
|
@ -157,6 +157,26 @@
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
<el-dialog
|
||||||
|
title="同步以下信息到新版本"
|
||||||
|
:visible.sync="createNewVersionVisible"
|
||||||
|
:show-close="false"
|
||||||
|
width="30%"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<el-checkbox v-model="httpForm.newVersionRemark">备注</el-checkbox>
|
||||||
|
<el-checkbox v-model="httpForm.newVersionDeps">依赖关系</el-checkbox>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-slot:footer>
|
||||||
|
<ms-dialog-footer
|
||||||
|
@cancel="cancelCreateNewVersion"
|
||||||
|
:title="$t('commons.edit_info')"
|
||||||
|
@confirm="saveApi">
|
||||||
|
</ms-dialog-footer>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -176,6 +196,7 @@ import ApiOtherInfo from "@/business/components/api/definition/components/comple
|
||||||
import HttpApiVersionDiff from "./version/HttpApiVersionDiff"
|
import HttpApiVersionDiff from "./version/HttpApiVersionDiff"
|
||||||
import {createComponent } from ".././jmeter/components";
|
import {createComponent } from ".././jmeter/components";
|
||||||
import { TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
import { TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
||||||
|
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
||||||
|
|
||||||
const {Body} = require("@/business/components/api/definition/model/ApiTestModel");
|
const {Body} = require("@/business/components/api/definition/model/ApiTestModel");
|
||||||
const Sampler = require("@/business/components/api/definition/components/jmeter/components/sampler/sampler");
|
const Sampler = require("@/business/components/api/definition/components/jmeter/components/sampler/sampler");
|
||||||
|
@ -186,6 +207,7 @@ const versionHistory = requireComponent.keys().length > 0 ? requireComponent("./
|
||||||
export default {
|
export default {
|
||||||
name: "MsAddCompleteHttpApi",
|
name: "MsAddCompleteHttpApi",
|
||||||
components: {
|
components: {
|
||||||
|
MsDialogFooter,
|
||||||
'MsVersionHistory': versionHistory.default,
|
'MsVersionHistory': versionHistory.default,
|
||||||
ApiOtherInfo,
|
ApiOtherInfo,
|
||||||
MsFormDivider,
|
MsFormDivider,
|
||||||
|
@ -233,7 +255,8 @@ export default {
|
||||||
count: 0,
|
count: 0,
|
||||||
versionData: [],
|
versionData: [],
|
||||||
oldRequest:Sampler,
|
oldRequest:Sampler,
|
||||||
oldResponse:{}
|
oldResponse:{},
|
||||||
|
createNewVersionVisible: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {moduleOptions: {}, request: {}, response: {}, basisData: {}, syncTabs: Array, projectId: String},
|
props: {moduleOptions: {}, request: {}, response: {}, basisData: {}, syncTabs: Array, projectId: String},
|
||||||
|
@ -623,6 +646,10 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
cancelCreateNewVersion() {
|
||||||
|
this.createNewVersionVisible = false;
|
||||||
|
this.getVersionHistory();
|
||||||
|
},
|
||||||
checkout(row) {
|
checkout(row) {
|
||||||
let api = this.versionData.filter(v => v.versionId === row.id)[0];
|
let api = this.versionData.filter(v => v.versionId === row.id)[0];
|
||||||
if (api.tags && api.tags.length > 0) {
|
if (api.tags && api.tags.length > 0) {
|
||||||
|
@ -633,7 +660,14 @@ export default {
|
||||||
create(row) {
|
create(row) {
|
||||||
// 创建新版本
|
// 创建新版本
|
||||||
this.httpForm.versionId = row.id;
|
this.httpForm.versionId = row.id;
|
||||||
this.saveApi();
|
|
||||||
|
this.httpForm.newVersionRemark = !!this.httpForm.remark;
|
||||||
|
this.httpForm.newVersionDeps = this.$refs.apiOtherInfo.relationshipCount > 0;
|
||||||
|
if (this.$refs.apiOtherInfo.relationshipCount > 0 || this.httpForm.remark) {
|
||||||
|
this.createNewVersionVisible = true;
|
||||||
|
} else {
|
||||||
|
this.saveApi();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
del(row) {
|
del(row) {
|
||||||
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ?", '', {
|
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ?", '', {
|
||||||
|
|
Loading…
Reference in New Issue