mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-03 04:28:51 +08:00
fix(项目设置): 修复缺陷更新时通知不能解析处理人的问题
--bug=1015711 --user=刘瑞斌 [项目设置]github #16751消息设置设置新建缺陷的接收人是处理人,在消息通知时没有@处理人。 https://www.tapd.cn/55049933/s/1224126 Closes #16751
This commit is contained in:
parent
7d8d70497d
commit
55f05e6bb9
@ -2,10 +2,12 @@ package io.metersphere.notice.sender;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.metersphere.api.service.ApiAutomationService;
|
||||
import io.metersphere.api.service.ApiDefinitionService;
|
||||
import io.metersphere.api.service.ApiTestCaseService;
|
||||
import io.metersphere.base.domain.CustomField;
|
||||
import io.metersphere.base.domain.TestCaseReview;
|
||||
import io.metersphere.commons.constants.NoticeConstants;
|
||||
import io.metersphere.commons.constants.NotificationConstants;
|
||||
@ -14,10 +16,12 @@ import io.metersphere.notice.domain.MessageDetail;
|
||||
import io.metersphere.notice.domain.Receiver;
|
||||
import io.metersphere.notice.domain.UserDetail;
|
||||
import io.metersphere.performance.service.PerformanceTestService;
|
||||
import io.metersphere.service.CustomFieldService;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.track.service.TestCaseReviewService;
|
||||
import io.metersphere.track.service.TestCaseService;
|
||||
import io.metersphere.track.service.TestPlanService;
|
||||
import org.apache.commons.beanutils.BeanMap;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
@ -55,24 +59,14 @@ public abstract class AbstractNoticeSender implements NoticeSender {
|
||||
@Resource
|
||||
@Lazy
|
||||
private TestCaseReviewService testCaseReviewService;
|
||||
@Resource
|
||||
private CustomFieldService customFieldService;
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
protected String getContext(MessageDetail messageDetail, NoticeModel noticeModel) {
|
||||
// 如果有自定义字段
|
||||
if (noticeModel.getParamMap().containsKey("customFields")) {
|
||||
String customFields = (String) noticeModel.getParamMap().get("customFields");
|
||||
JSONArray array = JSON.parseArray(customFields);
|
||||
if (CollectionUtils.isNotEmpty(array)) {
|
||||
for (Object o : array) {
|
||||
JSONObject jsonObject = JSON.parseObject(o.toString());
|
||||
String name = jsonObject.getString("name");
|
||||
Object value = jsonObject.getObject("value", Object.class);
|
||||
noticeModel.getParamMap().put(name, value); // 处理人
|
||||
if (StringUtils.equals(jsonObject.getString("name"), "处理人")) {
|
||||
noticeModel.getParamMap().put("processor", value); // 处理人
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
handleCustomFields(noticeModel);
|
||||
|
||||
// 处理 userIds 中包含的特殊值
|
||||
noticeModel.setReceivers(getRealUserIds(messageDetail, noticeModel, messageDetail.getEvent()));
|
||||
@ -112,6 +106,39 @@ public abstract class AbstractNoticeSender implements NoticeSender {
|
||||
return getContent(context, noticeModel.getParamMap());
|
||||
}
|
||||
|
||||
private void handleCustomFields(NoticeModel noticeModel) {
|
||||
if (!noticeModel.getParamMap().containsKey("fields")) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Object customFields = noticeModel.getParamMap().get("fields");
|
||||
List<Object> fields;
|
||||
if (customFields instanceof String) {
|
||||
fields = objectMapper.readValue((String) customFields, new TypeReference<>() {
|
||||
});
|
||||
} else {
|
||||
fields = (List<Object>) customFields;
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(fields)) {
|
||||
for (Object o : fields) {
|
||||
Map jsonObject = new BeanMap(o);
|
||||
String id = (String) jsonObject.get("id");
|
||||
CustomField customField = customFieldService.get(id);
|
||||
Object value = jsonObject.get("value");
|
||||
if (value instanceof String && StringUtils.isNotEmpty((String) value)) {
|
||||
String v = StringUtils.unwrap((String) value, "\"");
|
||||
noticeModel.getParamMap().put(customField.getName(), v); // 处理人
|
||||
if (StringUtils.equals(customField.getName(), "处理人")) {
|
||||
noticeModel.getParamMap().put("processor", v); // 处理人
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getContent(String template, Map<String, Object> context) {
|
||||
// 处理 null
|
||||
context.forEach((k, v) -> {
|
||||
|
@ -66,8 +66,7 @@ public class IssuesController {
|
||||
@PostMapping(value = "/add", consumes = {"multipart/form-data"})
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_CREATE)
|
||||
@MsAuditLog(module = OperLogModule.TRACK_BUG, type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#issuesRequest)", msClass = IssuesService.class)
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.DEFECT_TASK, target = "#issuesRequest",
|
||||
event = NoticeConstants.Event.CREATE, subject = "缺陷通知")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.DEFECT_TASK, event = NoticeConstants.Event.CREATE, subject = "缺陷通知")
|
||||
public IssuesWithBLOBs addIssues(@RequestPart(value = "request") IssuesUpdateRequest issuesRequest, @RequestPart(value = "file", required = false) List<MultipartFile> files) {
|
||||
return issuesService.addIssues(issuesRequest, files);
|
||||
}
|
||||
@ -75,10 +74,9 @@ public class IssuesController {
|
||||
@PostMapping(value = "/update")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_EDIT)
|
||||
@MsAuditLog(module = OperLogModule.TRACK_BUG, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#issuesRequest.id)", content = "#msClass.getLogDetails(#issuesRequest.id)", msClass = IssuesService.class)
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.DEFECT_TASK, target = "#issuesRequest",
|
||||
event = NoticeConstants.Event.UPDATE, subject = "缺陷通知")
|
||||
public void updateIssues(@RequestPart(value = "request") IssuesUpdateRequest issuesRequest) {
|
||||
issuesService.updateIssues(issuesRequest);
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.DEFECT_TASK, event = NoticeConstants.Event.UPDATE, subject = "缺陷通知")
|
||||
public IssuesWithBLOBs updateIssues(@RequestPart(value = "request") IssuesUpdateRequest issuesRequest) {
|
||||
return issuesService.updateIssues(issuesRequest);
|
||||
}
|
||||
|
||||
@GetMapping("/get/case/{refType}/{id}")
|
||||
|
@ -32,7 +32,6 @@ import io.metersphere.track.request.issues.PlatformIssueTypeRequest;
|
||||
import io.metersphere.track.request.testcase.AuthUserIssueRequest;
|
||||
import io.metersphere.track.request.testcase.IssuesRequest;
|
||||
import io.metersphere.track.request.testcase.IssuesUpdateRequest;
|
||||
import io.metersphere.track.request.testcase.TestCaseBatchRequest;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -142,13 +141,15 @@ public class IssuesService {
|
||||
return issues;
|
||||
}
|
||||
|
||||
public void updateIssues(IssuesUpdateRequest issuesRequest) {
|
||||
public IssuesWithBLOBs updateIssues(IssuesUpdateRequest issuesRequest) {
|
||||
List<AbstractIssuePlatform> platformList = getUpdatePlatforms(issuesRequest);
|
||||
platformList.forEach(platform -> {
|
||||
platform.updateIssue(issuesRequest);
|
||||
});
|
||||
customFieldIssuesService.editFields(issuesRequest.getId(), issuesRequest.getEditFields());
|
||||
customFieldIssuesService.addFields(issuesRequest.getId(), issuesRequest.getAddFields());
|
||||
|
||||
return getIssue(issuesRequest.getId());
|
||||
}
|
||||
|
||||
public void saveFollows(String issueId, List<String> follows) {
|
||||
|
Loading…
Reference in New Issue
Block a user