fix: 修复Mock设置的相关问题、更改首页tips

修复Mock设置中删除期望未二次确认的问题、修改tips由天冷了该为天热了、增加或修改期望时增加名称唯一性验证
This commit is contained in:
song-tianyang 2021-04-19 18:22:01 +08:00 committed by 刘瑞斌
parent aae13f0342
commit 1f6c3891a3
11 changed files with 50 additions and 17 deletions

View File

@ -139,7 +139,7 @@ public class ApiTestEnvironmentService {
JSONObject tcpConfigObj = new JSONObject();
tcpConfigObj.put("classname", "TCPClientImpl");
tcpConfigObj.put("reUseConnection", true);
tcpConfigObj.put("reUseConnection", false);
tcpConfigObj.put("nodelay", false);
tcpConfigObj.put("closeConnection", false);

View File

@ -10,7 +10,9 @@ import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiDefinitionMapper;
import io.metersphere.base.mapper.MockConfigMapper;
import io.metersphere.base.mapper.MockExpectConfigMapper;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.i18n.Translator;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -88,6 +90,8 @@ public class MockConfigService {
}
public MockExpectConfig updateMockExpectConfig(MockExpectConfigRequest request) {
//检查名称是否存在
this.checkNameIsExists(request);
boolean isSave = false;
if (StringUtils.isEmpty(request.getId())) {
isSave = true;
@ -120,6 +124,15 @@ public class MockConfigService {
return model;
}
private void checkNameIsExists(MockExpectConfigRequest request) {
MockExpectConfigExample example = new MockExpectConfigExample();
example.createCriteria().andMockConfigIdEqualTo(request.getMockConfigId()).andNameEqualTo(request.getName().trim());
long count = mockExpectConfigMapper.countByExample(example);
if (count > 0) {
MSException.throwException(Translator.get("expect_name_exists") + ":" + request.getName());
}
}
public MockExpectConfigResponse findExpectConfig(List<MockExpectConfigResponse> mockExpectConfigList, Map<String, String> paramMap) {
MockExpectConfigResponse returnModel = null;

View File

@ -65,3 +65,4 @@ please_input_workspace_member=
test_case_report_template_repeat=
custom_field_already=
template_already=
expect_name_exists=

View File

@ -215,4 +215,4 @@ authsource_configuration_is_null=Authentication source configuration cannot be e
mobile_phone_number_cannot_be_empty=When the receiving mode is pin and enterprise wechat: the user's mobile phone number cannot be empty
custom_field_already=A feild already exists under this workspace:
template_already=A template already exists under this workspace:
expect_name_exists=Expect name is exists

View File

@ -215,4 +215,4 @@ authsource_name_is_null=认证源名称不能为空
authsource_configuration_is_null=认证源配置不能为空
custom_field_already=工作空间下已存在该字段:
template_already=工作空间下已存在该模板:
expect_name_exists=预期名称已存在

View File

@ -216,4 +216,4 @@ authsource_name_is_null=認證源名稱不能為空
authsource_configuration_is_null=認證源配置不能為空
custom_field_already=工作空間下已存在該字段:
template_already=工作空間下已存在該模板:
expect_name_exists=預期名稱已存在

View File

@ -3,7 +3,7 @@
<p class="tip">期望列表</p>
<div class="card">
<el-input :placeholder="$t('commons.search_by_name')" class="search-input" size="small"
clearable="serchInputClearable"
:clearable="serchInputClearable"
v-model="tableSearch"/>
<el-table ref="table" border
:data="mockConfigData.mockExpectConfigList.filter(data=>!tableSearch || data.name.toLowerCase().includes(tableSearch.toLowerCase()))"
@ -117,7 +117,7 @@
:items="mockExpectConfig.response.httpHeads" ref="rspHttpHead"/>
</el-row>
<el-row style="margin-top: 10px;">
<el-form-item label="Body:" label-width="50px" prop="response.body">
<el-form-item label="Body:" label-width="50px">
<ms-code-edit height="200px" :mode="'txt'" ref="codeEdit" :data.sync="mockExpectConfig.response.body"
style="margin-top: 10px;"/>
</el-form-item>
@ -197,7 +197,6 @@ export default {
response: {
httpCode: [{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},],
delayed: [{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},],
body: [{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},],
},
},
};
@ -244,16 +243,29 @@ export default {
});
},
removeExpect(row) {
let mockInfoId = row.mockConfigId;
let selectUrl = "/mockConfig/deleteMockExpectConfig/" + row.id;
this.$get(selectUrl, response => {
this.cleanMockExpectConfig();
this.refreshMockInfo(mockInfoId);
this.$confirm(this.$t('api_test.mock.delete_mock_expect'), this.$t('commons.prompt'), {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
let mockInfoId = row.mockConfigId;
let selectUrl = "/mockConfig/deleteMockExpectConfig/" + row.id;
this.$get(selectUrl, response => {
this.cleanMockExpectConfig();
this.refreshMockInfo(mockInfoId);
this.$message({
type: 'success',
message: this.$t('commons.delete_success'),
});
});
}).catch(() => {
});
},
saveMockExpectConfig() {
let mockConfigId = this.mockConfigData.mockConfig.id;
this.mockExpectConfig.mockConfigId = mockConfigId;
this.mockExpectConfig.id = "";
let formCheckResult = this.checkMockExpectForm("mockExpectForm");
this.cleanMockExpectConfig();
},
@ -289,6 +301,10 @@ export default {
let returnData = response.data;
this.mockExpectConfig.id = returnData.id;
this.refreshMockInfo(param.mockConfigId);
this.$message({
type: 'success',
message: this.$t('commons.save_success'),
});
});
},
refreshMockInfo(mockConfigId) {

View File

@ -85,7 +85,7 @@ export default {
interfaceCoverage: "waitting...",
tipsType: "1",
result: {},
seasonTips: "🤔️ 天热了,小风扇买了吗?",
seasonTips: "😊 MeterSphere温馨提醒 —— 多喝热水哟!",
}
},
activated() {
@ -98,15 +98,15 @@ export default {
checkTipsType() {
var random = Math.floor(Math.random() * (4 - 1 + 1)) + 1;
this.tipsType = random + "";
let today = new Date();
let month = today.getMonth();
if (month > 9 && month < 3) {
this.seasonTips = "🤔️ 天热了,小风扇买了吗?";
} else {
if (9 > month > 4) {
this.seasonTips = "🤔️ 天凉了,保温杯买了吗?";
} else {
this.seasonTips = "🤔️天热了,小风扇买了吗?";
}
},
search() {
let selectProjectId = getCurrentProjectID();

View File

@ -610,6 +610,7 @@ export default {
base_info: "Base info",
req_param: "Request params",
rsp_param: "Response Params",
delete_mock_expect: "Confirm to delete this expect info ?",
},
definition: {
api_title: "Api test",

View File

@ -619,6 +619,7 @@ export default {
base_info: "基本信息",
req_param: "请求参数",
rsp_param: "响应内容",
delete_mock_expect: "确认删除这条预期吗?",
},
definition: {
api_title: "接口列表",

View File

@ -609,6 +609,7 @@ export default {
base_info: "基本信息",
req_param: "請求參賽",
rsp_param: "響應內容",
delete_mock_expect: "確認刪除這條預期嗎?",
},
definition: {
api_title: "接口列表",