fix: 修复测试计划发送通知相关

This commit is contained in:
CaptainB 2021-10-29 11:17:08 +08:00 committed by 刘瑞斌
parent 8320b0beb3
commit 5dfe6085f0
7 changed files with 19 additions and 13 deletions

View File

@ -98,7 +98,7 @@ public class TestPlanController {
@PostMapping("/edit") @PostMapping("/edit")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_EDIT) @RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_EDIT)
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#testPlanDTO.id)", content = "#msClass.getLogDetails(#testPlanDTO.id)", msClass = TestPlanService.class) @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#testPlanDTO.id)", content = "#msClass.getLogDetails(#testPlanDTO.id)", msClass = TestPlanService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.UPDATE, mailTemplate = "track/TestPlanEnd", subject = "测试计划通知") @SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.UPDATE, mailTemplate = "track/TestPlanUpdate", subject = "测试计划通知")
public TestPlan editTestPlan(@RequestBody AddTestPlanRequest testPlanDTO) { public TestPlan editTestPlan(@RequestBody AddTestPlanRequest testPlanDTO) {
return testPlanService.editTestPlanWithRequest(testPlanDTO); return testPlanService.editTestPlanWithRequest(testPlanDTO);
} }

View File

@ -840,6 +840,7 @@ public class TestPlanReportService {
String event = ""; String event = "";
String successContext = "${operator}执行的 ${name} 测试计划运行成功, 报告: ${planShareUrl}"; String successContext = "${operator}执行的 ${name} 测试计划运行成功, 报告: ${planShareUrl}";
String failedContext = "${operator}执行的 ${name} 测试计划运行失败, 报告: ${planShareUrl}"; String failedContext = "${operator}执行的 ${name} 测试计划运行失败, 报告: ${planShareUrl}";
String context = "${operator}完成了测试计划: ${name}";
if (StringUtils.equals(testPlanReport.getTriggerMode(), ReportTriggerMode.API.name())) { if (StringUtils.equals(testPlanReport.getTriggerMode(), ReportTriggerMode.API.name())) {
subject = Translator.get("task_notification_jenkins"); subject = Translator.get("task_notification_jenkins");
} else { } else {
@ -874,10 +875,12 @@ public class TestPlanReportService {
NoticeModel noticeModel = NoticeModel.builder() NoticeModel noticeModel = NoticeModel.builder()
.operator(creator) .operator(creator)
.context(context)
.successContext(successContext) .successContext(successContext)
.successMailTemplate(successfulMailTemplate) .successMailTemplate(successfulMailTemplate)
.failedContext(failedContext) .failedContext(failedContext)
.failedMailTemplate(errfoMailTemplate) .failedMailTemplate(errfoMailTemplate)
.mailTemplate("track/TestPlanComplete")
.testId(testPlan.getId()) .testId(testPlan.getId())
.status(testPlanReport.getStatus()) .status(testPlanReport.getStatus())
.event(event) .event(event)

View File

@ -729,7 +729,7 @@ public class TestPlanService {
private void sendCompletedNotice(TestPlan testPlan) { private void sendCompletedNotice(TestPlan testPlan) {
if (StringUtils.equals(TestPlanStatus.Completed.name(), testPlan.getStatus())) { if (StringUtils.equals(TestPlanStatus.Completed.name(), testPlan.getStatus())) {
try { try {
String context = getTestPlanContext(testPlan, NoticeConstants.Event.UPDATE); String context = getTestPlanContext(testPlan, NoticeConstants.Event.COMPLETE);
Map paramMap = getTestPlanParamMap(testPlan); Map paramMap = getTestPlanParamMap(testPlan);
SessionUser user = SessionUtils.getUser(); SessionUser user = SessionUtils.getUser();
if (user != null) { if (user != null) {
@ -739,7 +739,7 @@ public class TestPlanService {
.operator(SessionUtils.getUserId()) .operator(SessionUtils.getUserId())
.context(context) .context(context)
.subject(Translator.get("test_plan_notification")) .subject(Translator.get("test_plan_notification"))
.mailTemplate("track/TestPlanEnd") .mailTemplate("track/TestPlanComplete")
.paramMap(paramMap) .paramMap(paramMap)
.event(NoticeConstants.Event.COMPLETE) .event(NoticeConstants.Event.COMPLETE)
.build(); .build();

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MeterSphere</title>
</head>
<body>
<div>
<p style="text-align: left">${operator}完成了测试计划: ${name}<br>
</div>
</body>
</html>

View File

@ -6,12 +6,7 @@
</head> </head>
<body> <body>
<div> <div>
<p style="text-align: left">${operator}创建的:<br> <p style="text-align: left">${operator}删除了测试计划: ${name} </p>
${name}<br>
计划开始时间是:${start}<br>
计划结束时间为:${end}<br>
已删除!
</p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -7,8 +7,6 @@
<body> <body>
<div> <div>
<p style="text-align: left">${operator}创建了测试计划${name}<br> <p style="text-align: left">${operator}创建了测试计划${name}<br>
点击下面链接进入测试计划页面</p>
<a href="${url}/#/track/plan/all">${url}/#/track/plan/all</a>
</div> </div>
</body> </body>
</html> </html>

View File

@ -7,8 +7,6 @@
<body> <body>
<div> <div>
<p style="text-align: left">${operator}更新了测试计划: ${name}<br> <p style="text-align: left">${operator}更新了测试计划: ${name}<br>
点击下面链接进入测试计划页面</p>
<a href="${url}/#/track/plan/view/${id}">${url}/#/track/plan/view</a>
</div> </div>
</body> </body>
</html> </html>