From 1f6c3891a300846ddb24d5c065aa83bc50db8ce4 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Mon, 19 Apr 2021 18:22:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DMock=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=E3=80=81=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=E9=A6=96=E9=A1=B5tips?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复Mock设置中删除期望未二次确认的问题、修改tips由天冷了该为天热了、增加或修改期望时增加名称唯一性验证 --- .../service/ApiTestEnvironmentService.java | 2 +- .../api/service/MockConfigService.java | 13 ++++++++ .../main/resources/i18n/messages.properties | 1 + .../resources/i18n/messages_en_US.properties | 2 +- .../resources/i18n/messages_zh_CN.properties | 2 +- .../resources/i18n/messages_zh_TW.properties | 2 +- .../definition/components/mock/MockConfig.vue | 32 ++++++++++++++----- .../api/homepage/ApiTestHomePage.vue | 10 +++--- frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 1 + frontend/src/i18n/zh-TW.js | 1 + 11 files changed, 50 insertions(+), 17 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java index 166629a5ea..2eb1858d77 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java @@ -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); diff --git a/backend/src/main/java/io/metersphere/api/service/MockConfigService.java b/backend/src/main/java/io/metersphere/api/service/MockConfigService.java index f718a88d35..4febbe4bcf 100644 --- a/backend/src/main/java/io/metersphere/api/service/MockConfigService.java +++ b/backend/src/main/java/io/metersphere/api/service/MockConfigService.java @@ -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 mockExpectConfigList, Map paramMap) { MockExpectConfigResponse returnModel = null; diff --git a/backend/src/main/resources/i18n/messages.properties b/backend/src/main/resources/i18n/messages.properties index 7d43e364f4..074844edf0 100644 --- a/backend/src/main/resources/i18n/messages.properties +++ b/backend/src/main/resources/i18n/messages.properties @@ -65,3 +65,4 @@ please_input_workspace_member= test_case_report_template_repeat= custom_field_already= template_already= +expect_name_exists= diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 0238fe2087..2667874686 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -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 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 46497a03ee..89f35d4e0a 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -215,4 +215,4 @@ authsource_name_is_null=认证源名称不能为空 authsource_configuration_is_null=认证源配置不能为空 custom_field_already=工作空间下已存在该字段: template_already=工作空间下已存在该模板: - +expect_name_exists=预期名称已存在 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index acb88e7b97..bff20e3cc5 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -216,4 +216,4 @@ authsource_name_is_null=認證源名稱不能為空 authsource_configuration_is_null=認證源配置不能為空 custom_field_already=工作空間下已存在該字段: template_already=工作空間下已存在該模板: - +expect_name_exists=預期名稱已存在 \ No newline at end of file diff --git a/frontend/src/business/components/api/definition/components/mock/MockConfig.vue b/frontend/src/business/components/api/definition/components/mock/MockConfig.vue index e191021a09..e38edaa8c7 100644 --- a/frontend/src/business/components/api/definition/components/mock/MockConfig.vue +++ b/frontend/src/business/components/api/definition/components/mock/MockConfig.vue @@ -3,7 +3,7 @@

期望列表

- + @@ -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) { diff --git a/frontend/src/business/components/api/homepage/ApiTestHomePage.vue b/frontend/src/business/components/api/homepage/ApiTestHomePage.vue index b0905e1098..fd7aa7897f 100644 --- a/frontend/src/business/components/api/homepage/ApiTestHomePage.vue +++ b/frontend/src/business/components/api/homepage/ApiTestHomePage.vue @@ -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(); diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 5f5470cfb4..438dfd8bd3 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -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", diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index f95e58ed44..9ca6a601ad 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -619,6 +619,7 @@ export default { base_info: "基本信息", req_param: "请求参数", rsp_param: "响应内容", + delete_mock_expect: "确认删除这条预期吗?", }, definition: { api_title: "接口列表", diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 940c50f33e..83ec96245b 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -609,6 +609,7 @@ export default { base_info: "基本信息", req_param: "請求參賽", rsp_param: "響應內容", + delete_mock_expect: "確認刪除這條預期嗎?", }, definition: { api_title: "接口列表",