feat (接口定义): 完成http协议操作历史
This commit is contained in:
parent
6b9e9c1f5e
commit
c79a7732e7
|
@ -154,10 +154,10 @@ public class ReflexObjectUtil {
|
|||
DetailColumn column = new DetailColumn();
|
||||
BeanUtils.copyBean(column, originalColumns.get(i));
|
||||
column.setNewValue(newColumns.get(i).getOriginalValue());
|
||||
if (originalColumns.get(i).getColumnName().equals("tags")) {
|
||||
if (StringUtils.isNotEmpty(originalColumns.get(i).getColumnName()) && originalColumns.get(i).getColumnName().equals("tags")) {
|
||||
GsonDiff diff = new GsonDiff();
|
||||
String oldTags = "{\"root\":" + originalColumns.get(i).getOriginalValue().toString() + "}";
|
||||
String newTags = "{\"root\":" + newColumns.get(i).getOriginalValue().toString() + "}";
|
||||
String oldTags = "{\"root\":" + ((originalColumns.get(i) != null && originalColumns.get(i).getOriginalValue() != null) ? originalColumns.get(i).getOriginalValue().toString() : "\"\"") + "}";
|
||||
String newTags = "{\"root\":" + ((newColumns.get(i) != null && newColumns.get(i).getOriginalValue() != null) ? newColumns.get(i).getOriginalValue().toString() : "\"\"") + "}";
|
||||
String diffStr = diff.diff(oldTags, newTags);
|
||||
String diffValue = diff.apply(newTags, diffStr);
|
||||
column.setDiffValue(diffValue);
|
||||
|
|
|
@ -50,7 +50,9 @@ public class ApiDefinitionDiffUtil {
|
|||
MsDubboSampler dubboSamplerOld = bloBsOld.toJavaObject(MsDubboSampler.class);
|
||||
diffDubbo(dubboSamplerNew, dubboSamplerOld, jsonDiff, diffMap);
|
||||
}
|
||||
if (diffMap.size() > 1) {
|
||||
return JSON.toJSONString(diffMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -59,7 +61,7 @@ public class ApiDefinitionDiffUtil {
|
|||
|
||||
private static void diffHttp(MsHTTPSamplerProxy httpNew, MsHTTPSamplerProxy httpOld, JsonDiff jsonDiff, Map<String, String> diffMap) {
|
||||
// 请求头对比 old/new
|
||||
if (CollectionUtils.isNotEmpty(httpNew.getHeaders())) {
|
||||
if (CollectionUtils.isNotEmpty(httpNew.getHeaders()) && CollectionUtils.isNotEmpty(httpOld.getHeaders())) {
|
||||
httpNew.getHeaders().remove(httpNew.getHeaders().size() - 1);
|
||||
httpOld.getHeaders().remove(httpOld.getHeaders().size() - 1);
|
||||
}
|
||||
|
@ -73,7 +75,7 @@ public class ApiDefinitionDiffUtil {
|
|||
}
|
||||
}
|
||||
// 对比QUERY参数
|
||||
if (CollectionUtils.isNotEmpty(httpNew.getArguments())) {
|
||||
if (CollectionUtils.isNotEmpty(httpNew.getArguments()) && CollectionUtils.isNotEmpty(httpOld.getArguments())) {
|
||||
httpNew.getArguments().remove(httpNew.getArguments().size() - 1);
|
||||
httpOld.getArguments().remove(httpOld.getArguments().size() - 1);
|
||||
}
|
||||
|
@ -87,7 +89,7 @@ public class ApiDefinitionDiffUtil {
|
|||
}
|
||||
}
|
||||
// 对比REST参数
|
||||
if (CollectionUtils.isNotEmpty(httpNew.getRest())) {
|
||||
if (CollectionUtils.isNotEmpty(httpNew.getRest()) && CollectionUtils.isNotEmpty(httpOld.getRest())) {
|
||||
httpNew.getRest().remove(httpNew.getRest().size() - 1);
|
||||
httpOld.getRest().remove(httpOld.getRest().size() - 1);
|
||||
}
|
||||
|
@ -112,7 +114,7 @@ public class ApiDefinitionDiffUtil {
|
|||
}
|
||||
}
|
||||
// 对比BODY-FORM参数
|
||||
if (CollectionUtils.isNotEmpty(httpNew.getBody().getKvs())) {
|
||||
if (CollectionUtils.isNotEmpty(httpNew.getBody().getKvs()) && CollectionUtils.isNotEmpty(httpOld.getBody().getKvs())) {
|
||||
httpNew.getBody().getKvs().remove(httpNew.getBody().getKvs().size() - 1);
|
||||
httpOld.getBody().getKvs().remove(httpOld.getBody().getKvs().size() - 1);
|
||||
}
|
||||
|
@ -131,6 +133,25 @@ public class ApiDefinitionDiffUtil {
|
|||
diffMap.put("body_raw_2", httpOld.getBody().getRaw());
|
||||
}
|
||||
|
||||
// 认证配置
|
||||
if (httpNew.getAuthManager() != null || httpOld.getAuthManager() != null) {
|
||||
List<DetailColumn> authColumns = ReflexObjectUtil.getColumns(httpNew.getAuthManager(), DefinitionReference.authColumns);
|
||||
List<DetailColumn> authColumnsOld = ReflexObjectUtil.getColumns(httpOld.getAuthManager(), DefinitionReference.authColumns);
|
||||
List<DetailColumn> authDiffColumns = getColumn(authColumns, authColumnsOld);
|
||||
if (CollectionUtils.isNotEmpty(authDiffColumns)) {
|
||||
diffMap.put("body_auth", JSON.toJSONString(authDiffColumns));
|
||||
} else if (CollectionUtils.isEmpty(authDiffColumns) && CollectionUtils.isEmpty(authColumnsOld) && CollectionUtils.isNotEmpty(authColumns)) {
|
||||
diffMap.put("body_auth", JSON.toJSONString(authColumns));
|
||||
}
|
||||
}
|
||||
|
||||
// 其他设置
|
||||
List<DetailColumn> columns = ReflexObjectUtil.getColumns(httpNew, DefinitionReference.httpColumns);
|
||||
List<DetailColumn> columnsOld = ReflexObjectUtil.getColumns(httpOld, DefinitionReference.httpColumns);
|
||||
List<DetailColumn> diffColumns = getColumn(columns, columnsOld);
|
||||
if (CollectionUtils.isNotEmpty(diffColumns)) {
|
||||
diffMap.put("body_config", JSON.toJSONString(diffColumns));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,15 @@ public class DefinitionReference {
|
|||
public static Map<String, String> definitionColumns = new LinkedHashMap<>();
|
||||
public static Map<String, String> caseColumns = new LinkedHashMap<>();
|
||||
public static Map<String, String> jdbcColumns = new LinkedHashMap<>();
|
||||
public static Map<String, String> httpColumns = new LinkedHashMap<>();
|
||||
public static Map<String, String> authColumns = new LinkedHashMap<>();
|
||||
|
||||
static {
|
||||
definitionColumns.clear();
|
||||
caseColumns.clear();
|
||||
jdbcColumns.clear();
|
||||
httpColumns.clear();
|
||||
authColumns.clear();
|
||||
definitionColumns.put("name", "接口名称");
|
||||
definitionColumns.put("createUser", "创建人");
|
||||
definitionColumns.put("method", "请求类型");
|
||||
|
@ -46,6 +50,16 @@ public class DefinitionReference {
|
|||
jdbcColumns.put("queryTimeout", "超时时间");
|
||||
jdbcColumns.put("resultVariable", "存储结果");
|
||||
jdbcColumns.put("variableNames", "按列存储");
|
||||
// http
|
||||
httpColumns.put("connectTimeout","连接超时");
|
||||
httpColumns.put("responseTimeout","响应超时");
|
||||
httpColumns.put("alias","证书别名");
|
||||
httpColumns.put("followRedirects","跟随重定向");
|
||||
// http auth
|
||||
authColumns.put("verification","认证方式");
|
||||
authColumns.put("username","用户名");
|
||||
authColumns.put("password","密码");
|
||||
authColumns.put("encrypt","加密");
|
||||
|
||||
}
|
||||
}
|
|
@ -99,7 +99,9 @@
|
|||
this.request.hashTree.splice(index, 1);
|
||||
}
|
||||
}
|
||||
this.request.authManager = {};
|
||||
}
|
||||
this.request.authManager = this.authConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,20 @@
|
|||
<el-tabs v-model="activeName">
|
||||
<el-tab-pane label="Config Center" name="config" v-if="request.config && request.config.length > 0">
|
||||
<el-table :data="request.config">
|
||||
<el-table-column prop="columnTitle" :label="$t('operating_log.change_field')">
|
||||
</el-table-column>
|
||||
<el-table-column prop="columnTitle" :label="$t('operating_log.change_field')"/>
|
||||
<el-table-column prop="originalValue" :label="$t('operating_log.before_change')">
|
||||
<template v-slot:default="scope">
|
||||
<el-tooltip :content="scope.row.originalValue">
|
||||
<div class="current-value ms-tag-del">{{ scope.row.originalValue }}</div>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="newValue" :label="$t('operating_log.after_change')">
|
||||
<template v-slot:default="scope">
|
||||
<el-tooltip :content="scope.row.newValue">
|
||||
<div class="current-value ms-tag-add">{{ scope.row.newValue }}</div>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
|
@ -113,6 +122,7 @@ export default {
|
|||
white-space: nowrap;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.ms-tag-del {
|
||||
text-decoration: line-through;
|
||||
text-decoration-color: red;
|
||||
|
|
|
@ -101,9 +101,13 @@ export default {
|
|||
this.detail.body = {};
|
||||
this.detail.headerId = getUUID();
|
||||
if (diffValue.body) {
|
||||
let jsonSchema = (JSON.parse(diffValue.body)).jsonSchema;
|
||||
this.formatJson(jsonSchema.properties);
|
||||
this.detail.body.jsonSchema = jsonSchema;
|
||||
let json = (JSON.parse(diffValue.body));
|
||||
if (json && json.jsonSchema && json.jsonSchema.properties) {
|
||||
this.formatJson(json.jsonSchema.properties);
|
||||
this.detail.body.jsonSchema = json.jsonSchema;
|
||||
} else if (json && json["++jsonSchema"]) {
|
||||
this.detail.body.jsonSchema = json["++jsonSchema"];
|
||||
}
|
||||
this.detail.headerId = getUUID();
|
||||
}
|
||||
if (diffValue.body_form) {
|
||||
|
@ -131,6 +135,14 @@ export default {
|
|||
this.detail.rest = rest;
|
||||
this.detail.headerId = getUUID();
|
||||
}
|
||||
if (diffValue.body_auth) {
|
||||
this.detail.body_auth = JSON.parse(diffValue.body_auth);
|
||||
this.detail.headerId = getUUID();
|
||||
}
|
||||
if (diffValue.body_config) {
|
||||
this.detail.body_config = JSON.parse(diffValue.body_config);
|
||||
this.detail.headerId = getUUID();
|
||||
}
|
||||
},
|
||||
formatTcp(diffValue) {
|
||||
if (!this.detail.body) {
|
||||
|
|
|
@ -30,11 +30,46 @@
|
|||
</el-tab-pane>
|
||||
|
||||
<!--认证配置 -->
|
||||
<!-- <el-tab-pane :label="$t('api_test.definition.request.auth_config')" name="authConfig">-->
|
||||
<!-- </el-tab-pane>-->
|
||||
<el-tab-pane :label="$t('api_test.definition.request.auth_config')" name="authConfig" v-if="request.body_auth">
|
||||
<el-table :data="request.body_auth">
|
||||
<el-table-column prop="columnTitle" :label="$t('operating_log.change_field')"/>
|
||||
<el-table-column prop="originalValue" :label="$t('operating_log.before_change')">
|
||||
<template v-slot:default="scope">
|
||||
<el-tooltip :content="scope.row.originalValue">
|
||||
<div class="current-value ms-tag-del">{{ scope.row.originalValue }}</div>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="newValue" :label="$t('operating_log.after_change')">
|
||||
<template v-slot:default="scope">
|
||||
<el-tooltip :content="scope.row.newValue">
|
||||
<div class="current-value ms-tag-add">{{ scope.row.newValue }}</div>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- <el-tab-pane :label="$t('api_test.definition.request.other_config')" name="advancedConfig">-->
|
||||
<!-- </el-tab-pane>-->
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane :label="$t('api_test.definition.request.other_config')" name="advancedConfig" v-if="request.body_config">
|
||||
<el-table :data="request.body_config">
|
||||
<el-table-column prop="columnTitle" :label="$t('operating_log.change_field')"/>
|
||||
<el-table-column prop="originalValue" :label="$t('operating_log.before_change')">
|
||||
<template v-slot:default="scope">
|
||||
<el-tooltip :content="scope.row.originalValue">
|
||||
<div class="current-value ms-tag-del">{{ scope.row.originalValue }}</div>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="newValue" :label="$t('operating_log.after_change')">
|
||||
<template v-slot:default="scope">
|
||||
<el-tooltip :content="scope.row.newValue">
|
||||
<div class="current-value ms-tag-add">{{ scope.row.newValue }}</div>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -79,6 +114,10 @@ export default {
|
|||
this.activeName = "headers";
|
||||
} else if (this.request.rest) {
|
||||
this.activeName = "rest";
|
||||
} else if (this.request.body_config) {
|
||||
this.activeName = "advancedConfig";
|
||||
} else if (this.request.body_auth) {
|
||||
this.activeName = "authConfig";
|
||||
}
|
||||
this.reloadCodeEdit();
|
||||
},
|
||||
|
@ -101,6 +140,10 @@ export default {
|
|||
this.activeName = "headers";
|
||||
} else if (this.request.rest) {
|
||||
this.activeName = "rest";
|
||||
} else if (this.request.body_config) {
|
||||
this.activeName = "advancedConfig";
|
||||
} else if (this.request.body_auth) {
|
||||
this.activeName = "authConfig";
|
||||
}
|
||||
this.reloadCodeEdit();
|
||||
}
|
||||
|
@ -145,6 +188,27 @@ export default {
|
|||
margin-right: 45px;
|
||||
}
|
||||
|
||||
.current-value {
|
||||
display: inline-block;
|
||||
overflow-x: hidden;
|
||||
padding-bottom: 0;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.ms-tag-del {
|
||||
text-decoration: line-through;
|
||||
text-decoration-color: red;
|
||||
-moz-text-decoration-line: line-through;
|
||||
background: #F3E6E7;
|
||||
}
|
||||
|
||||
.ms-tag-add {
|
||||
background: #E2ECDC;
|
||||
}
|
||||
|
||||
@import "~jsondiffpatch/dist/formatters-styles/html.css";
|
||||
@import "~jsondiffpatch/dist/formatters-styles/annotated.css";
|
||||
|
||||
|
|
|
@ -3,11 +3,20 @@
|
|||
<el-tabs v-model="activeName">
|
||||
<el-tab-pane :label="$t('api_test.definition.request.req_param')" name="parameters" v-if="request.base && request.base.length > 0">
|
||||
<el-table :data="request.base">
|
||||
<el-table-column prop="columnTitle" :label="$t('operating_log.change_field')">
|
||||
</el-table-column>
|
||||
<el-table-column prop="columnTitle" :label="$t('operating_log.change_field')"/>
|
||||
<el-table-column prop="originalValue" :label="$t('operating_log.before_change')">
|
||||
<template v-slot:default="scope">
|
||||
<el-tooltip :content="scope.row.originalValue">
|
||||
<div class="current-value ms-tag-del">{{ scope.row.originalValue }}</div>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="newValue" :label="$t('operating_log.after_change')">
|
||||
<template v-slot:default="scope">
|
||||
<el-tooltip :content="scope.row.newValue">
|
||||
<div class="current-value ms-tag-add">{{ scope.row.newValue }}</div>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
|
@ -90,6 +99,27 @@ export default {
|
|||
display: inline-block;
|
||||
}
|
||||
|
||||
.current-value {
|
||||
display: inline-block;
|
||||
overflow-x: hidden;
|
||||
padding-bottom: 0;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.ms-tag-del {
|
||||
text-decoration: line-through;
|
||||
text-decoration-color: red;
|
||||
-moz-text-decoration-line: line-through;
|
||||
background: #F3E6E7;
|
||||
}
|
||||
|
||||
.ms-tag-add {
|
||||
background: #E2ECDC;
|
||||
}
|
||||
|
||||
.one-row .el-form-item:nth-child(2) {
|
||||
margin-left: 60px;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue