fix(测试计划): 修复测试计划删除关注人收不到消息通知问题

--bug=1040946 --user=王旭 【项目管理】消息设置-测试计划-删除测试计划和更新测试计划,通知接受人为创建人或关注人收不到通知 https://www.tapd.cn/55049933/s/1532107
This commit is contained in:
WangXu10 2024-06-19 17:50:40 +08:00 committed by Craftsman
parent ff91f4b77d
commit bfdff00cce
3 changed files with 22 additions and 5 deletions

View File

@ -155,8 +155,15 @@ public abstract class AbstractNoticeSender implements NoticeSender {
} }
case NoticeConstants.RelatedUser.FOLLOW_PEOPLE -> { case NoticeConstants.RelatedUser.FOLLOW_PEOPLE -> {
try { try {
List<Receiver> follows = handleFollows(messageDetail, noticeModel); List<String> followUser = (List) paramMap.get("followUsers");
toUsers.addAll(follows); if (CollectionUtils.isNotEmpty(followUser)) {
followUser.forEach(item ->{
toUsers.add(new Receiver(item, NotificationConstants.Type.SYSTEM_NOTICE.name()));
});
} else {
List<Receiver> follows = handleFollows(messageDetail, noticeModel);
toUsers.addAll(follows);
}
} catch (Exception e) { } catch (Exception e) {
LogUtils.error("查询关注人失败:{}", e); LogUtils.error("查询关注人失败:{}", e);
} }

View File

@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
/** /**
* @author wx * @author wx
@ -55,4 +57,6 @@ public class TestPlanDTO {
@Schema(description = "message.domain.test_plan_description") @Schema(description = "message.domain.test_plan_description")
private String description; private String description;
private List<String> followUsers;
} }

View File

@ -2,13 +2,12 @@ package io.metersphere.plan.service;
import io.metersphere.functional.domain.FunctionalCase; import io.metersphere.functional.domain.FunctionalCase;
import io.metersphere.functional.mapper.FunctionalCaseMapper; import io.metersphere.functional.mapper.FunctionalCaseMapper;
import io.metersphere.plan.domain.TestPlan; import io.metersphere.plan.domain.*;
import io.metersphere.plan.domain.TestPlanConfig;
import io.metersphere.plan.domain.TestPlanExample;
import io.metersphere.plan.dto.TestPlanDTO; import io.metersphere.plan.dto.TestPlanDTO;
import io.metersphere.plan.dto.request.TestPlanCreateRequest; import io.metersphere.plan.dto.request.TestPlanCreateRequest;
import io.metersphere.plan.dto.request.TestPlanUpdateRequest; import io.metersphere.plan.dto.request.TestPlanUpdateRequest;
import io.metersphere.plan.mapper.TestPlanConfigMapper; import io.metersphere.plan.mapper.TestPlanConfigMapper;
import io.metersphere.plan.mapper.TestPlanFollowerMapper;
import io.metersphere.plan.mapper.TestPlanMapper; import io.metersphere.plan.mapper.TestPlanMapper;
import io.metersphere.sdk.constants.ReportStatus; import io.metersphere.sdk.constants.ReportStatus;
import io.metersphere.sdk.constants.TestPlanConstants; import io.metersphere.sdk.constants.TestPlanConstants;
@ -49,6 +48,8 @@ public class TestPlanSendNoticeService {
private CommonNoticeSendService commonNoticeSendService; private CommonNoticeSendService commonNoticeSendService;
@Resource @Resource
private TestPlanConfigMapper testPlanConfigMapper; private TestPlanConfigMapper testPlanConfigMapper;
@Resource
private TestPlanFollowerMapper testPlanFollowerMapper;
public void sendNoticeCase(List<String> relatedUsers, String userId, String caseId, String task, String event, String testPlanId) { public void sendNoticeCase(List<String> relatedUsers, String userId, String caseId, String task, String event, String testPlanId) {
FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(caseId); FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(caseId);
@ -155,10 +156,15 @@ public class TestPlanSendNoticeService {
public TestPlanDTO sendDeleteNotice(String id) { public TestPlanDTO sendDeleteNotice(String id) {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(id); TestPlan testPlan = testPlanMapper.selectByPrimaryKey(id);
TestPlanConfig testPlanConfig = testPlanConfigMapper.selectByPrimaryKey(id); TestPlanConfig testPlanConfig = testPlanConfigMapper.selectByPrimaryKey(id);
TestPlanFollowerExample example = new TestPlanFollowerExample();
example.createCriteria().andTestPlanIdEqualTo(id);
List<TestPlanFollower> testPlanFollowers = testPlanFollowerMapper.selectByExample(example);
List<String> followUsers = testPlanFollowers.stream().map(TestPlanFollower::getUserId).toList();
TestPlanDTO dto = new TestPlanDTO(); TestPlanDTO dto = new TestPlanDTO();
if (testPlan != null) { if (testPlan != null) {
BeanUtils.copyBean(dto, testPlan); BeanUtils.copyBean(dto, testPlan);
BeanUtils.copyBean(dto, testPlanConfig); BeanUtils.copyBean(dto, testPlanConfig);
dto.setFollowUsers(followUsers);
return dto; return dto;
} }
return null; return null;