From 9b7de47b07004a32b7fcd44d08308905933936bb Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Mon, 22 May 2023 15:01:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E9=A2=84=E8=AD=A6=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更改性能测试脚本预警的方式 --- .../controller/PerformanceTestController.java | 4 +- .../service/PerformanceTestService.java | 48 +++++++++++-------- .../service/ProjectApplicationService.java | 9 +++- .../notice/components/NotificationData.vue | 23 ++++++--- .../project/menu/appmanage/AppManage.vue | 5 +- .../project/menu/appmanage/ReviewerConfig.vue | 10 +++- frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 1 + frontend/src/i18n/zh-TW.js | 1 + 9 files changed, 69 insertions(+), 33 deletions(-) diff --git a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java index c2d1854c64..2413763c04 100644 --- a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java +++ b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java @@ -98,7 +98,7 @@ public class PerformanceTestController { checkPermissionService.checkProjectOwner(request.getProjectId()); LoadTest loadTest = performanceTestService.save(request, files); //检查并发送审核脚本的通知 - performanceTestService.checkAndSendReviewMessage(new ArrayList<>(request.getUpdatedFileList()), files, request.getId(), request.getName(), request.getProjectId()); + performanceTestService.checkAndSendReviewMessage(new ArrayList<>(request.getUpdatedFileList()), files, loadTest); return loadTest; } @@ -120,7 +120,7 @@ public class PerformanceTestController { checkPermissionService.checkPerformanceTestOwner(request.getId()); LoadTest loadTest = performanceTestService.edit(request, files); //检查并发送审核脚本的通知 - performanceTestService.checkAndSendReviewMessage(new ArrayList<>(request.getUpdatedFileList()), files, request.getId(), request.getName(), request.getProjectId()); + performanceTestService.checkAndSendReviewMessage(new ArrayList<>(request.getUpdatedFileList()), files, loadTest); return loadTest; } diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index bcb8d8b765..7bfdb4088b 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -1173,28 +1173,38 @@ public class PerformanceTestService { return this.list(request2); } + private boolean checkLoadTest(LoadTest loadTest) { + return loadTest != null && StringUtils.isNoneBlank(loadTest.getId(), loadTest.getName(), loadTest.getProjectId(), loadTest.getCreateUser()); + } + //检查并发送脚本审核的通知 - public void checkAndSendReviewMessage(List fileMetadataList, List files, String loadTestId, String loadTestName, String projectId) { - ProjectApplication reviewLoadTestScript = projectApplicationService.getProjectApplication( - projectId, ProjectApplicationType.PERFORMANCE_REVIEW_LOAD_TEST_SCRIPT.name()); - if (BooleanUtils.toBoolean(reviewLoadTestScript.getTypeValue())) { - ProjectApplication loadTestScriptReviewerConfig = projectApplicationService.getProjectApplication( - projectId, ProjectApplicationType.PERFORMANCE_SCRIPT_REVIEWER.name()); - if (StringUtils.isNotEmpty(loadTestScriptReviewerConfig.getTypeValue()) && projectService.isProjectMember(projectId, loadTestScriptReviewerConfig.getTypeValue())) { + public void checkAndSendReviewMessage(List fileMetadataList, List files, LoadTest loadTest) { + if (checkLoadTest(loadTest)) { + String projectId = loadTest.getProjectId(); + ProjectApplication reviewLoadTestScript = projectApplicationService.getProjectApplication( + projectId, ProjectApplicationType.PERFORMANCE_REVIEW_LOAD_TEST_SCRIPT.name()); + if (BooleanUtils.toBoolean(reviewLoadTestScript.getTypeValue())) { boolean isSend = this.isSendScriptReviewMessage(fileMetadataList, files); if (isSend) { - Notification notification = new Notification(); - notification.setTitle("性能测试通知"); - notification.setOperator(SessionUtils.getUserId()); - notification.setOperation(NoticeConstants.Event.REVIEW); - notification.setResourceId(loadTestId); - notification.setResourceName(loadTestName); - notification.setResourceType(NoticeConstants.TaskType.PERFORMANCE_TEST_TASK); - notification.setType(NotificationConstants.Type.SYSTEM_NOTICE.name()); - notification.setStatus(NotificationConstants.Status.UNREAD.name()); - notification.setCreateTime(System.currentTimeMillis()); - notification.setReceiver(loadTestScriptReviewerConfig.getTypeValue()); - notificationService.sendAnnouncement(notification); + String sendUser = loadTest.getCreateUser(); + ProjectApplication loadTestScriptReviewerConfig = projectApplicationService.getProjectApplication(projectId, ProjectApplicationType.PERFORMANCE_SCRIPT_REVIEWER.name()); + if (StringUtils.isNotEmpty(loadTestScriptReviewerConfig.getTypeValue())) { + sendUser = loadTestScriptReviewerConfig.getTypeValue(); + } + if (projectService.isProjectMember(projectId, loadTestScriptReviewerConfig.getTypeValue())) { + Notification notification = new Notification(); + notification.setTitle("性能测试通知"); + notification.setOperator(SessionUtils.getUserId()); + notification.setOperation(NoticeConstants.Event.REVIEW); + notification.setResourceId(loadTest.getId()); + notification.setResourceName(loadTest.getName()); + notification.setResourceType(NoticeConstants.TaskType.PERFORMANCE_TEST_TASK); + notification.setType(NotificationConstants.Type.SYSTEM_NOTICE.name()); + notification.setStatus(NotificationConstants.Status.UNREAD.name()); + notification.setCreateTime(System.currentTimeMillis()); + notification.setReceiver(sendUser); + notificationService.sendAnnouncement(notification); + } } } } diff --git a/backend/src/main/java/io/metersphere/service/ProjectApplicationService.java b/backend/src/main/java/io/metersphere/service/ProjectApplicationService.java index 74aad90105..0090bbb23b 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectApplicationService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectApplicationService.java @@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSON; import com.google.common.base.CaseFormat; import io.metersphere.api.service.ApiTestEnvironmentService; import io.metersphere.api.tcp.TCPPool; -import io.metersphere.base.domain.*; +import io.metersphere.base.domain.Project; +import io.metersphere.base.domain.ProjectApplication; +import io.metersphere.base.domain.ProjectApplicationExample; import io.metersphere.base.mapper.ProjectApplicationMapper; import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.commons.constants.ProjectApplicationType; @@ -214,7 +216,10 @@ public class ProjectApplicationService { String projectId = conf.getProjectId(); String type = conf.getType(); String value = conf.getTypeValue(); - if (StringUtils.isBlank(projectId) || StringUtils.isBlank(type) || StringUtils.isEmpty(value)) { + + //性能测试审核人,允许value值为空 + if (!StringUtils.equals(type, ProjectApplicationType.PERFORMANCE_SCRIPT_REVIEWER.name()) + && (StringUtils.isBlank(projectId) || StringUtils.isBlank(type) || StringUtils.isEmpty(value))) { LogUtil.error("create or update project config error. project id or conf type or value is blank."); return; } diff --git a/frontend/src/business/components/notice/components/NotificationData.vue b/frontend/src/business/components/notice/components/NotificationData.vue index 090d8a9afa..c30160d74b 100644 --- a/frontend/src/business/components/notice/components/NotificationData.vue +++ b/frontend/src/business/components/notice/components/NotificationData.vue @@ -33,18 +33,24 @@ >
- {{ row.resourceName.substring(0, 1) }} + {{ $t("commons.system_notification_logo") }}
{{ getResource(row) }}: - - {{ row.resourceName }} - + + + {{ getShortResourceName(row.resourceName) }} + + {{ $t("project.config.contains_script_review") }} @@ -168,6 +174,9 @@ export default { let element = document.getElementById(id); element.parentNode.removeChild(element); }, + getShortResourceName(resourceName) { + return resourceName.length > 7 ? resourceName.substring(0, 7) + "..." : resourceName; + }, isReviewNotice(row) { return row.operation === "REVIEW"; }, diff --git a/frontend/src/business/components/project/menu/appmanage/AppManage.vue b/frontend/src/business/components/project/menu/appmanage/AppManage.vue index 5a6631a7aa..79d151a620 100644 --- a/frontend/src/business/components/project/menu/appmanage/AppManage.vue +++ b/frontend/src/business/components/project/menu/appmanage/AppManage.vue @@ -196,6 +196,7 @@ :reviewers="userInProject" :reviewer.sync="config.performanceScriptReviewer" :reviewerSwitch.sync="config.performanceReviewLoadTestScript" + :placeholder="$t('commons.creator')" @reviewerChange=" switchChange( 'PERFORMANCE_SCRIPT_REVIEWER', @@ -297,9 +298,11 @@ export default { created() { this.init(); this.getResourcePools(); - this.selectUserInProject(); this.isXpack = !!hasLicense(); }, + activated() { + this.selectUserInProject(); + }, computed: { projectId() { return getCurrentProjectID(); diff --git a/frontend/src/business/components/project/menu/appmanage/ReviewerConfig.vue b/frontend/src/business/components/project/menu/appmanage/ReviewerConfig.vue index d69371bcb9..a0a423c168 100644 --- a/frontend/src/business/components/project/menu/appmanage/ReviewerConfig.vue +++ b/frontend/src/business/components/project/menu/appmanage/ReviewerConfig.vue @@ -23,12 +23,13 @@ {{ $t("commons.reviewers") }}