feat: 测试评审任务添加评论和完成通知
This commit is contained in:
parent
d370a5bb7b
commit
f73a81da66
|
@ -3,12 +3,14 @@ package io.metersphere.notice.service;
|
|||
import io.metersphere.api.dto.APIReportResult;
|
||||
import io.metersphere.base.domain.Notice;
|
||||
import io.metersphere.base.domain.SystemParameter;
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import io.metersphere.commons.constants.ParamConstants;
|
||||
import io.metersphere.commons.utils.EncryptUtils;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.dto.LoadTestDTO;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.track.request.testreview.SaveCommentRequest;
|
||||
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
||||
import org.springframework.mail.MailException;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
|
@ -138,12 +140,20 @@ public class MailService {
|
|||
}
|
||||
|
||||
|
||||
public void sendHtml(List<String> userIds, String type, SaveTestCaseReviewRequest reviewRequest) {
|
||||
public void sendHtml(List<String> userIds, String type, SaveTestCaseReviewRequest reviewRequest, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs) {
|
||||
Long startTime = reviewRequest.getCreateTime();
|
||||
Long endTime = reviewRequest.getEndTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String start = sdf.format(new Date(Long.parseLong(String.valueOf(startTime))));
|
||||
String end = sdf.format(new Date(Long.parseLong(String.valueOf(endTime))));
|
||||
String start = null;
|
||||
String sTime = String.valueOf(startTime);
|
||||
String eTime = String.valueOf(endTime);
|
||||
if (!sTime.equals("null")) {
|
||||
start = sdf.format(new Date(Long.parseLong(sTime)));
|
||||
}
|
||||
String end = null;
|
||||
if (!eTime.equals("null")) {
|
||||
end = sdf.format(new Date(Long.parseLong(eTime)));
|
||||
}
|
||||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
|
||||
List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue());
|
||||
javaMailSender.setDefaultEncoding("UTF-8");
|
||||
|
@ -182,8 +192,31 @@ public class MailService {
|
|||
" </div>\n" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
String html2 = "";
|
||||
String html3 = "";
|
||||
String html2 = "<!DOCTYPE html>\n" +
|
||||
"<html lang=\"en\">\n" +
|
||||
"<head>\n" +
|
||||
" <meta charset=\"UTF-8\">\n" +
|
||||
" <title>MeterSphere</title>\n" +
|
||||
"</head>\n" +
|
||||
"<body style=\"text-align: left\">\n" +
|
||||
" <div>\n" +
|
||||
" <p>" + testCaseWithBLOBs.getMaintainer() + "发起的" + testCaseWithBLOBs.getName() + "添加评论:" + request.getDescription() + "</p>\n" +
|
||||
" </div>\n" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
String html3 = "<!DOCTYPE html>\n" +
|
||||
"<html lang=\"en\">\n" +
|
||||
"<head>\n" +
|
||||
" <meta charset=\"UTF-8\">\n" +
|
||||
" <title>MeterSphere</title>\n" +
|
||||
"</head>\n" +
|
||||
"<body style=\"text-align: left\">\n" +
|
||||
" <div>\n" +
|
||||
" <p>" + reviewRequest.getCreator() + "发起的" + reviewRequest.getName() + "的计划开始时间是" + start + ",计划结束时间为" + end + "已完成" + "</p>\n" +
|
||||
" </div>\n" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
;
|
||||
try {
|
||||
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
||||
helper.setFrom(javaMailSender.getUsername());
|
||||
|
@ -198,6 +231,10 @@ public class MailService {
|
|||
users = emails.toArray(new String[emails.size()]);
|
||||
if (type.equals("reviewer")) {
|
||||
helper.setText(html1, true);
|
||||
} else if (type.equals("comment")) {
|
||||
helper.setText(html2, true);
|
||||
} else if (type.equals("end")) {
|
||||
helper.setText(html3, true);
|
||||
}
|
||||
helper.setTo(users);
|
||||
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
package io.metersphere.track.service;
|
||||
|
||||
import io.metersphere.base.domain.TestCaseComment;
|
||||
import io.metersphere.base.domain.TestCaseCommentExample;
|
||||
import io.metersphere.base.domain.User;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.TestCaseCommentMapper;
|
||||
import io.metersphere.base.mapper.TestCaseMapper;
|
||||
import io.metersphere.base.mapper.TestCaseReviewMapper;
|
||||
import io.metersphere.base.mapper.UserMapper;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.notice.service.MailService;
|
||||
import io.metersphere.track.request.testreview.SaveCommentRequest;
|
||||
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -21,7 +26,13 @@ public class TestCaseCommentService {
|
|||
@Resource
|
||||
TestCaseCommentMapper testCaseCommentMapper;
|
||||
@Resource
|
||||
private TestCaseReviewMapper testCaseReviewMapper;
|
||||
@Resource
|
||||
UserMapper userMapper;
|
||||
@Resource
|
||||
MailService mailService;
|
||||
@Resource
|
||||
TestCaseMapper testCaseMapper;
|
||||
|
||||
public void saveComment(SaveCommentRequest request) {
|
||||
TestCaseComment testCaseComment = new TestCaseComment();
|
||||
|
@ -32,6 +43,13 @@ public class TestCaseCommentService {
|
|||
testCaseComment.setUpdateTime(System.currentTimeMillis());
|
||||
testCaseComment.setDescription(request.getDescription());
|
||||
testCaseCommentMapper.insert(testCaseComment);
|
||||
TestCaseWithBLOBs testCaseWithBLOBs;
|
||||
testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(request.getCaseId());
|
||||
SaveTestCaseReviewRequest caseReviewRequest = new SaveTestCaseReviewRequest();
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(testCaseComment.getAuthor());
|
||||
mailService.sendHtml(userIds, "comment", caseReviewRequest, request, testCaseWithBLOBs);
|
||||
|
||||
}
|
||||
|
||||
public List<TestCaseComment> getComments(String caseId) {
|
||||
|
|
|
@ -17,10 +17,8 @@ import io.metersphere.controller.request.member.QueryMemberRequest;
|
|||
import io.metersphere.notice.service.MailService;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.track.dto.*;
|
||||
import io.metersphere.track.request.testreview.QueryTestReviewRequest;
|
||||
import io.metersphere.track.request.testreview.ReviewRelevanceRequest;
|
||||
import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
|
||||
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
||||
import io.metersphere.track.request.testreview.*;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
|
@ -30,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -64,6 +63,7 @@ public class TestCaseReviewService {
|
|||
@Resource
|
||||
MailService mailService;
|
||||
|
||||
|
||||
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
|
||||
checkCaseReviewExist(reviewRequest);
|
||||
|
||||
|
@ -91,7 +91,9 @@ public class TestCaseReviewService {
|
|||
reviewRequest.setCreator(SessionUtils.getUser().getId());
|
||||
reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name());
|
||||
testCaseReviewMapper.insert(reviewRequest);
|
||||
mailService.sendHtml(userIds, "reviewer", reviewRequest);
|
||||
SaveCommentRequest request = new SaveCommentRequest();
|
||||
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
|
||||
mailService.sendHtml(userIds, "reviewer", reviewRequest, request, testCaseWithBLOBs);
|
||||
|
||||
}
|
||||
|
||||
|
@ -148,7 +150,9 @@ public class TestCaseReviewService {
|
|||
testCaseReview.setUpdateTime(System.currentTimeMillis());
|
||||
checkCaseReviewExist(testCaseReview);
|
||||
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
|
||||
mailService.sendHtml(testCaseReview.getUserIds(), "reviewer", testCaseReview);
|
||||
SaveCommentRequest request = new SaveCommentRequest();
|
||||
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
|
||||
mailService.sendHtml(testCaseReview.getUserIds(), "reviewer", testCaseReview, request, testCaseWithBLOBs);
|
||||
}
|
||||
|
||||
private void editCaseReviewer(SaveTestCaseReviewRequest testCaseReview) {
|
||||
|
@ -321,6 +325,20 @@ public class TestCaseReviewService {
|
|||
}
|
||||
}
|
||||
testCaseReview.setStatus(TestPlanStatus.Completed.name());
|
||||
SaveCommentRequest request = new SaveCommentRequest();
|
||||
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
|
||||
SaveTestCaseReviewRequest testCaseReviewRequest = new SaveTestCaseReviewRequest();
|
||||
TestCaseReview _testCaseReview = testCaseReviewMapper.selectByPrimaryKey(reviewId);
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(_testCaseReview.getCreator());
|
||||
try {
|
||||
BeanUtils.copyProperties(testCaseReviewRequest, _testCaseReview);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mailService.sendHtml(userIds, "end", testCaseReviewRequest, request, testCaseWithBLOBs);
|
||||
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue