feat(接口自动化): 修复部分缺陷

This commit is contained in:
fit2-zhao 2021-01-12 14:51:15 +08:00
parent 86b19b68fc
commit a1eac0996f
4 changed files with 77 additions and 72 deletions

View File

@ -24,7 +24,7 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
@ -214,22 +214,21 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
request.setUpdateTime(System.currentTimeMillis()); request.setUpdateTime(System.currentTimeMillis());
checkApiModuleExist(request); checkApiModuleExist(request);
List<ApiDefinitionResult> apiDefinitionResults = queryByModuleIds(request.getNodeIds()); List<ApiDefinitionResult> apiDefinitionResults = queryByModuleIds(request.getNodeIds());
if (CollectionUtils.isNotEmpty(apiDefinitionResults)) {
apiDefinitionResults.forEach(apiDefinition -> { apiDefinitionResults.forEach(apiDefinition -> {
if (StringUtils.isNotBlank(apiDefinition.getModulePath())) { if (apiDefinition != null && StringUtils.isNotBlank(apiDefinition.getModulePath())) {
StringBuilder path = new StringBuilder(apiDefinition.getModulePath()); StringBuilder path = new StringBuilder(apiDefinition.getModulePath());
List<String> pathLists = Arrays.asList(path.toString().split("/")); List<String> pathLists = Arrays.asList(path.toString().split("/"));
pathLists.set(request.getLevel(), request.getName()); pathLists.set(request.getLevel(), request.getName());
path.delete(0, path.length()); path.delete(0, path.length());
for (int i = 1; i < pathLists.size(); i++) { for (int i = 1; i < pathLists.size(); i++) {
path = path.append("/").append(pathLists.get(i)); path = path.append("/").append(pathLists.get(i));
}
apiDefinition.setModulePath(path.toString());
} }
apiDefinition.setModulePath(path.toString()); });
} batchUpdateApiDefinition(apiDefinitionResults);
}); }
batchUpdateApiDefinition(apiDefinitionResults);
return apiModuleMapper.updateByPrimaryKeySelective(request); return apiModuleMapper.updateByPrimaryKeySelective(request);
} }

View File

@ -29,68 +29,70 @@
</template> </template>
<script> <script>
import MsBasisApi from "./BasisApi"; import MsBasisApi from "./BasisApi";
import MsBasisParameters from "../request/dubbo/BasisParameters"; import MsBasisParameters from "../request/dubbo/BasisParameters";
export default { export default {
name: "MsApiDubboRequestForm", name: "MsApiDubboRequestForm",
components: { components: {
MsBasisApi, MsBasisParameters MsBasisApi, MsBasisParameters
},
props: {
request: {},
basisData: {},
moduleOptions: Array,
isReadOnly: {
type: Boolean,
default: false
}
},
data() {
return {validated: false}
},
methods: {
callback() {
this.validated = true;
}, },
validateApi() { props: {
this.validated = false; request: {},
this.basisData.method = this.request.protocol; basisData: {},
this.$refs['basicForm'].validate(); moduleOptions: Array,
isReadOnly: {
type: Boolean,
default: false
}
}, },
saveApi() { data() {
this.validateApi(); return {validated: false}
if (this.validated) { },
this.basisData.request = this.request; methods: {
console.log(this.basisData) callback() {
if (this.basisData.tags instanceof Array) { this.validated = true;
this.basisData.tags = JSON.stringify(this.basisData.tags); },
validateApi() {
this.validated = false;
this.basisData.method = this.request.protocol;
this.$refs['basicForm'].validate();
},
saveApi() {
this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
if (this.basisData.tags instanceof Array) {
this.basisData.tags = JSON.stringify(this.basisData.tags);
}
this.$emit('saveApi', this.basisData);
} }
this.$emit('saveApi', this.basisData); },
} runTest() {
this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
if (this.basisData.tags instanceof Array) {
this.basisData.tags = JSON.stringify(this.basisData.tags);
}
this.$emit('runTest', this.basisData);
}
},
createRootModelInTree() {
this.$emit("createRootModelInTree");
},
}, },
runTest() {
this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
this.$emit('runTest', this.basisData);
}
},
createRootModelInTree() {
this.$emit("createRootModelInTree");
},
},
computed: {} computed: {}
} }
</script> </script>
<style scoped> <style scoped>
.tip { .tip {
padding: 3px 5px; padding: 3px 5px;
font-size: 16px; font-size: 16px;
border-radius: 4px; border-radius: 4px;
border-left: 4px solid #783887; border-left: 4px solid #783887;
margin: 0px 20px 0px; margin: 0px 20px 0px;
} }
</style> </style>

View File

@ -71,6 +71,10 @@ export default {
this.validateApi(); this.validateApi();
if (this.validated) { if (this.validated) {
this.basisData.request = this.request; this.basisData.request = this.request;
this.basisData.method = this.basisData.protocol;
if (this.basisData.tags instanceof Array) {
this.basisData.tags = JSON.stringify(this.basisData.tags);
}
this.$emit('runTest', this.basisData); this.$emit('runTest', this.basisData);
} }
}, },

View File

@ -3,7 +3,7 @@
<el-row> <el-row>
<el-col :span="21" style="padding-bottom: 20px"> <el-col :span="21" style="padding-bottom: 20px">
<div style="border:1px #DCDFE6 solid; height: 100%;border-radius: 4px ;width: 100% ;margin: 10px"> <div style="border:1px #DCDFE6 solid; height: 100%;border-radius: 4px ;width: 100% ;margin: 10px">
<el-form class="tcp" :model="request" :rules="rules" ref="request" label-width="auto" :disabled="isReadOnly" style="margin: 20px"> <el-form class="tcp" :model="request" :rules="rules" ref="request" :disabled="isReadOnly" style="margin: 20px">
<el-tabs v-model="activeName" class="request-tabs"> <el-tabs v-model="activeName" class="request-tabs">