From 64234791286d1545f7b017ff87881339bdb637a7 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 21 Jun 2024 15:55:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=97=B6=E5=88=9B=E5=BB=BA=E4=BA=BA=E5=92=8C=E5=85=B3?= =?UTF-8?q?=E6=B3=A8=E4=BA=BA=E6=94=B6=E4=B8=8D=E5=88=B0=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../functional/dto/FunctionalCaseDTO.java | 3 ++ .../service/FunctionalCaseNoticeService.java | 29 +++++++++++++------ .../impl/DingEnterPriseNoticeSender.java | 8 +++++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDTO.java index 2ebbb28f1d..1528d4856f 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDTO.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDTO.java @@ -25,4 +25,7 @@ public class FunctionalCaseDTO extends FunctionalCaseMessageDTO { @Schema(description = "触发方式:功能用例执行相关(测试计划/定时任务/用例评审)") private String triggerMode; + @Schema(description = "message.follow_people") + private List followUsers; + } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseNoticeService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseNoticeService.java index b60b7ac78f..05905c05ef 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseNoticeService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseNoticeService.java @@ -3,17 +3,11 @@ package io.metersphere.functional.service; import io.metersphere.functional.domain.*; import io.metersphere.functional.dto.CaseCustomFieldDTO; import io.metersphere.functional.dto.FunctionalCaseDTO; -import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper; -import io.metersphere.functional.mapper.CaseReviewMapper; -import io.metersphere.functional.mapper.FunctionalCaseCustomFieldMapper; -import io.metersphere.functional.mapper.FunctionalCaseMapper; +import io.metersphere.functional.mapper.*; import io.metersphere.functional.request.FunctionalCaseAddRequest; import io.metersphere.functional.request.FunctionalCaseCommentRequest; import io.metersphere.functional.request.FunctionalCaseEditRequest; -import io.metersphere.plan.domain.TestPlan; -import io.metersphere.plan.domain.TestPlanExample; -import io.metersphere.plan.domain.TestPlanFunctionalCase; -import io.metersphere.plan.domain.TestPlanFunctionalCaseExample; +import io.metersphere.plan.domain.*; import io.metersphere.plan.mapper.TestPlanFunctionalCaseMapper; import io.metersphere.plan.mapper.TestPlanMapper; import io.metersphere.sdk.util.BeanUtils; @@ -43,6 +37,9 @@ public class FunctionalCaseNoticeService { @Resource private FunctionalCaseMapper functionalCaseMapper; + @Resource + private FunctionalCaseFollowerMapper functionalCaseFollowerMapper; + @Resource private FunctionalCaseCustomFieldMapper functionalCaseCustomFieldMapper; @@ -264,6 +261,15 @@ public class FunctionalCaseNoticeService { Map> casePlanMap = testPlanFunctionalCases.stream().collect(Collectors.groupingBy(TestPlanFunctionalCase::getFunctionalCaseId)); Map finalReviewMap = reviewMap; Map finalPlanMap = planMap; + + FunctionalCaseFollowerExample example = new FunctionalCaseFollowerExample(); + example.createCriteria().andCaseIdIn(ids); + List functionalCaseFollowers = functionalCaseFollowerMapper.selectByExample(example); + Map> followMap = new HashMap<>(); + if (CollectionUtils.isNotEmpty(functionalCaseFollowers)) { + followMap = functionalCaseFollowers.stream().collect(Collectors.groupingBy(FunctionalCaseFollower::getCaseId)); + } + Map> finalFollowMap = followMap; ids.forEach(id -> { FunctionalCase functionalCase = functionalCaseMap.get(id); if (functionalCase != null) { @@ -276,8 +282,13 @@ public class FunctionalCaseNoticeService { functionalCaseDTO.setName(functionalCase.getName()); functionalCaseDTO.setProjectId(functionalCase.getProjectId()); functionalCaseDTO.setCaseEditType(functionalCase.getCaseEditType()); - functionalCaseDTO.setCreateUser(null); + functionalCaseDTO.setCreateUser(StringUtils.isBlank(functionalCase.getCreateUser()) ? null : functionalCase.getCreateUser()); functionalCaseDTO.setFields(optionDTOS.get()); + List caseFollowers = finalFollowMap.get(id); + if (CollectionUtils.isNotEmpty(caseFollowers)) { + List followUsers = caseFollowers.stream().map(FunctionalCaseFollower::getUserId).toList(); + functionalCaseDTO.setFollowUsers(followUsers); + } List caseReviewFunctionalCases1 = caseReviewMap.get(id); List reviewName = new ArrayList<>(); if (CollectionUtils.isNotEmpty(caseReviewFunctionalCases1)) { diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/impl/DingEnterPriseNoticeSender.java b/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/impl/DingEnterPriseNoticeSender.java index 09d63cbbe7..192fd3c642 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/impl/DingEnterPriseNoticeSender.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/impl/DingEnterPriseNoticeSender.java @@ -10,10 +10,14 @@ import com.aliyun.teautil.Common; import com.aliyun.teautil.models.RuntimeOptions; import io.metersphere.system.notice.MessageDetail; import io.metersphere.system.notice.NoticeModel; +import io.metersphere.system.notice.Receiver; import io.metersphere.system.notice.sender.AbstractNoticeSender; import io.metersphere.sdk.util.LogUtils; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Component; +import java.util.List; + @Component public class DingEnterPriseNoticeSender extends AbstractNoticeSender { @@ -90,6 +94,10 @@ public class DingEnterPriseNoticeSender extends AbstractNoticeSender { @Override public void send(MessageDetail messageDetail, NoticeModel noticeModel) { + List receivers = super.getReceivers(noticeModel.getReceivers(), noticeModel.isExcludeSelf(), noticeModel.getOperator()); + if (CollectionUtils.isEmpty(receivers)) { + return; + } String context = super.getContext(messageDetail, noticeModel); try { sendDing(messageDetail, context);