refactor: 创建新接口版本时同步备注和依赖关系
This commit is contained in:
parent
4780eb2f05
commit
feee6e323b
|
@ -60,4 +60,8 @@ public class SaveApiDefinitionRequest {
|
|||
private String esbDataStruct;
|
||||
private String backEsbDataStruct;
|
||||
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.JSONToDocumentUtils;
|
||||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.controller.request.RelationshipEdgeRequest;
|
||||
import io.metersphere.controller.request.ResetOrderRequest;
|
||||
import io.metersphere.controller.request.ScheduleRequest;
|
||||
import io.metersphere.dto.MsExecResponseDTO;
|
||||
|
@ -554,7 +555,30 @@ public class ApiDefinitionService {
|
|||
test.setCreateUser(SessionUtils.getUserId());
|
||||
test.setOrder(oldApi.getOrder());
|
||||
test.setRefId(oldApi.getRefId());
|
||||
// 创建新版是否关联备注
|
||||
if (!request.isNewVersionRemark()) {
|
||||
test.setRemark(null);
|
||||
}
|
||||
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.setTargetNum(apiDefinition.getNum());
|
||||
relationshipEdgeDTO.setStatus(apiDefinition.getStatus());
|
||||
relationshipEdgeDTO.setVersionId(apiDefinition.getVersionId());
|
||||
results.add(relationshipEdgeDTO);
|
||||
}
|
||||
return results;
|
||||
|
|
|
@ -10,4 +10,5 @@ public class RelationshipEdgeDTO extends RelationshipEdge {
|
|||
private String targetCustomNum;
|
||||
private String status;
|
||||
private String creator;
|
||||
private String versionId;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div>
|
||||
<ms-table
|
||||
<ms-table
|
||||
v-loading="result.loading"
|
||||
:show-select-all="false"
|
||||
:data="data"
|
||||
|
@ -20,22 +20,33 @@
|
|||
:label="$t('commons.name')"
|
||||
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
|
||||
prop="creator"
|
||||
:label="$t('commons.create_user')"
|
||||
min-width="120">
|
||||
</ms-table-column>
|
||||
|
||||
<ms-table-column
|
||||
prop="status"
|
||||
min-width="120px"
|
||||
:label="$t('api_test.definition.api_status')">
|
||||
<template v-slot:default="scope">
|
||||
<ms-table-column
|
||||
prop="status"
|
||||
min-width="120px"
|
||||
:label="$t('api_test.definition.api_status')">
|
||||
<template v-slot:default="scope">
|
||||
<span class="el-dropdown-link">
|
||||
<api-status :value="scope.row.status"/>
|
||||
</span>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
|
||||
</ms-table>
|
||||
|
||||
|
@ -58,11 +69,14 @@ import {getRelationshipApi} from "@/network/api";
|
|||
import ApiRelationshipRelevance
|
||||
from "@/business/components/api/definition/components/complete/ApiRelationshipRelevance";
|
||||
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
|
||||
import {getCurrentProjectID} from "@/common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "ApiRelationshipList",
|
||||
components: {
|
||||
ApiStatus,
|
||||
ApiRelationshipRelevance, RelationshipFunctionalRelevance, MsTableSearchBar, MsTableColumn, MsTable},
|
||||
ApiRelationshipRelevance, RelationshipFunctionalRelevance, MsTableSearchBar, MsTableColumn, MsTable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
result: {},
|
||||
|
@ -76,14 +90,22 @@ export default {
|
|||
],
|
||||
condition: {},
|
||||
options: [],
|
||||
value: ''
|
||||
}
|
||||
value: '',
|
||||
versionOptions: {},
|
||||
versionEnable: false,
|
||||
};
|
||||
},
|
||||
props: {
|
||||
apiDefinitionId: String,
|
||||
readOnly: Boolean,
|
||||
relationshipType: String,
|
||||
},
|
||||
created() {
|
||||
this.getProjectVersions();
|
||||
this.$get('/project/version/enable/' + getCurrentProjectID(), response => {
|
||||
this.versionEnable = response.data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
getTableData() {
|
||||
getRelationshipApi(this.apiDefinitionId, this.relationshipType, (data) => {
|
||||
|
@ -97,8 +119,16 @@ export default {
|
|||
handleDelete(item) {
|
||||
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>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
<ms-form-divider :title="$t('api_test.definition.request.res_param')"/>
|
||||
<ms-response-text :response="response"/>
|
||||
|
||||
<api-other-info :api="httpForm"/>
|
||||
<api-other-info :api="httpForm" ref="apiOtherInfo"/>
|
||||
|
||||
<ms-change-history ref="changeHistory"/>
|
||||
|
||||
|
@ -157,6 +157,26 @@
|
|||
</el-dialog>
|
||||
|
||||
</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>
|
||||
</template>
|
||||
|
||||
|
@ -176,6 +196,7 @@ import ApiOtherInfo from "@/business/components/api/definition/components/comple
|
|||
import HttpApiVersionDiff from "./version/HttpApiVersionDiff"
|
||||
import {createComponent } from ".././jmeter/components";
|
||||
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 Sampler = require("@/business/components/api/definition/components/jmeter/components/sampler/sampler");
|
||||
|
@ -186,6 +207,7 @@ const versionHistory = requireComponent.keys().length > 0 ? requireComponent("./
|
|||
export default {
|
||||
name: "MsAddCompleteHttpApi",
|
||||
components: {
|
||||
MsDialogFooter,
|
||||
'MsVersionHistory': versionHistory.default,
|
||||
ApiOtherInfo,
|
||||
MsFormDivider,
|
||||
|
@ -233,7 +255,8 @@ export default {
|
|||
count: 0,
|
||||
versionData: [],
|
||||
oldRequest:Sampler,
|
||||
oldResponse:{}
|
||||
oldResponse:{},
|
||||
createNewVersionVisible: false,
|
||||
};
|
||||
},
|
||||
props: {moduleOptions: {}, request: {}, response: {}, basisData: {}, syncTabs: Array, projectId: String},
|
||||
|
@ -623,6 +646,10 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
cancelCreateNewVersion() {
|
||||
this.createNewVersionVisible = false;
|
||||
this.getVersionHistory();
|
||||
},
|
||||
checkout(row) {
|
||||
let api = this.versionData.filter(v => v.versionId === row.id)[0];
|
||||
if (api.tags && api.tags.length > 0) {
|
||||
|
@ -633,7 +660,14 @@ export default {
|
|||
create(row) {
|
||||
// 创建新版本
|
||||
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) {
|
||||
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ?", '', {
|
||||
|
|
Loading…
Reference in New Issue