fix(消息通知): 修复测试评审变量不全的问题

--bug=1007495 --user=刘瑞斌 【消息通知】模板变量问题汇总 https://www.tapd.cn/55049933/s/1103123
This commit is contained in:
CaptainB 2022-02-11 15:18:39 +08:00 committed by 刘瑞斌
parent 056bf36a93
commit 257420dadf
4 changed files with 8 additions and 74 deletions

View File

@ -21,7 +21,6 @@ import io.metersphere.track.dto.TestReviewDTOWithMetric;
import io.metersphere.track.request.testreview.*;
import io.metersphere.track.service.TestCaseCommentService;
import io.metersphere.track.service.TestCaseReviewService;
import io.metersphere.track.service.TestCaseService;
import io.metersphere.track.service.TestReviewProjectService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
@ -157,7 +156,7 @@ public class TestCaseReviewController {
@PostMapping("/comment/save")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_COMMENT)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseCommentService.class)
@SendNotice(taskType = NoticeConstants.TaskType.REVIEW_TASK, target = "#targetClass.getTestCase(#request.caseId)", targetClass = TestCaseService.class,
@SendNotice(taskType = NoticeConstants.TaskType.REVIEW_TASK, target = "#targetClass.getTestReview(#request.reviewId)", targetClass = TestCaseReviewService.class,
event = NoticeConstants.Event.COMMENT, mailTemplate = "track/TestCaseComment", subject = "测试评审通知")
public TestCaseComment saveComment(@RequestBody SaveCommentRequest request) {
request.setId(UUID.randomUUID().toString());

View File

@ -4,21 +4,15 @@ import com.alibaba.fastjson.JSON;
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.base.mapper.ext.ExtTestCaseCommentMapper;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.BaseSystemConfigDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.track.TestCaseReviewReference;
import io.metersphere.notice.sender.NoticeModel;
import io.metersphere.notice.service.NoticeSendService;
import io.metersphere.service.SystemParameterService;
import io.metersphere.track.dto.TestCaseCommentDTO;
import io.metersphere.track.request.testreview.SaveCommentRequest;
import org.apache.commons.lang3.StringUtils;
@ -27,13 +21,12 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class TestCaseCommentService {
@Resource
TestCaseReviewMapper testCaseReviewMapper;
@Resource
private TestCaseCommentMapper testCaseCommentMapper;
@Resource
@ -42,10 +35,6 @@ public class TestCaseCommentService {
private ExtTestCaseCommentMapper extTestCaseCommentMapper;
@Resource
private UserMapper userMapper;
@Resource
private NoticeSendService noticeSendService;
@Resource
private SystemParameterService systemParameterService;
public TestCaseComment saveComment(SaveCommentRequest request) {
TestCaseComment testCaseComment = new TestCaseComment();
@ -57,30 +46,6 @@ public class TestCaseCommentService {
testCaseComment.setDescription(request.getDescription());
testCaseComment.setStatus(request.getStatus());
testCaseCommentMapper.insert(testCaseComment);
// TestCaseWithBLOBs testCaseWithBLOBs;
// testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(request.getCaseId());
//
// // 发送通知
// User user = userMapper.selectByPrimaryKey(testCaseComment.getAuthor());
// BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
// List<String> userIds = new ArrayList<>();
// userIds.add(testCaseWithBLOBs.getMaintainer());//用例维护人
// String context = getReviewContext(testCaseComment, testCaseWithBLOBs);
// Map<String, Object> paramMap = new HashMap<>();
// paramMap.put("maintainer", user.getName());
// paramMap.put("testCaseName", testCaseWithBLOBs.getName());
// paramMap.put("description", request.getDescription());
// paramMap.put("url", baseSystemConfigDTO.getUrl());
// paramMap.put("id", request.getReviewId());
// NoticeModel noticeModel = NoticeModel.builder()
// .context(context)
// .relatedUsers(userIds)
// .subject(Translator.get("test_review_task_notice"))
// .mailTemplate("ReviewComments")
// .paramMap(paramMap)
// .event(NoticeConstants.Event.COMMENT)
// .build();
// noticeSendService.send(NoticeConstants.TaskType.REVIEW_TASK, noticeModel);
return testCaseComment;
}

View File

@ -31,6 +31,7 @@ import io.metersphere.track.dto.TestCaseReviewDTO;
import io.metersphere.track.dto.TestReviewCaseDTO;
import io.metersphere.track.dto.TestReviewDTOWithMetric;
import io.metersphere.track.request.testreview.*;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -118,38 +119,11 @@ public class TestCaseReviewService {
}
//评审内容
private Map<String, String> getReviewParamMap(SaveTestCaseReviewRequest reviewRequest) {
Long startTime = reviewRequest.getCreateTime();
Long endTime = reviewRequest.getEndTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
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)));
}
Map<String, String> paramMap = new HashMap<>();
private Map getReviewParamMap(TestCaseReview review) {
Map paramMap = new HashMap<>();
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
paramMap.put("url", baseSystemConfigDTO.getUrl());
paramMap.put("creator", reviewRequest.getCreator());
paramMap.put("name", reviewRequest.getName());
paramMap.put("start", start);
paramMap.put("end", end);
paramMap.put("id", reviewRequest.getId());
String status = "";
if (StringUtils.equals(TestPlanStatus.Underway.name(), reviewRequest.getStatus())) {
status = "进行中";
} else if (StringUtils.equals(TestPlanStatus.Prepare.name(), reviewRequest.getStatus())) {
status = "未开始";
} else if (StringUtils.equals(TestPlanStatus.Completed.name(), reviewRequest.getStatus())) {
status = "已完成";
}
paramMap.put("status", status);
paramMap.putAll(new BeanMap(review));
return paramMap;
}
@ -439,7 +413,7 @@ public class TestCaseReviewService {
try {
BeanUtils.copyProperties(testCaseReviewRequest, _testCaseReview);
String context = getReviewContext(testCaseReviewRequest, NoticeConstants.Event.UPDATE);
Map<String, Object> paramMap = new HashMap<>(getReviewParamMap(testCaseReviewRequest));
Map<String, Object> paramMap = new HashMap<>(getReviewParamMap(_testCaseReview));
paramMap.put("operator", SessionUtils.getUser().getName());
NoticeModel noticeModel = NoticeModel.builder()
.operator(SessionUtils.getUserId())

View File

@ -190,10 +190,6 @@ export default {
label:this.$t('commons.name'),
value:'name',
},
{
label:this.$t('commons.create_user'),
value:'creator',
},
{
label:this.$t('commons.status'),
value:'status',