From 1342a56ff57c4d9e332c89ea9d768f0c56f945e7 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Tue, 23 Jul 2024 15:08:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=BC=BA=E9=99=B7=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E5=B9=B3=E5=8F=B0=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=97=A5=E5=BF=97=E5=90=8D=E7=A7=B0=E6=9C=89?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1044337 --user=宋昌昌 【缺陷管理】项目集成jira-查看缺陷-基本信息-快捷编辑-生成系统日志-名称为空 https://www.tapd.cn/55049933/s/1552745 --- .../metersphere/bug/service/BugLogService.java | 16 ++++++++++++++-- .../components/bug-detail-drawer.vue | 9 ++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugLogService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugLogService.java index 16591910a4..a93d60137a 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugLogService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugLogService.java @@ -3,6 +3,7 @@ package io.metersphere.bug.service; import io.metersphere.bug.domain.Bug; import io.metersphere.bug.domain.BugContent; import io.metersphere.bug.dto.request.BugEditRequest; +import io.metersphere.bug.dto.response.BugCustomFieldDTO; import io.metersphere.bug.dto.response.BugDTO; import io.metersphere.bug.mapper.BugContentMapper; import io.metersphere.bug.mapper.BugMapper; @@ -13,6 +14,7 @@ import io.metersphere.system.log.constants.OperationLogModule; import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.log.dto.LogDTO; import jakarta.annotation.Resource; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -39,7 +41,7 @@ public class BugLogService { * @return 日志 */ public LogDTO addLog(BugEditRequest request, List files) { - LogDTO dto = new LogDTO(request.getProjectId(), null, null, null, OperationLogType.ADD.name(), OperationLogModule.BUG_MANAGEMENT_INDEX, request.getTitle()); + LogDTO dto = new LogDTO(request.getProjectId(), null, null, null, OperationLogType.ADD.name(), OperationLogModule.BUG_MANAGEMENT_INDEX, getPlatformTitle(request)); dto.setHistory(true); dto.setPath("/bug/add"); dto.setMethod(HttpMethodConstants.POST.name()); @@ -56,7 +58,7 @@ public class BugLogService { */ public LogDTO updateLog(BugEditRequest request, List files) { BugDTO history = getOriginalValue(request.getId()); - LogDTO dto = new LogDTO(request.getProjectId(), null, request.getId(), null, OperationLogType.UPDATE.name(), OperationLogModule.BUG_MANAGEMENT_INDEX, request.getTitle()); + LogDTO dto = new LogDTO(request.getProjectId(), null, request.getId(), null, OperationLogType.UPDATE.name(), OperationLogModule.BUG_MANAGEMENT_INDEX, getPlatformTitle(request)); dto.setHistory(true); dto.setPath("/bug/update"); dto.setMethod(HttpMethodConstants.POST.name()); @@ -123,4 +125,14 @@ public class BugLogService { // 缺陷自定义字段 return bugService.handleCustomField(List.of(originalBug), originalBug.getProjectId()).getFirst(); } + + /** + * 获取缺陷的标题 + * @param request 请求参数 + * @return 缺陷标题 + */ + private String getPlatformTitle(BugEditRequest request) { + BugCustomFieldDTO platformTitle = request.getCustomFields().stream().filter(field -> StringUtils.equalsAny(field.getId(), "summary")).findFirst().get(); + return StringUtils.isNotBlank(request.getTitle()) ? request.getTitle() : platformTitle.getValue(); + } } diff --git a/frontend/src/views/bug-management/components/bug-detail-drawer.vue b/frontend/src/views/bug-management/components/bug-detail-drawer.vue index 7dd9515832..c1f8845f83 100644 --- a/frontend/src/views/bug-management/components/bug-detail-drawer.vue +++ b/frontend/src/views/bug-management/components/bug-detail-drawer.vue @@ -350,9 +350,12 @@ } else if (item.type === 'INT' || item.type === 'FLOAT') { tmpObj[item.id] = Number(item.value); } else if (item.type === 'CASCADER') { - const arr = JSON.parse(item.value); - if (arr && arr instanceof Array && arr.length > 0) { - tmpObj[item.id] = arr[arr.length - 1]; + console.log(item.value === ''); + if (item.value !== '') { + const arr = JSON.parse(item.value); + if (arr && arr instanceof Array && arr.length > 0) { + tmpObj[item.id] = arr[arr.length - 1]; + } } } else if (SINGLE_TYPE.includes(item.type)) { const multipleOptions = getOptionFromTemplate(