fix(功能用例): 修复功能用例删除时创建人和关注人收不到消息的问题

This commit is contained in:
guoyuqi 2024-06-21 15:55:46 +08:00 committed by Craftsman
parent d2c2096da8
commit 6423479128
3 changed files with 31 additions and 9 deletions

View File

@ -25,4 +25,7 @@ public class FunctionalCaseDTO extends FunctionalCaseMessageDTO {
@Schema(description = "触发方式:功能用例执行相关(测试计划/定时任务/用例评审)")
private String triggerMode;
@Schema(description = "message.follow_people")
private List<String> followUsers;
}

View File

@ -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<String, List<TestPlanFunctionalCase>> casePlanMap = testPlanFunctionalCases.stream().collect(Collectors.groupingBy(TestPlanFunctionalCase::getFunctionalCaseId));
Map<String, String> finalReviewMap = reviewMap;
Map<String, String> finalPlanMap = planMap;
FunctionalCaseFollowerExample example = new FunctionalCaseFollowerExample();
example.createCriteria().andCaseIdIn(ids);
List<FunctionalCaseFollower> functionalCaseFollowers = functionalCaseFollowerMapper.selectByExample(example);
Map<String, List<FunctionalCaseFollower>> followMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(functionalCaseFollowers)) {
followMap = functionalCaseFollowers.stream().collect(Collectors.groupingBy(FunctionalCaseFollower::getCaseId));
}
Map<String, List<FunctionalCaseFollower>> 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<FunctionalCaseFollower> caseFollowers = finalFollowMap.get(id);
if (CollectionUtils.isNotEmpty(caseFollowers)) {
List<String> followUsers = caseFollowers.stream().map(FunctionalCaseFollower::getUserId).toList();
functionalCaseDTO.setFollowUsers(followUsers);
}
List<CaseReviewFunctionalCase> caseReviewFunctionalCases1 = caseReviewMap.get(id);
List<String> reviewName = new ArrayList<>();
if (CollectionUtils.isNotEmpty(caseReviewFunctionalCases1)) {

View File

@ -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<Receiver> receivers = super.getReceivers(noticeModel.getReceivers(), noticeModel.isExcludeSelf(), noticeModel.getOperator());
if (CollectionUtils.isEmpty(receivers)) {
return;
}
String context = super.getContext(messageDetail, noticeModel);
try {
sendDing(messageDetail, context);