From 72bdde0de7c3d45b580acbba3015ad0a143c335e Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Tue, 19 Nov 2024 17:55:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=B7=A5=E4=BD=9C=E5=8F=B0):=20Local?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E7=BC=BA=E9=99=B7=E6=94=AF=E6=8C=81=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1049080 --user=宋昌昌 【工作台】我创建的-缺陷-点击LOCAL平台的缺陷ID查看-不展示缺陷信息 https://www.tapd.cn/55049933/s/1612335 --- .../bug/controller/BugController.java | 2 +- .../bug/dto/request/BugTemplateRequest.java | 5 +++++ .../metersphere/bug/service/BugService.java | 21 ++++++++++--------- .../bug/service/BugStatusService.java | 5 +++-- .../bug-management/components/basicInfo.vue | 13 ++++++++---- .../components/bug-detail-drawer.vue | 2 +- .../components/bugDetailTab.vue | 11 ++++++++-- 7 files changed, 39 insertions(+), 20 deletions(-) diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugController.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugController.java index 0529bf81cd..e75ea8a72b 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugController.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugController.java @@ -229,7 +229,7 @@ public class BugController { @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") public TemplateDTO getTemplateDetail(@RequestBody BugTemplateRequest request) { - return bugService.getTemplate(request.getId(), request.getProjectId(), request.getFromStatusId(), request.getPlatformBugKey()); + return bugService.getTemplate(request.getId(), request.getProjectId(), request.getFromStatusId(), request.getPlatformBugKey(), request.getShowLocal()); } @GetMapping("/follow/{id}") diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugTemplateRequest.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugTemplateRequest.java index 347dc3f7ec..54a9d5bcce 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugTemplateRequest.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugTemplateRequest.java @@ -5,6 +5,9 @@ import lombok.Data; import java.io.Serializable; +/** + * @author song-cc-rock + */ @Data public class BugTemplateRequest implements Serializable { @@ -16,4 +19,6 @@ public class BugTemplateRequest implements Serializable { private String fromStatusId; @Schema(description = "缺陷第三方平台Key") private String platformBugKey; + @Schema(description = "是否展示本地的模板详情") + private Boolean showLocal; } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java index 92f98152f1..8d42ee5055 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java @@ -62,6 +62,7 @@ import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -253,7 +254,7 @@ public class BugService { */ public BugDetailDTO get(String id, String currentUser) { Bug bug = checkBugExist(id); - TemplateDTO template = getTemplate(bug.getTemplateId(), bug.getProjectId(), null, null); + TemplateDTO template = getTemplate(bug.getTemplateId(), bug.getProjectId(), null, null, StringUtils.equals(bug.getPlatform(), BugPlatform.LOCAL.getName())); List allCustomFields = extBugCustomFieldMapper.getBugAllCustomFields(List.of(id), bug.getProjectId()); BugDetailDTO detail = new BugDetailDTO(); detail.setId(id); @@ -380,21 +381,21 @@ public class BugService { * @param platformBugKey 平台缺陷key * @return 模板详情 */ - public TemplateDTO getTemplate(String templateId, String projectId, String fromStatusId, String platformBugKey) { + public TemplateDTO getTemplate(String templateId, String projectId, String fromStatusId, String platformBugKey, Boolean showLocal) { Template template = templateMapper.selectByPrimaryKey(templateId); if (template != null) { // 属于系统模板 - return injectPlatformTemplateBugField(baseTemplateService.getTemplateDTO(template), projectId, fromStatusId, platformBugKey); + return injectPlatformTemplateBugField(baseTemplateService.getTemplateDTO(template), projectId, fromStatusId, platformBugKey, showLocal); } else { // 不属于系统模板 List option = projectTemplateService.getOption(projectId, TemplateScene.BUG.name()); Optional isThirdPartyDefaultTemplate = option.stream().filter(projectTemplateOptionDTO -> StringUtils.equals(projectTemplateOptionDTO.getId(), templateId)).findFirst(); if (isThirdPartyDefaultTemplate.isPresent()) { // 属于第三方平台默认模板(平台生成的默认模板无需注入配置中的字段) - return attachTemplateStatusField(getPluginBugDefaultTemplate(projectId, true), projectId, fromStatusId, platformBugKey); + return attachTemplateStatusField(getPluginBugDefaultTemplate(projectId, true), projectId, fromStatusId, platformBugKey, false); } else { // 不属于系统模板&&不属于第三方平台默认模板, 则该模板已被删除 - return injectPlatformTemplateBugField(projectTemplateService.getDefaultTemplateDTO(projectId, TemplateScene.BUG.name()), projectId, fromStatusId, platformBugKey); + return injectPlatformTemplateBugField(projectTemplateService.getDefaultTemplateDTO(projectId, TemplateScene.BUG.name()), projectId, fromStatusId, platformBugKey, showLocal); } } } @@ -882,16 +883,16 @@ public class BugService { * @param platformBugKey 平台缺陷key * @return 模板 */ - private TemplateDTO injectPlatformTemplateBugField(TemplateDTO templateDTO, String projectId, String fromStatusId, String platformBugKey) { + private TemplateDTO injectPlatformTemplateBugField(TemplateDTO templateDTO, String projectId, String fromStatusId, String platformBugKey, Boolean showLocal) { // 来自平台模板 templateDTO.setPlatformDefault(false); String platformName = projectApplicationService.getPlatformName(projectId); // 状态字段 - attachTemplateStatusField(templateDTO, projectId, fromStatusId, platformBugKey); + attachTemplateStatusField(templateDTO, projectId, fromStatusId, platformBugKey, showLocal); // 内置字段(处理人字段) - if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { + if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName()) && BooleanUtils.isFalse(showLocal)) { // 获取插件中自定义的注入字段(处理人) ServiceIntegration serviceIntegration = projectApplicationService.getPlatformServiceIntegrationWithSyncOrDemand(projectId, true); // 状态选项获取时, 获取平台校验了服务集成配置, 所以此处不需要再次校验 @@ -951,7 +952,7 @@ public class BugService { * @param platformBugKey 平台缺陷key * @return 模板 */ - public TemplateDTO attachTemplateStatusField(TemplateDTO templateDTO, String projectId, String fromStatusId, String platformBugKey) { + public TemplateDTO attachTemplateStatusField(TemplateDTO templateDTO, String projectId, String fromStatusId, String platformBugKey, Boolean showLocal) { if (templateDTO == null) { return null; } @@ -960,7 +961,7 @@ public class BugService { statusField.setFieldName(BugTemplateCustomField.STATUS.getName()); statusField.setFieldKey(BugTemplateCustomField.STATUS.getId()); statusField.setType(CustomFieldType.SELECT.name()); - List statusOption = bugStatusService.getToStatusItemOption(projectId, fromStatusId, platformBugKey); + List statusOption = bugStatusService.getToStatusItemOption(projectId, fromStatusId, platformBugKey, showLocal); List statusCustomOption = statusOption.stream().map(option -> { CustomFieldOption customFieldOption = new CustomFieldOption(); customFieldOption.setText(option.getText()); diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugStatusService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugStatusService.java index 4490d90e20..871a24145d 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugStatusService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugStatusService.java @@ -12,6 +12,7 @@ import io.metersphere.sdk.util.LogUtils; import io.metersphere.system.service.BaseStatusFlowSettingService; import jakarta.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -68,9 +69,9 @@ public class BugStatusService { * @param platformBugKey 平台缺陷Key * @return 选项集合 */ - public List getToStatusItemOption(String projectId, String fromStatusId, String platformBugKey) { + public List getToStatusItemOption(String projectId, String fromStatusId, String platformBugKey, Boolean showLocal) { String platformName = projectApplicationService.getPlatformName(projectId); - if (StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { + if (StringUtils.equals(platformName, BugPlatform.LOCAL.getName()) || BooleanUtils.isTrue(showLocal)) { // Local状态流 return getToStatusItemOptionOnLocal(projectId, fromStatusId); } else { diff --git a/frontend/src/views/bug-management/components/basicInfo.vue b/frontend/src/views/bug-management/components/basicInfo.vue index b6915647a5..5fca63202e 100644 --- a/frontend/src/views/bug-management/components/basicInfo.vue +++ b/frontend/src/views/bug-management/components/basicInfo.vue @@ -2,7 +2,10 @@
-
+
@@ -32,7 +35,9 @@ @@ -65,7 +70,7 @@ import { BugEditCustomField, BugEditFormObject, type CustomFieldItem } from '@/models/bug-management'; - import { getCurrentText, makeCustomFieldsParams } from '../utils'; + import { makeCustomFieldsParams } from '../utils'; const appStore = useAppStore(); 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 03d4fac5f9..d4253118de 100644 --- a/frontend/src/views/bug-management/components/bug-detail-drawer.vue +++ b/frontend/src/views/bug-management/components/bug-detail-drawer.vue @@ -212,7 +212,6 @@ import useModal from '@/hooks/useModal'; import { useAppStore } from '@/store'; import useUserStore from '@/store/modules/user'; - import { characterLimit } from '@/utils'; import { hasAnyPermission } from '@/utils/permission'; import type { CustomFieldItem } from '@/models/bug-management'; @@ -323,6 +322,7 @@ id: detail.templateId, fromStatusId: detail.status, platformBugKey: detail.platformBugId, + showLocal: detail.platform === 'Local', }); // 详情信息, TAG赋值 detailInfo.value = { ...detail }; diff --git a/frontend/src/views/bug-management/components/bugDetailTab.vue b/frontend/src/views/bug-management/components/bugDetailTab.vue index 022ebc7fa0..a43ca9b2a0 100644 --- a/frontend/src/views/bug-management/components/bugDetailTab.vue +++ b/frontend/src/views/bug-management/components/bugDetailTab.vue @@ -1,9 +1,16 @@