fix(消息通知): 修复测试评审变量不全的问题
--bug=1007495 --user=刘瑞斌 【消息通知】模板变量问题汇总 https://www.tapd.cn/55049933/s/1103123
This commit is contained in:
parent
067bbbdc03
commit
7e9eb47145
|
@ -21,7 +21,6 @@ import io.metersphere.track.dto.TestReviewDTOWithMetric;
|
||||||
import io.metersphere.track.request.testreview.*;
|
import io.metersphere.track.request.testreview.*;
|
||||||
import io.metersphere.track.service.TestCaseCommentService;
|
import io.metersphere.track.service.TestCaseCommentService;
|
||||||
import io.metersphere.track.service.TestCaseReviewService;
|
import io.metersphere.track.service.TestCaseReviewService;
|
||||||
import io.metersphere.track.service.TestCaseService;
|
|
||||||
import io.metersphere.track.service.TestReviewProjectService;
|
import io.metersphere.track.service.TestReviewProjectService;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -157,7 +156,7 @@ public class TestCaseReviewController {
|
||||||
@PostMapping("/comment/save")
|
@PostMapping("/comment/save")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_COMMENT)
|
@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)
|
@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 = "测试评审通知")
|
event = NoticeConstants.Event.COMMENT, mailTemplate = "track/TestCaseComment", subject = "测试评审通知")
|
||||||
public TestCaseComment saveComment(@RequestBody SaveCommentRequest request) {
|
public TestCaseComment saveComment(@RequestBody SaveCommentRequest request) {
|
||||||
request.setId(UUID.randomUUID().toString());
|
request.setId(UUID.randomUUID().toString());
|
||||||
|
|
|
@ -4,21 +4,15 @@ import com.alibaba.fastjson.JSON;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.TestCaseCommentMapper;
|
import io.metersphere.base.mapper.TestCaseCommentMapper;
|
||||||
import io.metersphere.base.mapper.TestCaseMapper;
|
import io.metersphere.base.mapper.TestCaseMapper;
|
||||||
import io.metersphere.base.mapper.TestCaseReviewMapper;
|
|
||||||
import io.metersphere.base.mapper.UserMapper;
|
import io.metersphere.base.mapper.UserMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestCaseCommentMapper;
|
import io.metersphere.base.mapper.ext.ExtTestCaseCommentMapper;
|
||||||
import io.metersphere.commons.constants.NoticeConstants;
|
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.log.utils.ReflexObjectUtil;
|
import io.metersphere.log.utils.ReflexObjectUtil;
|
||||||
import io.metersphere.log.vo.DetailColumn;
|
import io.metersphere.log.vo.DetailColumn;
|
||||||
import io.metersphere.log.vo.OperatingLogDetails;
|
import io.metersphere.log.vo.OperatingLogDetails;
|
||||||
import io.metersphere.log.vo.track.TestCaseReviewReference;
|
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.dto.TestCaseCommentDTO;
|
||||||
import io.metersphere.track.request.testreview.SaveCommentRequest;
|
import io.metersphere.track.request.testreview.SaveCommentRequest;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -27,13 +21,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class TestCaseCommentService {
|
public class TestCaseCommentService {
|
||||||
@Resource
|
|
||||||
TestCaseReviewMapper testCaseReviewMapper;
|
|
||||||
@Resource
|
@Resource
|
||||||
private TestCaseCommentMapper testCaseCommentMapper;
|
private TestCaseCommentMapper testCaseCommentMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -42,10 +35,6 @@ public class TestCaseCommentService {
|
||||||
private ExtTestCaseCommentMapper extTestCaseCommentMapper;
|
private ExtTestCaseCommentMapper extTestCaseCommentMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
@Resource
|
|
||||||
private NoticeSendService noticeSendService;
|
|
||||||
@Resource
|
|
||||||
private SystemParameterService systemParameterService;
|
|
||||||
|
|
||||||
public TestCaseComment saveComment(SaveCommentRequest request) {
|
public TestCaseComment saveComment(SaveCommentRequest request) {
|
||||||
TestCaseComment testCaseComment = new TestCaseComment();
|
TestCaseComment testCaseComment = new TestCaseComment();
|
||||||
|
@ -57,30 +46,6 @@ public class TestCaseCommentService {
|
||||||
testCaseComment.setDescription(request.getDescription());
|
testCaseComment.setDescription(request.getDescription());
|
||||||
testCaseComment.setStatus(request.getStatus());
|
testCaseComment.setStatus(request.getStatus());
|
||||||
testCaseCommentMapper.insert(testCaseComment);
|
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;
|
return testCaseComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ import io.metersphere.track.dto.TestCaseReviewDTO;
|
||||||
import io.metersphere.track.dto.TestReviewCaseDTO;
|
import io.metersphere.track.dto.TestReviewCaseDTO;
|
||||||
import io.metersphere.track.dto.TestReviewDTOWithMetric;
|
import io.metersphere.track.dto.TestReviewDTOWithMetric;
|
||||||
import io.metersphere.track.request.testreview.*;
|
import io.metersphere.track.request.testreview.*;
|
||||||
|
import org.apache.commons.beanutils.BeanMap;
|
||||||
import org.apache.commons.beanutils.BeanUtils;
|
import org.apache.commons.beanutils.BeanUtils;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -118,38 +119,11 @@ public class TestCaseReviewService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//评审内容
|
//评审内容
|
||||||
private Map<String, String> getReviewParamMap(SaveTestCaseReviewRequest reviewRequest) {
|
private Map getReviewParamMap(TestCaseReview review) {
|
||||||
Long startTime = reviewRequest.getCreateTime();
|
Map paramMap = new HashMap<>();
|
||||||
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<>();
|
|
||||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||||
paramMap.put("url", baseSystemConfigDTO.getUrl());
|
paramMap.put("url", baseSystemConfigDTO.getUrl());
|
||||||
paramMap.put("creator", reviewRequest.getCreator());
|
paramMap.putAll(new BeanMap(review));
|
||||||
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);
|
|
||||||
return paramMap;
|
return paramMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +413,7 @@ public class TestCaseReviewService {
|
||||||
try {
|
try {
|
||||||
BeanUtils.copyProperties(testCaseReviewRequest, _testCaseReview);
|
BeanUtils.copyProperties(testCaseReviewRequest, _testCaseReview);
|
||||||
String context = getReviewContext(testCaseReviewRequest, NoticeConstants.Event.UPDATE);
|
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());
|
paramMap.put("operator", SessionUtils.getUser().getName());
|
||||||
NoticeModel noticeModel = NoticeModel.builder()
|
NoticeModel noticeModel = NoticeModel.builder()
|
||||||
.operator(SessionUtils.getUserId())
|
.operator(SessionUtils.getUserId())
|
||||||
|
|
|
@ -190,10 +190,6 @@ export default {
|
||||||
label:this.$t('commons.name'),
|
label:this.$t('commons.name'),
|
||||||
value:'name',
|
value:'name',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label:this.$t('commons.create_user'),
|
|
||||||
value:'creator',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label:this.$t('commons.status'),
|
label:this.$t('commons.status'),
|
||||||
value:'status',
|
value:'status',
|
||||||
|
|
Loading…
Reference in New Issue