refactor: 发送消息通知使用非事务方式, 声明写在类上面

This commit is contained in:
Captain.B 2020-10-22 17:53:02 +08:00
parent badbe8eda0
commit ba0bc4dded
3 changed files with 11 additions and 8 deletions

View File

@ -19,12 +19,11 @@ import java.util.ArrayList;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public class DingTaskService {
@Resource
private UserService userService;
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void sendNailRobot(MessageDetail messageDetail, List<String> userIds, String context, String eventType) {
List<String> addresseeIdList = new ArrayList<>();
messageDetail.getEvents().forEach(e -> {

View File

@ -42,7 +42,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
@Service
@Transactional(rollbackFor = Exception.class)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public class MailService {
@Resource
private UserService userService;
@ -70,6 +70,7 @@ public class MailService {
}
}
public void sendApiNotification(ApiTestReport apiTestReport, List<NoticeDetail> noticeList) {
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
Map<String, String> context = new HashMap<>();
@ -128,6 +129,7 @@ public class MailService {
}
//测试评审
public void sendEndNotice(MessageDetail messageDetail, List<String> userIds, SaveTestCaseReviewRequest reviewRequest, String eventType) {
Map<String, String> context = getReviewContext(reviewRequest);
try {
@ -138,6 +140,7 @@ public class MailService {
}
}
public void sendDeleteNotice(MessageDetail messageDetail, List<String> userIds, SaveTestCaseReviewRequest reviewRequest, String eventType) {
Map<String, String> context = getReviewContext(reviewRequest);
try {
@ -148,6 +151,7 @@ public class MailService {
}
}
public void sendCommentNotice(MessageDetail messageDetail, List<String> userIds, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs, String eventType) {
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
Map<String, String> context = new HashMap<>();
@ -164,6 +168,7 @@ public class MailService {
}
}
public void sendReviewerNotice(MessageDetail messageDetail, List<String> userIds, SaveTestCaseReviewRequest reviewRequest, String eventType) {
Map<String, String> context = getReviewContext(reviewRequest);
try {
@ -175,7 +180,7 @@ public class MailService {
}
//测试计划
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void sendTestPlanStartNotice(MessageDetail messageDetail, List<String> userIds, AddTestPlanRequest testPlan, String eventType) {
Map<String, String> context = getTestPlanContext(testPlan);
context.put("creator", userIds.toString());
@ -187,7 +192,7 @@ public class MailService {
}
}
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void sendTestPlanEndNotice(MessageDetail messageDetail, List<String> userIds, AddTestPlanRequest testPlan, String eventType) {
Map<String, String> context = getTestPlanContext(testPlan);
context.put("creator", userIds.toString());
@ -199,7 +204,7 @@ public class MailService {
}
}
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void sendTestPlanDeleteNotice(MessageDetail messageDetail, List<String> userIds, AddTestPlanRequest testPlan, String eventType) {
Map<String, String> context = getTestPlanContext(testPlan);
context.put("creator", userIds.toString());

View File

@ -18,12 +18,11 @@ import java.util.ArrayList;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public class WxChatTaskService {
@Resource
private UserService userService;
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void sendWechatRobot(MessageDetail messageDetail, List<String> userIds, String context, String eventType) {
List<String> addresseeIdList = new ArrayList<>();
messageDetail.getEvents().forEach(e -> {