From 34542c257947f83e5887596ed5998aca6cf27298 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Thu, 18 May 2023 16:05:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=BC=BA=E9=99=B7=E6=93=8D=E4=BD=9C=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=95=B0=E6=8D=AE=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1026282 --user=宋昌昌 【项目设置】缺陷管理-创建缺陷&编辑功能用例-关联缺陷-创建缺陷-操作日志标题和日志详情数据为空 https://www.tapd.cn/55049933/s/1372822 --- .../controller/IssuesController.java | 2 +- .../io/metersphere/service/IssuesService.java | 42 +++++++++++++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java b/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java index 692449d9af..33222e1728 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java @@ -147,7 +147,7 @@ public class IssuesController { @PostMapping("/batchDelete") @RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_DELETE) - @MsAuditLog(module = OperLogModule.TRACK_BUG, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#request)", msClass = IssuesService.class) + @MsAuditLog(module = OperLogModule.TRACK_BUG, type = OperLogConstants.DELETE, msClass = IssuesService.class) public void batchDelete(@RequestBody IssuesUpdateRequest request) { issuesService.batchDelete(request); } diff --git a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java index f05ecdfe5f..fcc743cfd4 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java @@ -65,6 +65,7 @@ import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -747,6 +748,30 @@ public class IssuesService { data.setFields(fields); } + private String getCustomStatus(List fields) { + List customFields = fields.stream().filter(field -> StringUtils.equals(field.getName(), SystemCustomField.ISSUE_STATUS)) + .collect(Collectors.toList()); + if (CollectionUtils.isEmpty(customFields)) { + return null; + } + return customFields.get(0).getValue().toString(); + } + + private void buildCustomFieldStr(IssuesWithBLOBs issues, List fields) { + if (CollectionUtils.isEmpty(fields)) { + return; + } + List> custemFieldMaps = new ArrayList<>(); + fields.stream().filter(field -> ObjectUtils.isNotEmpty(field.getValue()) + && !StringUtils.equalsAnyIgnoreCase(field.getValue().toString(), StringUtils.EMPTY, "[]")).forEach(field -> { + Map custemFieldMap = new HashMap<>(); + custemFieldMap.put("name", field.getName()); + custemFieldMap.put("value", field.getValue()); + custemFieldMaps.add(custemFieldMap); + }); + issues.setCustomFields(JSON.toJSONString(custemFieldMaps)); + } + private void buildCustomField(List data, Boolean isThirdTemplate, List customFields) { if (CollectionUtils.isEmpty(data)) { return; @@ -1234,6 +1259,7 @@ public class IssuesService { public String getLogDetails(String id) { IssuesWithBLOBs issuesWithBLOBs = issuesMapper.selectByPrimaryKey(id); if (issuesWithBLOBs != null) { + issuesWithBLOBs.setStatus(StringUtils.equals(issuesWithBLOBs.getPlatform(), IssuesManagePlatform.Local.name()) ? issuesWithBLOBs.getStatus() : issuesWithBLOBs.getPlatformStatus()); List columns = ReflexObjectUtil.getColumns(issuesWithBLOBs, TestPlanReference.issuesColumns); OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(issuesWithBLOBs.getId()), issuesWithBLOBs.getProjectId(), issuesWithBLOBs.getTitle(), issuesWithBLOBs.getCreator(), columns); return JSON.toJSONString(details); @@ -1242,10 +1268,18 @@ public class IssuesService { } public String getLogDetails(IssuesUpdateRequest issuesRequest) { - if (issuesRequest != null) { - issuesRequest.setCreator(SessionUtils.getUserId()); - List columns = ReflexObjectUtil.getColumns(issuesRequest, TestPlanReference.issuesColumns); - OperatingLogDetails details = new OperatingLogDetails(null, issuesRequest.getProjectId(), issuesRequest.getTitle(), issuesRequest.getCreator(), columns); + IssuesWithBLOBs issuesWithBLOBs = issuesMapper.selectByPrimaryKey(issuesRequest.getId()); + if (issuesWithBLOBs != null) { + if (!StringUtils.equals(issuesWithBLOBs.getPlatform(), IssuesManagePlatform.Local.name())) { + issuesWithBLOBs.setStatus(issuesWithBLOBs.getPlatformStatus()); + } + String customStatus = getCustomStatus(issuesRequest.getRequestFields()); + if (customStatus != null) { + issuesWithBLOBs.setStatus(customStatus); + } + buildCustomFieldStr(issuesWithBLOBs, issuesRequest.getRequestFields()); + List columns = ReflexObjectUtil.getColumns(issuesWithBLOBs, TestPlanReference.issuesColumns); + OperatingLogDetails details = new OperatingLogDetails(null, issuesWithBLOBs.getProjectId(), issuesWithBLOBs.getTitle(), issuesWithBLOBs.getCreator(), columns); return JSON.toJSONString(details); } return null;