From 316617d04ae62f0f653be262b626932695219bff Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 18 Sep 2020 10:55:36 +0800 Subject: [PATCH 01/12] =?UTF-8?q?refactor(=E6=80=A7=E8=83=BD=E6=B5=8B?= =?UTF-8?q?=E8=AF=95):=20=E4=BF=AE=E6=94=B9Kafka=20acks=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/io/metersphere/config/KafkaProperties.java | 2 +- backend/src/main/resources/application.properties | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/config/KafkaProperties.java b/backend/src/main/java/io/metersphere/config/KafkaProperties.java index 912352b24b..59c24022af 100644 --- a/backend/src/main/java/io/metersphere/config/KafkaProperties.java +++ b/backend/src/main/java/io/metersphere/config/KafkaProperties.java @@ -10,7 +10,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; public class KafkaProperties { public static final String KAFKA_PREFIX = "kafka"; - private String acks; + private String acks = "all"; private String topic; private String fields; private String timestamp; diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index a3a405615e..5a57cf4026 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -40,7 +40,6 @@ spring.flyway.validate-on-migrate=false spring.messages.basename=i18n/messages # kafka -kafka.acks=1 kafka.fields= kafka.timestamp=yyyy-MM-dd'T'HH:mm:ss.SSSZZ kafka.sample-filter= From 7a6151ab794403e66e65cab61db63bb79a0dabdb Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Fri, 18 Sep 2020 11:09:37 +0800 Subject: [PATCH 02/12] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?):=20=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=80=E5=B1=9E=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/controller/TestPlanController.java | 4 +- .../io/metersphere/track/dto/TestPlanDTO.java | 3 ++ .../track/service/TestPlanService.java | 42 ++++++++++++++++++- .../track/case/components/SwitchProject.vue | 2 +- .../track/plan/components/TestPlanEdit.vue | 31 ++++++++++---- .../review/components/TestCaseReviewEdit.vue | 6 ++- 6 files changed, 74 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java index 6fbea3d40d..7f9135fcb9 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java @@ -81,8 +81,8 @@ public class TestPlanController { @PostMapping("/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) - public void editTestPlan(@RequestBody TestPlan testPlan) { - testPlanService.editTestPlan(testPlan); + public void editTestPlan(@RequestBody TestPlanDTO testPlanDTO) { + testPlanService.editTestPlan(testPlanDTO); } @PostMapping("/edit/status/{planId}") diff --git a/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java b/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java index 232c77ada0..a9b9fb545f 100644 --- a/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java +++ b/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java @@ -4,8 +4,11 @@ import io.metersphere.base.domain.TestPlan; import lombok.Getter; import lombok.Setter; +import java.util.List; + @Getter @Setter public class TestPlanDTO extends TestPlan { private String projectName; + private List projectIds; } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index bdd198c510..7f95cd805d 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -34,6 +34,7 @@ import org.apache.ibatis.session.SqlSessionFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.*; @@ -110,12 +111,51 @@ public class TestPlanService { return Optional.ofNullable(testPlanMapper.selectByPrimaryKey(testPlanId)).orElse(new TestPlan()); } - public int editTestPlan(TestPlan testPlan) { + public int editTestPlan(TestPlanDTO testPlan) { + editTestPlanProject(testPlan); testPlan.setUpdateTime(System.currentTimeMillis()); checkTestPlanExist(testPlan); return testPlanMapper.updateByPrimaryKeySelective(testPlan); } + private void editTestPlanProject(TestPlanDTO testPlan) { + List projectIds = testPlan.getProjectIds(); + if (!CollectionUtils.isEmpty(projectIds)) { + TestPlanProjectExample testPlanProjectExample1 = new TestPlanProjectExample(); + testPlanProjectExample1.createCriteria().andTestPlanIdEqualTo(testPlan.getId()); + List testPlanProjects = testPlanProjectMapper.selectByExample(testPlanProjectExample1); + // 已经关联的项目idList + List dbProjectIds = testPlanProjects.stream().map(TestPlanProject::getProjectId).collect(Collectors.toList()); + // 修改后传过来的项目idList,如果还未关联,进行关联 + projectIds.forEach(projectId -> { + if (!dbProjectIds.contains(projectId)) { + TestPlanProject testPlanProject = new TestPlanProject(); + testPlanProject.setTestPlanId(testPlan.getId()); + testPlanProject.setProjectId(projectId); + testPlanProjectMapper.insert(testPlanProject); + } + }); + + TestPlanProjectExample testPlanProjectExample = new TestPlanProjectExample(); + testPlanProjectExample.createCriteria().andTestPlanIdEqualTo(testPlan.getId()).andProjectIdNotIn(projectIds); + testPlanProjectMapper.deleteByExample(testPlanProjectExample); + + // 关联的项目下的用例idList + TestCaseExample example = new TestCaseExample(); + example.createCriteria().andProjectIdIn(projectIds); + List caseList = testCaseMapper.selectByExample(example); + List caseIds = caseList.stream().map(TestCase::getId).collect(Collectors.toList()); + + // 取消关联所属项目下的用例和计划的关系 + TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample(); + TestPlanTestCaseExample.Criteria criteria = testPlanTestCaseExample.createCriteria().andPlanIdEqualTo(testPlan.getId()); + if (!CollectionUtils.isEmpty(caseIds)) { + criteria.andCaseIdNotIn(caseIds); + } + testPlanTestCaseMapper.deleteByExample(testPlanTestCaseExample); + } + } + private void checkTestPlanExist(TestPlan testPlan) { if (testPlan.getName() != null) { TestPlanExample example = new TestPlanExample(); diff --git a/frontend/src/business/components/track/case/components/SwitchProject.vue b/frontend/src/business/components/track/case/components/SwitchProject.vue index 57b9335340..035d52312e 100644 --- a/frontend/src/business/components/track/case/components/SwitchProject.vue +++ b/frontend/src/business/components/track/case/components/SwitchProject.vue @@ -4,7 +4,7 @@ :close-on-click-modal="false" class="ms-switch-project" > - + { - this.$success(this.$t('commons.save_success')); - this.dialogFormVisible = false; - this.$emit("refresh"); - // 发送广播,刷新 head 上的最新列表 - TrackEvent.$emit(LIST_CHANGE); - }); + + if (this.operationType === 'edit') { + this.$confirm('取消项目关联会同时取消该项目下已关联的测试用例', '提示', { + confirmButtonText: this.$t('commons.confirm'), + cancelButtonText: this.$t('commons.cancel'), + type: 'warning' + }).then(() => { + this.editTestPlan(param); + }).catch(() => { + this.$info(this.$t('commons.cancel')) + }); + } else { + this.editTestPlan(param); + } } else { return false; } }); }, + editTestPlan(param) { + this.$post('/test/plan/' + this.operationType, param, () => { + this.$success(this.$t('commons.save_success')); + this.dialogFormVisible = false; + this.$emit("refresh"); + // 发送广播,刷新 head 上的最新列表 + TrackEvent.$emit(LIST_CHANGE); + }); + }, getProjects() { this.$get("/project/listAll", (response) => { if (response.success) { diff --git a/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue b/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue index 7dfc0298b8..aaeea31402 100644 --- a/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue +++ b/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue @@ -6,6 +6,7 @@ :title="operationType === 'edit' ? '编辑用例评审' : '创建用例评审'" :visible.sync="dialogFormVisible" @close="close" + v-loading="result.loading" width="65%"> @@ -122,6 +123,7 @@ export default { data() { return { dialogFormVisible: false, + result: {}, form: { name: '', projectIds: [], @@ -187,7 +189,7 @@ export default { }); }, getProjects() { - this.$get("/project/listAll", (response) => { + this.result = this.$get("/project/listAll", (response) => { if (response.success) { this.projects = response.data; } else { @@ -197,7 +199,7 @@ export default { }, setReviewerOptions() { let workspaceId = localStorage.getItem(WORKSPACE_ID); - this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => { + this.result = this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => { this.reviewerOptions = response.data; }); }, From 56db0e077bb1e3f15e94f197cc6afb3af1b41a73 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 18 Sep 2020 11:14:44 +0800 Subject: [PATCH 03/12] =?UTF-8?q?refactor(XPack):=20license=E5=A2=9E?= =?UTF-8?q?=E5=BC=BA=E6=A0=A1=E9=AA=8C=EF=BC=8C=E5=B9=B6=E5=AF=B9=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=97=B6=E9=97=B4=E8=BF=9B=E8=A1=8C=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xmind/XmindToTestCaseParser.java | 2 +- frontend/src/business/App.vue | 36 +++++++++++++ .../components/settings/SettingMenu.vue | 53 ++++++++++--------- frontend/src/common/js/constants.js | 1 + frontend/src/common/js/utils.js | 16 ++++-- 5 files changed, 77 insertions(+), 31 deletions(-) diff --git a/backend/src/main/java/io/metersphere/xmind/XmindToTestCaseParser.java b/backend/src/main/java/io/metersphere/xmind/XmindToTestCaseParser.java index 135fe835f0..699948c904 100644 --- a/backend/src/main/java/io/metersphere/xmind/XmindToTestCaseParser.java +++ b/backend/src/main/java/io/metersphere/xmind/XmindToTestCaseParser.java @@ -55,7 +55,7 @@ public class XmindToTestCaseParser { // 递归处理案例数据 private void makeXmind(StringBuffer processBuffer, Attached parent, int level, String nodePath, List attacheds) { for (Attached item : attacheds) { - if (isBlack(item.getTitle(), "(?:tc|tc)")) { // 用例 + if (isBlack(item.getTitle(), "(?:tc:|tc:|tc)")) { // 用例 item.setParent(parent); this.newTestCase(item.getTitle(), parent.getPath(), item.getChildren() != null ? item.getChildren().getAttached() : null); } else { diff --git a/frontend/src/business/App.vue b/frontend/src/business/App.vue index 6f75a42fa0..1fb604f01a 100644 --- a/frontend/src/business/App.vue +++ b/frontend/src/business/App.vue @@ -1,5 +1,13 @@ From 1786fb23ec6a3e396ebd6f9cd25978c68c813f14 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 18 Sep 2020 15:12:10 +0800 Subject: [PATCH 12/12] =?UTF-8?q?fix(XPack):=20=E5=90=88=E5=B9=B6=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=E7=9A=84I18n=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/resources/i18n/messages_en_US.properties | 3 ++- backend/src/main/resources/i18n/messages_zh_CN.properties | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index a9be69b2aa..145e7904ab 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -154,4 +154,5 @@ quota_duration_excess_organization=The stress test duration exceeds the organiza email_subject=Metersphere timing task result notification import_xmind_count_error=The number of use cases imported into the mind map cannot exceed 500 -import_xmind_not_found=Test case not found \ No newline at end of file +import_xmind_not_found=Test case not found +license_valid_license_error=Authorization authentication failed diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 87ed767fb7..7836a2ba48 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -153,6 +153,7 @@ quota_duration_excess_workspace=压测时长超过工作空间限额 quota_duration_excess_organization=压测时长超过组织限额 email_subject=MeterSphere定时任务结果通知 import_xmind_count_error=思维导图导入用例数量不能超过 500 条 +license_valid_license_error=授权认证失败 import_xmind_not_found=未找到测试用例